Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2014 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. | |
| 4 | |
| 5 #include "base/strings/utf_string_conversions.h" | |
| 6 #include "chrome/browser/chrome_notification_types.h" | |
| 7 #include "chrome/browser/devtools/devtools_window.h" | |
| 8 #include "chrome/browser/ui/browser.h" | |
| 9 #include "chrome/browser/ui/tabs/tab_strip_model.h" | |
| 10 #include "chrome/test/base/in_process_browser_test.h" | |
| 11 #include "chrome/test/base/ui_test_utils.h" | |
| 12 #include "content/public/browser/devtools_manager.h" | |
| 13 #include "content/public/browser/web_contents.h" | |
| 14 | |
| 15 class InterstitialUITest : public InProcessBrowserTest { | |
| 16 public: | |
| 17 InterstitialUITest() {} | |
| 18 virtual ~InterstitialUITest() {} | |
| 19 | |
| 20 protected: | |
| 21 content::WebContents* GetInspectedTab() { | |
|
Bernhard Bauer
2014/07/16 10:22:45
Is this used?
meacer
2014/07/16 21:21:40
Done.
| |
| 22 return browser()->tab_strip_model()->GetWebContentsAt(0); | |
| 23 } | |
| 24 | |
| 25 void TestInterstitial(GURL url, std::string page_title) { | |
|
Bernhard Bauer
2014/07/16 10:22:45
const std::string&
meacer
2014/07/16 21:21:40
Done.
| |
| 26 ui_test_utils::NavigateToURL(browser(), url); | |
| 27 EXPECT_EQ( | |
| 28 base::ASCIIToUTF16(page_title), | |
| 29 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); | |
| 30 | |
| 31 // Should also be able to open and close devtools. | |
| 32 content::RenderViewHost* rvh = | |
| 33 browser()->tab_strip_model()->GetWebContentsAt(0)->GetRenderViewHost(); | |
| 34 DevToolsWindow* window = DevToolsWindow::OpenDevToolsWindowForTest(rvh, | |
| 35 true); | |
| 36 ui_test_utils::WaitUntilDevToolsWindowLoaded(window); | |
| 37 // Try closing the devtools. | |
| 38 content::WindowedNotificationObserver close_observer( | |
| 39 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
| 40 content::Source<content::WebContents>( | |
| 41 window->web_contents_for_test())); | |
| 42 DevToolsWindow::ToggleDevToolsWindow( | |
| 43 browser(), | |
| 44 DevToolsToggleAction::Toggle()); | |
| 45 close_observer.Wait(); | |
| 46 } | |
| 47 }; | |
| 48 | |
| 49 IN_PROC_BROWSER_TEST_F(InterstitialUITest, OpenInterstitial) { | |
| 50 TestInterstitial(GURL("chrome://interstitials"), "Interstitials"); | |
| 51 TestInterstitial(GURL("chrome://interstitials/--invalid--"), "Interstitials"); | |
| 52 TestInterstitial(GURL("chrome://interstitials/ssl"), "Privacy error"); | |
| 53 TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=malware"), | |
| 54 "Security error"); | |
| 55 TestInterstitial(GURL("chrome://interstitials/safebrowsing?type=phishing"), | |
| 56 "Security error"); | |
| 57 } | |
| OLD | NEW |