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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "chrome/browser/first_run/first_run.h" | 24 #include "chrome/browser/first_run/first_run.h" |
25 #include "chrome/browser/lifetime/application_lifetime.h" | 25 #include "chrome/browser/lifetime/application_lifetime.h" |
26 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 26 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
28 #include "chrome/browser/profiles/profile_manager.h" | 28 #include "chrome/browser/profiles/profile_manager.h" |
29 #include "chrome/browser/search/search.h" | 29 #include "chrome/browser/search/search.h" |
30 #include "chrome/browser/sessions/session_backend.h" | 30 #include "chrome/browser/sessions/session_backend.h" |
31 #include "chrome/browser/sessions/session_service_factory.h" | 31 #include "chrome/browser/sessions/session_service_factory.h" |
32 #include "chrome/browser/translate/translate_tab_helper.h" | 32 #include "chrome/browser/translate/translate_tab_helper.h" |
33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" | 33 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" |
| 34 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog_queue.h" |
34 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" | 35 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" |
35 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" | 36 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" |
36 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
37 #include "chrome/browser/ui/browser_command_controller.h" | 38 #include "chrome/browser/ui/browser_command_controller.h" |
38 #include "chrome/browser/ui/browser_commands.h" | 39 #include "chrome/browser/ui/browser_commands.h" |
39 #include "chrome/browser/ui/browser_finder.h" | 40 #include "chrome/browser/ui/browser_finder.h" |
40 #include "chrome/browser/ui/browser_iterator.h" | 41 #include "chrome/browser/ui/browser_iterator.h" |
41 #include "chrome/browser/ui/browser_navigator.h" | 42 #include "chrome/browser/ui/browser_navigator.h" |
42 #include "chrome/browser/ui/browser_tabstrip.h" | 43 #include "chrome/browser/ui/browser_tabstrip.h" |
43 #include "chrome/browser/ui/browser_ui_prefs.h" | 44 #include "chrome/browser/ui/browser_ui_prefs.h" |
(...skipping 1635 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1679 loop_runner->Run(); | 1680 loop_runner->Run(); |
1680 // interstitial is deleted now. | 1681 // interstitial is deleted now. |
1681 } | 1682 } |
1682 | 1683 |
1683 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); | 1684 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_VIEW_SOURCE)); |
1684 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); | 1685 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_PRINT)); |
1685 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); | 1686 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_SAVE_PAGE)); |
1686 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); | 1687 EXPECT_TRUE(command_updater->IsCommandEnabled(IDC_ENCODING_MENU)); |
1687 } | 1688 } |
1688 | 1689 |
| 1690 // Ensure that creating an interstitial page closes any JavaScript dialogs |
| 1691 // that were present on the previous page. See http://crbug.com/295695. |
| 1692 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialClosesDialogs) { |
| 1693 ASSERT_TRUE(test_server()->Start()); |
| 1694 host_resolver()->AddRule("www.example.com", "127.0.0.1"); |
| 1695 GURL url(test_server()->GetURL("empty.html")); |
| 1696 ui_test_utils::NavigateToURL(browser(), url); |
| 1697 |
| 1698 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1699 contents->GetRenderViewHost()->ExecuteJavascriptInWebFrame( |
| 1700 string16(), |
| 1701 ASCIIToUTF16("alert('Dialog showing!');")); |
| 1702 AppModalDialog* alert = ui_test_utils::WaitForAppModalDialog(); |
| 1703 EXPECT_TRUE(alert->IsValid()); |
| 1704 AppModalDialogQueue* dialog_queue = AppModalDialogQueue::GetInstance(); |
| 1705 EXPECT_TRUE(dialog_queue->HasActiveDialog()); |
| 1706 |
| 1707 TestInterstitialPage* interstitial = NULL; |
| 1708 { |
| 1709 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1710 new content::MessageLoopRunner); |
| 1711 |
| 1712 InterstitialObserver observer(contents, |
| 1713 loop_runner->QuitClosure(), |
| 1714 base::Closure()); |
| 1715 interstitial = new TestInterstitialPage(contents, false, GURL()); |
| 1716 loop_runner->Run(); |
| 1717 } |
| 1718 |
| 1719 // The interstitial should have closed the dialog. |
| 1720 EXPECT_TRUE(contents->ShowingInterstitialPage()); |
| 1721 EXPECT_FALSE(dialog_queue->HasActiveDialog()); |
| 1722 |
| 1723 { |
| 1724 scoped_refptr<content::MessageLoopRunner> loop_runner( |
| 1725 new content::MessageLoopRunner); |
| 1726 |
| 1727 InterstitialObserver observer(contents, |
| 1728 base::Closure(), |
| 1729 loop_runner->QuitClosure()); |
| 1730 interstitial->Proceed(); |
| 1731 loop_runner->Run(); |
| 1732 // interstitial is deleted now. |
| 1733 } |
| 1734 } |
| 1735 |
| 1736 |
1689 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCloseTab) { | 1737 IN_PROC_BROWSER_TEST_F(BrowserTest, InterstitialCloseTab) { |
1690 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 1738 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
1691 | 1739 |
1692 { | 1740 { |
1693 scoped_refptr<content::MessageLoopRunner> loop_runner( | 1741 scoped_refptr<content::MessageLoopRunner> loop_runner( |
1694 new content::MessageLoopRunner); | 1742 new content::MessageLoopRunner); |
1695 | 1743 |
1696 InterstitialObserver observer(contents, | 1744 InterstitialObserver observer(contents, |
1697 loop_runner->QuitClosure(), | 1745 loop_runner->QuitClosure(), |
1698 base::Closure()); | 1746 base::Closure()); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2425 exp_commit_size.Enlarge(wcv_resize_insets.width(), | 2473 exp_commit_size.Enlarge(wcv_resize_insets.width(), |
2426 wcv_resize_insets.height() + height_inset); | 2474 wcv_resize_insets.height() + height_inset); |
2427 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); | 2475 EXPECT_EQ(exp_commit_size, rwhv_commit_size2); |
2428 EXPECT_EQ(exp_commit_size, wcv_commit_size2); | 2476 EXPECT_EQ(exp_commit_size, wcv_commit_size2); |
2429 // Sizes of RenderWidgetHostView and WebContentsView before and after | 2477 // Sizes of RenderWidgetHostView and WebContentsView before and after |
2430 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. | 2478 // WebContentsDelegate::DidNavigateMainFramePostCommit should be the same. |
2431 EXPECT_EQ(rwhv_commit_size2, | 2479 EXPECT_EQ(rwhv_commit_size2, |
2432 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); | 2480 web_contents->GetRenderWidgetHostView()->GetViewBounds().size()); |
2433 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); | 2481 EXPECT_EQ(wcv_commit_size2, web_contents->GetView()->GetContainerSize()); |
2434 } | 2482 } |
OLD | NEW |