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 "chrome/app/chrome_command_ids.h" | 5 #include "chrome/app/chrome_command_ids.h" |
6 #include "chrome/browser/net/url_fixer_upper.h" | 6 #include "chrome/browser/net/url_fixer_upper.h" |
7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/browser_tabstrip.h" | 8 #include "chrome/browser/ui/browser_tabstrip.h" |
9 #include "chrome/browser/ui/constrained_window_tab_helper.h" | 9 #include "chrome/browser/ui/web_contents_modal_dialog_manager.h" |
10 #include "chrome/common/chrome_notification_types.h" | 10 #include "chrome/common/chrome_notification_types.h" |
11 #include "chrome/common/url_constants.h" | 11 #include "chrome/common/url_constants.h" |
12 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "chrome/test/ui/ui_test.h" | 14 #include "chrome/test/ui/ui_test.h" |
15 #include "content/public/browser/navigation_controller.h" | 15 #include "content/public/browser/navigation_controller.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/test_navigation_observer.h" | 17 #include "content/public/test/test_navigation_observer.h" |
18 #include "net/test/test_server.h" | 18 #include "net/test/test_server.h" |
19 | 19 |
(...skipping 10 matching lines...) Expand all Loading... |
30 ui_test_utils::NavigateToURL( | 30 ui_test_utils::NavigateToURL( |
31 browser(), | 31 browser(), |
32 GURL("javascript:document.getElementById('form').submit()")); | 32 GURL("javascript:document.getElementById('form').submit()")); |
33 | 33 |
34 // Try to reload it twice, checking for repost. | 34 // Try to reload it twice, checking for repost. |
35 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); | 35 content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
36 web_contents->GetController().Reload(true); | 36 web_contents->GetController().Reload(true); |
37 web_contents->GetController().Reload(true); | 37 web_contents->GetController().Reload(true); |
38 | 38 |
39 // There should only be one dialog open. | 39 // There should only be one dialog open. |
40 ConstrainedWindowTabHelper* constrained_window_tab_helper = | 40 WebContentsModalDialogManager* web_contents_dialog_manager = |
41 ConstrainedWindowTabHelper::FromWebContents(web_contents); | 41 WebContentsModalDialogManager::FromWebContents(web_contents); |
42 size_t num_constrained_windows = | 42 size_t num_dialogs = web_contents_dialog_manager->dialog_count(); |
43 constrained_window_tab_helper->dialog_count(); | 43 EXPECT_EQ(1u, num_dialogs); |
44 EXPECT_EQ(1u, num_constrained_windows); | |
45 | 44 |
46 // Navigate away from the page (this is when the test usually crashes). | 45 // Navigate away from the page (this is when the test usually crashes). |
47 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("bar")); | 46 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("bar")); |
48 | 47 |
49 // The dialog should've been closed. | 48 // The dialog should've been closed. |
50 num_constrained_windows = | 49 num_dialogs = web_contents_dialog_manager->dialog_count(); |
51 constrained_window_tab_helper->dialog_count(); | 50 EXPECT_EQ(0u, num_dialogs); |
52 EXPECT_EQ(0u, num_constrained_windows); | |
53 } | 51 } |
54 | 52 |
55 // If becomes flaky, disable on Windows and use http://crbug.com/47228 | 53 // If becomes flaky, disable on Windows and use http://crbug.com/47228 |
56 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { | 54 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { |
57 ASSERT_TRUE(test_server()->Start()); | 55 ASSERT_TRUE(test_server()->Start()); |
58 | 56 |
59 // Load a form. | 57 // Load a form. |
60 ui_test_utils::NavigateToURL( | 58 ui_test_utils::NavigateToURL( |
61 browser(), test_server()->GetURL("files/form.html")); | 59 browser(), test_server()->GetURL("files/form.html")); |
62 // Submit it. | 60 // Submit it. |
(...skipping 22 matching lines...) Expand all Loading... |
85 // Navigate away from the page. We can't use ui_test_utils:NavigateToURL | 83 // Navigate away from the page. We can't use ui_test_utils:NavigateToURL |
86 // because that waits for the current page to stop loading first, which won't | 84 // because that waits for the current page to stop loading first, which won't |
87 // happen while the auth dialog is up. | 85 // happen while the auth dialog is up. |
88 content::Source<content::NavigationController> source(&controller); | 86 content::Source<content::NavigationController> source(&controller); |
89 content::TestNavigationObserver navigation_observer(source); | 87 content::TestNavigationObserver navigation_observer(source); |
90 browser()->OpenURL(content::OpenURLParams( | 88 browser()->OpenURL(content::OpenURLParams( |
91 test_server()->GetURL("bar"), content::Referrer(), CURRENT_TAB, | 89 test_server()->GetURL("bar"), content::Referrer(), CURRENT_TAB, |
92 content::PAGE_TRANSITION_TYPED, false)); | 90 content::PAGE_TRANSITION_TYPED, false)); |
93 navigation_observer.Wait(); | 91 navigation_observer.Wait(); |
94 } | 92 } |
OLD | NEW |