| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdint.h> | 5 #include <stdint.h> |
| 6 #include <utility> | 6 #include <utility> |
| 7 | 7 |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 2482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2493 TestInterstitialPage* interstitial = | 2493 TestInterstitialPage* interstitial = |
| 2494 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); | 2494 new TestInterstitialPage(contents(), true, kGURL, &state, &deleted); |
| 2495 TestInterstitialPageStateGuard state_guard(interstitial); | 2495 TestInterstitialPageStateGuard state_guard(interstitial); |
| 2496 interstitial->Show(); | 2496 interstitial->Show(); |
| 2497 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); | 2497 int interstitial_entry_id = controller().GetTransientEntry()->GetUniqueID(); |
| 2498 interstitial->TestDidNavigate(interstitial_entry_id, true, kGURL); | 2498 interstitial->TestDidNavigate(interstitial_entry_id, true, kGURL); |
| 2499 | 2499 |
| 2500 // While the interstitial is showing, let's simulate the hidden page | 2500 // While the interstitial is showing, let's simulate the hidden page |
| 2501 // attempting to show a JS message. | 2501 // attempting to show a JS message. |
| 2502 IPC::Message* dummy_message = new IPC::Message; | 2502 IPC::Message* dummy_message = new IPC::Message; |
| 2503 contents()->RunJavaScriptMessage(main_test_rfh(), | 2503 contents()->RunJavaScriptDialog( |
| 2504 base::ASCIIToUTF16("This is an informative message"), | 2504 main_test_rfh(), base::ASCIIToUTF16("This is an informative message"), |
| 2505 base::ASCIIToUTF16("OK"), | 2505 base::ASCIIToUTF16("OK"), kGURL, JAVASCRIPT_DIALOG_TYPE_ALERT, |
| 2506 kGURL, JAVASCRIPT_MESSAGE_TYPE_ALERT, dummy_message); | 2506 dummy_message); |
| 2507 EXPECT_TRUE(contents()->last_dialog_suppressed_); | 2507 EXPECT_TRUE(contents()->last_dialog_suppressed_); |
| 2508 } | 2508 } |
| 2509 | 2509 |
| 2510 // Makes sure that if the source passed to CopyStateFromAndPrune has an | 2510 // Makes sure that if the source passed to CopyStateFromAndPrune has an |
| 2511 // interstitial it isn't copied over to the destination. | 2511 // interstitial it isn't copied over to the destination. |
| 2512 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { | 2512 TEST_F(WebContentsImplTest, CopyStateFromAndPruneSourceInterstitial) { |
| 2513 // Navigate to a page. | 2513 // Navigate to a page. |
| 2514 GURL url1("http://www.google.com"); | 2514 GURL url1("http://www.google.com"); |
| 2515 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1); | 2515 main_test_rfh()->NavigateAndCommitRendererInitiated(true, url1); |
| 2516 EXPECT_EQ(1, controller().GetEntryCount()); | 2516 EXPECT_EQ(1, controller().GetEntryCount()); |
| (...skipping 867 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3384 public: | 3384 public: |
| 3385 TestJavaScriptDialogManager() {} | 3385 TestJavaScriptDialogManager() {} |
| 3386 ~TestJavaScriptDialogManager() override {} | 3386 ~TestJavaScriptDialogManager() override {} |
| 3387 | 3387 |
| 3388 size_t reset_count() { return reset_count_; } | 3388 size_t reset_count() { return reset_count_; } |
| 3389 | 3389 |
| 3390 // JavaScriptDialogManager | 3390 // JavaScriptDialogManager |
| 3391 | 3391 |
| 3392 void RunJavaScriptDialog(WebContents* web_contents, | 3392 void RunJavaScriptDialog(WebContents* web_contents, |
| 3393 const GURL& origin_url, | 3393 const GURL& origin_url, |
| 3394 JavaScriptMessageType javascript_message_type, | 3394 JavaScriptDialogType dialog_type, |
| 3395 const base::string16& message_text, | 3395 const base::string16& message_text, |
| 3396 const base::string16& default_prompt_text, | 3396 const base::string16& default_prompt_text, |
| 3397 const DialogClosedCallback& callback, | 3397 const DialogClosedCallback& callback, |
| 3398 bool* did_suppress_message) override { | 3398 bool* did_suppress_message) override { |
| 3399 *did_suppress_message = true; | 3399 *did_suppress_message = true; |
| 3400 }; | 3400 }; |
| 3401 | 3401 |
| 3402 void RunBeforeUnloadDialog(WebContents* web_contents, | 3402 void RunBeforeUnloadDialog(WebContents* web_contents, |
| 3403 bool is_reload, | 3403 bool is_reload, |
| 3404 const DialogClosedCallback& callback) override {} | 3404 const DialogClosedCallback& callback) override {} |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3436 // An automatic navigation. | 3436 // An automatic navigation. |
| 3437 main_test_rfh()->SendNavigateWithModificationCallback( | 3437 main_test_rfh()->SendNavigateWithModificationCallback( |
| 3438 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); | 3438 0, true, GURL(url::kAboutBlankURL), base::Bind(SetAsNonUserGesture)); |
| 3439 | 3439 |
| 3440 EXPECT_EQ(1u, dialog_manager.reset_count()); | 3440 EXPECT_EQ(1u, dialog_manager.reset_count()); |
| 3441 | 3441 |
| 3442 contents()->SetJavaScriptDialogManagerForTesting(nullptr); | 3442 contents()->SetJavaScriptDialogManagerForTesting(nullptr); |
| 3443 } | 3443 } |
| 3444 | 3444 |
| 3445 } // namespace content | 3445 } // namespace content |
| OLD | NEW |