OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 "base/strings/utf_string_conversions.h" | 5 #include "base/strings/utf_string_conversions.h" |
6 #include "chrome/browser/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.h" |
7 #include "chrome/browser/devtools/devtools_window.h" | 7 #include "chrome/browser/devtools/devtools_window.h" |
8 #include "chrome/browser/devtools/devtools_window_testing.h" | 8 #include "chrome/browser/devtools/devtools_window_testing.h" |
9 #include "chrome/browser/ui/browser.h" | 9 #include "chrome/browser/ui/browser.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 11 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
11 #include "chrome/test/base/in_process_browser_test.h" | 12 #include "chrome/test/base/in_process_browser_test.h" |
12 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
13 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
14 | 15 |
15 class InterstitialUITest : public InProcessBrowserTest { | 16 class InterstitialUITest : public InProcessBrowserTest { |
16 public: | 17 public: |
17 InterstitialUITest() {} | 18 InterstitialUITest() {} |
18 ~InterstitialUITest() override {} | 19 ~InterstitialUITest() override {} |
19 | 20 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 | 78 |
78 IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitial) { | 79 IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitial) { |
79 TestInterstitial(GURL("chrome://interstitials/captiveportal"), | 80 TestInterstitial(GURL("chrome://interstitials/captiveportal"), |
80 "Connect to network"); | 81 "Connect to network"); |
81 } | 82 } |
82 | 83 |
83 IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitialWifi) { | 84 IN_PROC_BROWSER_TEST_F(InterstitialUITest, CaptivePortalInterstitialWifi) { |
84 TestInterstitial(GURL("chrome://interstitials/captiveportal?is_wifi=1"), | 85 TestInterstitial(GURL("chrome://interstitials/captiveportal?is_wifi=1"), |
85 "Connect to Wi-Fi"); | 86 "Connect to Wi-Fi"); |
86 } | 87 } |
| 88 |
| 89 // Checks that the interstitial page uses correct web contents. If not, closing |
| 90 // the tab might result in a freed web contents pointer and cause a crash. |
| 91 // See https://crbug.com/611706 for details. |
| 92 IN_PROC_BROWSER_TEST_F(InterstitialUITest, UseCorrectWebContents) { |
| 93 int current_tab = browser()->tab_strip_model()->active_index(); |
| 94 ui_test_utils::NavigateToURL(browser(), GURL("chrome://interstitials/ssl")); |
| 95 |
| 96 // Duplicate the tab and close it. |
| 97 chrome::DuplicateTab(browser()); |
| 98 EXPECT_NE(current_tab, browser()->tab_strip_model()->active_index()); |
| 99 chrome::CloseTab(browser()); |
| 100 EXPECT_EQ(current_tab, browser()->tab_strip_model()->active_index()); |
| 101 |
| 102 // Reloading the page shouldn't cause a crash. |
| 103 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 104 } |
OLD | NEW |