Add ICU message format support
[chromium-blink-merge.git] / chrome / browser / repost_form_warning_browsertest.cc
blob0a17796aa3471076e8d28dee5ad7d8d258d36115
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
3 // found in the LICENSE file.
5 #include "chrome/app/chrome_command_ids.h"
6 #include "chrome/browser/chrome_notification_types.h"
7 #include "chrome/browser/ui/browser.h"
8 #include "chrome/browser/ui/tabs/tab_strip_model.h"
9 #include "chrome/common/url_constants.h"
10 #include "chrome/test/base/in_process_browser_test.h"
11 #include "chrome/test/base/ui_test_utils.h"
12 #include "components/web_modal/web_contents_modal_dialog_manager.h"
13 #include "content/public/browser/navigation_controller.h"
14 #include "content/public/browser/web_contents.h"
15 #include "content/public/test/test_navigation_observer.h"
16 #include "net/test/spawned_test_server/spawned_test_server.h"
18 using web_modal::WebContentsModalDialogManager;
20 typedef InProcessBrowserTest RepostFormWarningTest;
22 // If becomes flaky, disable on Windows and use http://crbug.com/47228
23 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestDoubleReload) {
24 ASSERT_TRUE(test_server()->Start());
26 // Load a form.
27 ui_test_utils::NavigateToURL(
28 browser(), test_server()->GetURL("files/form.html"));
29 // Submit it.
30 ui_test_utils::NavigateToURL(
31 browser(),
32 GURL("javascript:document.getElementById('form').submit()"));
34 // Try to reload it twice, checking for repost.
35 content::WebContents* web_contents =
36 browser()->tab_strip_model()->GetActiveWebContents();
37 web_contents->GetController().Reload(true);
38 web_contents->GetController().Reload(true);
40 // There should only be one dialog open.
41 WebContentsModalDialogManager* web_contents_modal_dialog_manager =
42 WebContentsModalDialogManager::FromWebContents(web_contents);
43 EXPECT_TRUE(web_contents_modal_dialog_manager->IsDialogActive());
45 // Navigate away from the page (this is when the test usually crashes).
46 ui_test_utils::NavigateToURL(browser(), test_server()->GetURL("bar"));
48 // The dialog should've been closed.
49 EXPECT_FALSE(web_contents_modal_dialog_manager->IsDialogActive());
52 // If becomes flaky, disable on Windows and use http://crbug.com/47228
53 IN_PROC_BROWSER_TEST_F(RepostFormWarningTest, TestLoginAfterRepost) {
54 ASSERT_TRUE(test_server()->Start());
56 // Load a form.
57 ui_test_utils::NavigateToURL(
58 browser(), test_server()->GetURL("files/form.html"));
59 // Submit it.
60 ui_test_utils::NavigateToURL(
61 browser(),
62 GURL("javascript:document.getElementById('form').submit()"));
64 // Try to reload it, checking for repost.
65 content::WebContents* web_contents =
66 browser()->tab_strip_model()->GetActiveWebContents();
67 web_contents->GetController().Reload(true);
69 // Navigate to a page that requires authentication, bringing up another
70 // tab-modal sheet.
71 content::NavigationController& controller = web_contents->GetController();
72 content::WindowedNotificationObserver observer(
73 chrome::NOTIFICATION_AUTH_NEEDED,
74 content::Source<content::NavigationController>(&controller));
75 browser()->OpenURL(content::OpenURLParams(
76 test_server()->GetURL("auth-basic"), content::Referrer(), CURRENT_TAB,
77 ui::PAGE_TRANSITION_TYPED, false));
78 observer.Wait();
80 // Try to reload it again.
81 web_contents->GetController().Reload(true);
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
85 // happen while the auth dialog is up.
86 content::TestNavigationObserver navigation_observer(web_contents);
87 browser()->OpenURL(content::OpenURLParams(
88 test_server()->GetURL("bar"), content::Referrer(), CURRENT_TAB,
89 ui::PAGE_TRANSITION_TYPED, false));
90 navigation_observer.Wait();