Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(40)

Side by Side Diff: chrome/browser/repost_form_warning_browsertest.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
11 #include "chrome/test/base/ui_test_utils.h" 11 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/web_modal/web_contents_modal_dialog_manager.h" 12 #include "components/web_modal/web_contents_modal_dialog_manager.h"
13 #include "content/public/browser/navigation_controller.h" 13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/web_contents.h" 14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/test_navigation_observer.h" 15 #include "content/public/test/test_navigation_observer.h"
16 #include "net/test/spawned_test_server/spawned_test_server.h"
17 16
18 using web_modal::WebContentsModalDialogManager; 17 using web_modal::WebContentsModalDialogManager;
19 18
20 typedef InProcessBrowserTest RepostFormWarningTest; 19 typedef InProcessBrowserTest RepostFormWarningTest;
21 20
22 // If becomes flaky, disable on Windows and use http://crbug.com/47228 21 // If becomes flaky, disable on Windows and use http://crbug.com/47228
23 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestDoubleReload) { 22 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestDoubleReload) {
24 ASSERT_TRUE(test_server()->Start()); 23 ASSERT_TRUE(embedded_test_server()->Start());
25 24
26 // Load a form. 25 // Load a form.
27 ui_test_utils::NavigateToURL( 26 ui_test_utils::NavigateToURL(browser(),
28 browser(), test_server()->GetURL("files/form.html")); 27 embedded_test_server()->GetURL("/form.html"));
29 // Submit it. 28 // Submit it.
30 ui_test_utils::NavigateToURL( 29 ui_test_utils::NavigateToURL(
31 browser(), 30 browser(),
32 GURL("javascript:document.getElementById('form').submit()")); 31 GURL("javascript:document.getElementById('form').submit()"));
33 32
34 // Try to reload it twice, checking for repost. 33 // Try to reload it twice, checking for repost.
35 content::WebContents* web_contents = 34 content::WebContents* web_contents =
36 browser()->tab_strip_model()->GetActiveWebContents(); 35 browser()->tab_strip_model()->GetActiveWebContents();
37 web_contents->GetController().Reload(true); 36 web_contents->GetController().Reload(true);
38 web_contents->GetController().Reload(true); 37 web_contents->GetController().Reload(true);
39 38
40 // There should only be one dialog open. 39 // There should only be one dialog open.
41 WebContentsModalDialogManager* web_contents_modal_dialog_manager = 40 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
42 WebContentsModalDialogManager::FromWebContents(web_contents); 41 WebContentsModalDialogManager::FromWebContents(web_contents);
43 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive()); 42 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
44 43
45 // Navigate away from the page (this is when the test usually crashes). 44 // Navigate away from the page (this is when the test usually crashes).
46 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("bar")); 45 ui_test_utils::NavigateToURL(browser(),
46 embedded_test_server()->GetURL("/bar"));
47 47
48 // The dialog should've been closed. 48 // The dialog should've been closed.
49 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive()); 49 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
50 } 50 }
51 51
52 // If becomes flaky, disable on Windows and use http://crbug.com/47228 52 // If becomes flaky, disable on Windows and use http://crbug.com/47228
53 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) { 53 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) {
54 ASSERT_TRUE(test_server()->Start()); 54 ASSERT_TRUE(embedded_test_server()->Start());
55 55
56 // Load a form. 56 // Load a form.
57 ui_test_utils::NavigateToURL( 57 ui_test_utils::NavigateToURL(browser(),
58 browser(), test_server()->GetURL("files/form.html")); 58 embedded_test_server()->GetURL("/form.html"));
59 // Submit it. 59 // Submit it.
60 ui_test_utils::NavigateToURL( 60 ui_test_utils::NavigateToURL(
61 browser(), 61 browser(),
62 GURL("javascript:document.getElementById('form').submit()")); 62 GURL("javascript:document.getElementById('form').submit()"));
63 63
64 // Try to reload it, checking for repost. 64 // Try to reload it, checking for repost.
65 content::WebContents* web_contents = 65 content::WebContents* web_contents =
66 browser()->tab_strip_model()->GetActiveWebContents(); 66 browser()->tab_strip_model()->GetActiveWebContents();
67 web_contents->GetController().Reload(true); 67 web_contents->GetController().Reload(true);
68 68
69 // Navigate to a page that requires authentication, bringing up another 69 // Navigate to a page that requires authentication, bringing up another
70 // tab-modal sheet. 70 // tab-modal sheet.
71 content::NavigationController& controller = web_contents->GetController(); 71 content::NavigationController& controller = web_contents->GetController();
72 content::WindowedNotificationObserver observer( 72 content::WindowedNotificationObserver observer(
73 chrome::NOTIFICATION_AUTH_NEEDED, 73 chrome::NOTIFICATION_AUTH_NEEDED,
74 content::Source<content::NavigationController>(&controller)); 74 content::Source<content::NavigationController>(&controller));
75 browser()->OpenURL(content::OpenURLParams( 75 browser()->OpenURL(content::OpenURLParams(
76 test_server()->GetURL("auth-basic"), content::Referrer(), CURRENT_TAB, 76 embedded_test_server()->GetURL("/auth-basic"), content::Referrer(),
77 ui::PAGE_TRANSITION_TYPED, false)); 77 CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false));
78 observer.Wait(); 78 observer.Wait();
79 79
80 // Try to reload it again. 80 // Try to reload it again.
81 web_contents->GetController().Reload(true); 81 web_contents->GetController().Reload(true);
82 82
83 // 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
84 // 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
85 // happen while the auth dialog is up. 85 // happen while the auth dialog is up.
86 content::TestNavigationObserver navigation_observer(web_contents); 86 content::TestNavigationObserver navigation_observer(web_contents);
87 browser()->OpenURL(content::OpenURLParams( 87 browser()->OpenURL(content::OpenURLParams(
88 test_server()->GetURL("bar"), content::Referrer(), CURRENT_TAB, 88 embedded_test_server()->GetURL("/bar"), content::Referrer(), CURRENT_TAB,
89 ui::PAGE_TRANSITION_TYPED, false)); 89 ui::PAGE_TRANSITION_TYPED, false));
90 navigation_observer.Wait(); 90 navigation_observer.Wait();
91 } 91 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698