| 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/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
| 7 #include "chrome/browser/ui/browser.h" | 7 #include "chrome/browser/ui/browser.h" |
| 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 8 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 ui_test_utils::NavigateToURL(browser(), | 27 ui_test_utils::NavigateToURL(browser(), |
| 28 embedded_test_server()->GetURL("/form.html")); | 28 embedded_test_server()->GetURL("/form.html")); |
| 29 // Submit it. | 29 // Submit it. |
| 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 = | 35 content::WebContents* web_contents = |
| 36 browser()->tab_strip_model()->GetActiveWebContents(); | 36 browser()->tab_strip_model()->GetActiveWebContents(); |
| 37 web_contents->GetController().Reload(true); | 37 web_contents->GetController().Reload(content::ReloadType::NORMAL, true); |
| 38 web_contents->GetController().Reload(true); | 38 web_contents->GetController().Reload(content::ReloadType::NORMAL, true); |
| 39 | 39 |
| 40 // There should only be one dialog open. | 40 // There should only be one dialog open. |
| 41 WebContentsModalDialogManager* web_contents_modal_dialog_manager = | 41 WebContentsModalDialogManager* web_contents_modal_dialog_manager = |
| 42 WebContentsModalDialogManager::FromWebContents(web_contents); | 42 WebContentsModalDialogManager::FromWebContents(web_contents); |
| 43 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); | 43 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); |
| 44 | 44 |
| 45 // 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). |
| 46 ui_test_utils::NavigateToURL(browser(), | 46 ui_test_utils::NavigateToURL(browser(), |
| 47 embedded_test_server()->GetURL("/bar")); | 47 embedded_test_server()->GetURL("/bar")); |
| 48 | 48 |
| 49 // The dialog should've been closed. | 49 // The dialog should've been closed. |
| 50 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); | 50 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); |
| 51 } | 51 } |
| 52 | 52 |
| 53 // 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 |
| 54 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { | 54 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { |
| 55 ASSERT_TRUE(embedded_test_server()->Start()); | 55 ASSERT_TRUE(embedded_test_server()->Start()); |
| 56 | 56 |
| 57 // Load a form. | 57 // Load a form. |
| 58 ui_test_utils::NavigateToURL(browser(), | 58 ui_test_utils::NavigateToURL(browser(), |
| 59 embedded_test_server()->GetURL("/form.html")); | 59 embedded_test_server()->GetURL("/form.html")); |
| 60 // Submit it. | 60 // Submit it. |
| 61 ui_test_utils::NavigateToURL( | 61 ui_test_utils::NavigateToURL( |
| 62 browser(), | 62 browser(), |
| 63 GURL("javascript:document.getElementById('form').submit()")); | 63 GURL("javascript:document.getElementById('form').submit()")); |
| 64 | 64 |
| 65 // Try to reload it, checking for repost. | 65 // Try to reload it, checking for repost. |
| 66 content::WebContents* web_contents = | 66 content::WebContents* web_contents = |
| 67 browser()->tab_strip_model()->GetActiveWebContents(); | 67 browser()->tab_strip_model()->GetActiveWebContents(); |
| 68 web_contents->GetController().Reload(true); | 68 web_contents->GetController().Reload(content::ReloadType::NORMAL, true); |
| 69 | 69 |
| 70 // Navigate to a page that requires authentication, bringing up another | 70 // Navigate to a page that requires authentication, bringing up another |
| 71 // tab-modal sheet. | 71 // tab-modal sheet. |
| 72 content::NavigationController& controller = web_contents->GetController(); | 72 content::NavigationController& controller = web_contents->GetController(); |
| 73 content::WindowedNotificationObserver observer( | 73 content::WindowedNotificationObserver observer( |
| 74 chrome::NOTIFICATION_AUTH_NEEDED, | 74 chrome::NOTIFICATION_AUTH_NEEDED, |
| 75 content::Source<content::NavigationController>(&controller)); | 75 content::Source<content::NavigationController>(&controller)); |
| 76 browser()->OpenURL(content::OpenURLParams( | 76 browser()->OpenURL(content::OpenURLParams( |
| 77 embedded_test_server()->GetURL("/auth-basic"), content::Referrer(), | 77 embedded_test_server()->GetURL("/auth-basic"), content::Referrer(), |
| 78 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); | 78 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 79 observer.Wait(); | 79 observer.Wait(); |
| 80 | 80 |
| 81 // Try to reload it again. | 81 // Try to reload it again. |
| 82 web_contents->GetController().Reload(true); | 82 web_contents->GetController().Reload(content::ReloadType::NORMAL, true); |
| 83 | 83 |
| 84 // Navigate away from the page. We can't use ui_test_utils:NavigateToURL | 84 // Navigate away from the page. We can't use ui_test_utils:NavigateToURL |
| 85 // because that waits for the current page to stop loading first, which won't | 85 // because that waits for the current page to stop loading first, which won't |
| 86 // happen while the auth dialog is up. | 86 // happen while the auth dialog is up. |
| 87 content::TestNavigationObserver navigation_observer(web_contents); | 87 content::TestNavigationObserver navigation_observer(web_contents); |
| 88 browser()->OpenURL(content::OpenURLParams( | 88 browser()->OpenURL(content::OpenURLParams( |
| 89 embedded_test_server()->GetURL("/bar"), content::Referrer(), | 89 embedded_test_server()->GetURL("/bar"), content::Referrer(), |
| 90 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); | 90 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 91 navigation_observer.Wait(); | 91 navigation_observer.Wait(); |
| 92 } | 92 } |
| OLD | NEW |