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 <map> | 5 #include <map> |
6 #include <memory> | 6 #include <memory> |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1243 void CaptivePortalBrowserTest::SlowLoadNoCaptivePortal( | 1243 void CaptivePortalBrowserTest::SlowLoadNoCaptivePortal( |
1244 Browser* browser, | 1244 Browser* browser, |
1245 CaptivePortalResult expected_result) { | 1245 CaptivePortalResult expected_result) { |
1246 CaptivePortalTabReloader* tab_reloader = | 1246 CaptivePortalTabReloader* tab_reloader = |
1247 GetTabReloader(browser->tab_strip_model()->GetActiveWebContents()); | 1247 GetTabReloader(browser->tab_strip_model()->GetActiveWebContents()); |
1248 ASSERT_TRUE(tab_reloader); | 1248 ASSERT_TRUE(tab_reloader); |
1249 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); | 1249 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); |
1250 | 1250 |
1251 MultiNavigationObserver navigation_observer; | 1251 MultiNavigationObserver navigation_observer; |
1252 CaptivePortalObserver portal_observer(browser->profile()); | 1252 CaptivePortalObserver portal_observer(browser->profile()); |
1253 ui_test_utils::NavigateToURLWithDisposition(browser, | 1253 ui_test_utils::NavigateToURLWithDisposition( |
1254 GURL(kMockHttpsUrl), | 1254 browser, GURL(kMockHttpsUrl), WindowOpenDisposition::CURRENT_TAB, |
1255 CURRENT_TAB, | 1255 ui_test_utils::BROWSER_TEST_NONE); |
1256 ui_test_utils::BROWSER_TEST_NONE); | |
1257 | 1256 |
1258 portal_observer.WaitForResults(1); | 1257 portal_observer.WaitForResults(1); |
1259 | 1258 |
1260 ASSERT_EQ(1, browser->tab_strip_model()->count()); | 1259 ASSERT_EQ(1, browser->tab_strip_model()->count()); |
1261 EXPECT_EQ(expected_result, portal_observer.captive_portal_result()); | 1260 EXPECT_EQ(expected_result, portal_observer.captive_portal_result()); |
1262 EXPECT_EQ(1, portal_observer.num_results_received()); | 1261 EXPECT_EQ(1, portal_observer.num_results_received()); |
1263 EXPECT_EQ(0, navigation_observer.num_navigations()); | 1262 EXPECT_EQ(0, navigation_observer.num_navigations()); |
1264 EXPECT_FALSE(CheckPending(browser)); | 1263 EXPECT_FALSE(CheckPending(browser)); |
1265 | 1264 |
1266 // First tab should still be loading. | 1265 // First tab should still be loading. |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1364 int initial_active_index = tab_strip_model->active_index(); | 1363 int initial_active_index = tab_strip_model->active_index(); |
1365 int initial_loading_tabs = NumLoadingTabs(); | 1364 int initial_loading_tabs = NumLoadingTabs(); |
1366 int expected_broken_tabs = NumBrokenTabs(); | 1365 int expected_broken_tabs = NumBrokenTabs(); |
1367 if (CaptivePortalTabReloader::STATE_BROKEN_BY_PORTAL != | 1366 if (CaptivePortalTabReloader::STATE_BROKEN_BY_PORTAL != |
1368 GetStateOfTabReloader(tab_strip_model->GetActiveWebContents())) { | 1367 GetStateOfTabReloader(tab_strip_model->GetActiveWebContents())) { |
1369 ++expected_broken_tabs; | 1368 ++expected_broken_tabs; |
1370 } | 1369 } |
1371 | 1370 |
1372 MultiNavigationObserver navigation_observer; | 1371 MultiNavigationObserver navigation_observer; |
1373 CaptivePortalObserver portal_observer(browser->profile()); | 1372 CaptivePortalObserver portal_observer(browser->profile()); |
1374 ui_test_utils::NavigateToURLWithDisposition(browser, | 1373 ui_test_utils::NavigateToURLWithDisposition( |
1375 hanging_url, | 1374 browser, hanging_url, WindowOpenDisposition::CURRENT_TAB, |
1376 CURRENT_TAB, | 1375 ui_test_utils::BROWSER_TEST_NONE); |
1377 ui_test_utils::BROWSER_TEST_NONE); | |
1378 portal_observer.WaitForResults(expected_portal_checks); | 1376 portal_observer.WaitForResults(expected_portal_checks); |
1379 | 1377 |
1380 if (expect_open_login_tab) { | 1378 if (expect_open_login_tab) { |
1381 ASSERT_GE(expected_login_tab_navigations, 1); | 1379 ASSERT_GE(expected_login_tab_navigations, 1); |
1382 | 1380 |
1383 navigation_observer.WaitForNavigations(expected_login_tab_navigations); | 1381 navigation_observer.WaitForNavigations(expected_login_tab_navigations); |
1384 | 1382 |
1385 ASSERT_EQ(initial_tab_count + 1, tab_strip_model->count()); | 1383 ASSERT_EQ(initial_tab_count + 1, tab_strip_model->count()); |
1386 EXPECT_EQ(initial_tab_count, tab_strip_model->active_index()); | 1384 EXPECT_EQ(initial_tab_count, tab_strip_model->active_index()); |
1387 | 1385 |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1453 ++expected_broken_tabs; | 1451 ++expected_broken_tabs; |
1454 } | 1452 } |
1455 | 1453 |
1456 CaptivePortalService* captive_portal_service = | 1454 CaptivePortalService* captive_portal_service = |
1457 CaptivePortalServiceFactory::GetForProfile(browser->profile()); | 1455 CaptivePortalServiceFactory::GetForProfile(browser->profile()); |
1458 if (delay_portal_response_until_interstital) | 1456 if (delay_portal_response_until_interstital) |
1459 RespondToProbeRequests(false); | 1457 RespondToProbeRequests(false); |
1460 | 1458 |
1461 MultiNavigationObserver navigation_observer; | 1459 MultiNavigationObserver navigation_observer; |
1462 CaptivePortalObserver portal_observer(browser->profile()); | 1460 CaptivePortalObserver portal_observer(browser->profile()); |
1463 ui_test_utils::NavigateToURLWithDisposition(browser, | 1461 ui_test_utils::NavigateToURLWithDisposition( |
1464 error_url, | 1462 browser, error_url, WindowOpenDisposition::CURRENT_TAB, |
1465 CURRENT_TAB, | 1463 ui_test_utils::BROWSER_TEST_NONE); |
1466 ui_test_utils::BROWSER_TEST_NONE); | |
1467 | 1464 |
1468 if (delay_portal_response_until_interstital) { | 1465 if (delay_portal_response_until_interstital) { |
1469 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, | 1466 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, |
1470 GetStateOfTabReloaderAt(browser, initial_active_index)); | 1467 GetStateOfTabReloaderAt(browser, initial_active_index)); |
1471 // Once the interstitial is attached, probe for captive portal. | 1468 // Once the interstitial is attached, probe for captive portal. |
1472 WaitForInterstitialAttach(tab_strip_model->GetActiveWebContents()); | 1469 WaitForInterstitialAttach(tab_strip_model->GetActiveWebContents()); |
1473 RespondToProbeRequests(true); | 1470 RespondToProbeRequests(true); |
1474 captive_portal_service->DetectCaptivePortal(); | 1471 captive_portal_service->DetectCaptivePortal(); |
1475 } | 1472 } |
1476 | 1473 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 void CaptivePortalBrowserTest::FastErrorWithInterstitialTimer( | 1509 void CaptivePortalBrowserTest::FastErrorWithInterstitialTimer( |
1513 Browser* browser, | 1510 Browser* browser, |
1514 const GURL& cert_error_url) { | 1511 const GURL& cert_error_url) { |
1515 TabStripModel* tab_strip_model = browser->tab_strip_model(); | 1512 TabStripModel* tab_strip_model = browser->tab_strip_model(); |
1516 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); | 1513 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); |
1517 | 1514 |
1518 // Disable captive portal checks indefinitely. | 1515 // Disable captive portal checks indefinitely. |
1519 RespondToProbeRequests(false); | 1516 RespondToProbeRequests(false); |
1520 | 1517 |
1521 SSLInterstitialTimerObserver interstitial_timer_observer(broken_tab_contents); | 1518 SSLInterstitialTimerObserver interstitial_timer_observer(broken_tab_contents); |
1522 ui_test_utils::NavigateToURLWithDisposition(browser, | 1519 ui_test_utils::NavigateToURLWithDisposition( |
1523 cert_error_url, | 1520 browser, cert_error_url, WindowOpenDisposition::CURRENT_TAB, |
1524 CURRENT_TAB, | 1521 ui_test_utils::BROWSER_TEST_NONE); |
1525 ui_test_utils::BROWSER_TEST_NONE); | |
1526 interstitial_timer_observer.WaitForTimerStarted(); | 1522 interstitial_timer_observer.WaitForTimerStarted(); |
1527 | 1523 |
1528 // The tab should be in loading state, waiting for the interstitial timer to | 1524 // The tab should be in loading state, waiting for the interstitial timer to |
1529 // expire or a captive portal result to arrive. Since captive portal checks | 1525 // expire or a captive portal result to arrive. Since captive portal checks |
1530 // are disabled and timer set to expire after a very long time, the tab should | 1526 // are disabled and timer set to expire after a very long time, the tab should |
1531 // hang indefinitely. | 1527 // hang indefinitely. |
1532 EXPECT_TRUE(broken_tab_contents->IsLoading()); | 1528 EXPECT_TRUE(broken_tab_contents->IsLoading()); |
1533 EXPECT_EQ(1, NumLoadingTabs()); | 1529 EXPECT_EQ(1, NumLoadingTabs()); |
1534 } | 1530 } |
1535 | 1531 |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1768 | 1764 |
1769 // Navigate the error tab to another slow loading page. Can't have | 1765 // Navigate the error tab to another slow loading page. Can't have |
1770 // ui_test_utils do the navigation because it will wait for loading tabs to | 1766 // ui_test_utils do the navigation because it will wait for loading tabs to |
1771 // stop loading before navigating. | 1767 // stop loading before navigating. |
1772 // | 1768 // |
1773 // This may result in either 0 or 1 DidStopLoading events. If there is one, | 1769 // This may result in either 0 or 1 DidStopLoading events. If there is one, |
1774 // it must happen before the CaptivePortalService sends out its test request, | 1770 // it must happen before the CaptivePortalService sends out its test request, |
1775 // so waiting for PortalObserver to see that request prevents it from | 1771 // so waiting for PortalObserver to see that request prevents it from |
1776 // confusing the MultiNavigationObservers used later. | 1772 // confusing the MultiNavigationObservers used later. |
1777 tab_strip_model->ActivateTabAt(0, true); | 1773 tab_strip_model->ActivateTabAt(0, true); |
1778 browser->OpenURL(content::OpenURLParams(timeout_url, | 1774 browser->OpenURL(content::OpenURLParams(timeout_url, content::Referrer(), |
1779 content::Referrer(), | 1775 WindowOpenDisposition::CURRENT_TAB, |
1780 CURRENT_TAB, | 1776 ui::PAGE_TRANSITION_TYPED, false)); |
1781 ui::PAGE_TRANSITION_TYPED, | |
1782 false)); | |
1783 portal_observer.WaitForResults(1); | 1777 portal_observer.WaitForResults(1); |
1784 EXPECT_FALSE(CheckPending(browser)); | 1778 EXPECT_FALSE(CheckPending(browser)); |
1785 EXPECT_EQ(1, NumLoadingTabs()); | 1779 EXPECT_EQ(1, NumLoadingTabs()); |
1786 EXPECT_EQ(CaptivePortalTabReloader::STATE_BROKEN_BY_PORTAL, | 1780 EXPECT_EQ(CaptivePortalTabReloader::STATE_BROKEN_BY_PORTAL, |
1787 GetStateOfTabReloaderAt(browser, 0)); | 1781 GetStateOfTabReloaderAt(browser, 0)); |
1788 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, | 1782 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, |
1789 GetStateOfTabReloaderAt(browser, 1)); | 1783 GetStateOfTabReloaderAt(browser, 1)); |
1790 ASSERT_TRUE(IsLoginTab(tab_strip_model->GetWebContentsAt(1))); | 1784 ASSERT_TRUE(IsLoginTab(tab_strip_model->GetWebContentsAt(1))); |
1791 | 1785 |
1792 // Need to make sure the request has been issued before logging in. | 1786 // Need to make sure the request has been issued before logging in. |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2113 | 2107 |
2114 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2108 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2115 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); | 2109 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); |
2116 | 2110 |
2117 CaptivePortalObserver portal_observer(browser()->profile()); | 2111 CaptivePortalObserver portal_observer(browser()->profile()); |
2118 FastErrorWithInterstitialTimer(browser(), cert_error_url); | 2112 FastErrorWithInterstitialTimer(browser(), cert_error_url); |
2119 | 2113 |
2120 // Page appears loading. Reloading it cancels the page load. Since the load is | 2114 // Page appears loading. Reloading it cancels the page load. Since the load is |
2121 // stopped, no cert error occurs and SSLErrorHandler isn't instantiated. | 2115 // stopped, no cert error occurs and SSLErrorHandler isn't instantiated. |
2122 MultiNavigationObserver test_navigation_observer; | 2116 MultiNavigationObserver test_navigation_observer; |
2123 chrome::Reload(browser(), CURRENT_TAB); | 2117 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
2124 test_navigation_observer.WaitForNavigations(2); | 2118 test_navigation_observer.WaitForNavigations(2); |
2125 | 2119 |
2126 // Make sure that the |ssl_error_handler| is deleted. | 2120 // Make sure that the |ssl_error_handler| is deleted. |
2127 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); | 2121 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); |
2128 | 2122 |
2129 EXPECT_FALSE(broken_tab_contents->ShowingInterstitialPage()); | 2123 EXPECT_FALSE(broken_tab_contents->ShowingInterstitialPage()); |
2130 EXPECT_FALSE(broken_tab_contents->IsLoading()); | 2124 EXPECT_FALSE(broken_tab_contents->IsLoading()); |
2131 EXPECT_EQ(0, portal_observer.num_results_received()); | 2125 EXPECT_EQ(0, portal_observer.num_results_received()); |
2132 EXPECT_EQ(2, test_navigation_observer.num_navigations()); | 2126 EXPECT_EQ(2, test_navigation_observer.num_navigations()); |
2133 EXPECT_EQ(0, NumLoadingTabs()); | 2127 EXPECT_EQ(0, NumLoadingTabs()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2172 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); | 2166 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); |
2173 | 2167 |
2174 CaptivePortalObserver portal_observer(browser()->profile()); | 2168 CaptivePortalObserver portal_observer(browser()->profile()); |
2175 FastErrorWithInterstitialTimer(browser(), cert_error_url); | 2169 FastErrorWithInterstitialTimer(browser(), cert_error_url); |
2176 | 2170 |
2177 // Page appears loading. Navigating away shouldn't result in any interstitial. | 2171 // Page appears loading. Navigating away shouldn't result in any interstitial. |
2178 // Can't use ui_test_utils::NavigateToURLWithDisposition because it waits for | 2172 // Can't use ui_test_utils::NavigateToURLWithDisposition because it waits for |
2179 // a load stop notification before starting a new navigation. | 2173 // a load stop notification before starting a new navigation. |
2180 MultiNavigationObserver test_navigation_observer; | 2174 MultiNavigationObserver test_navigation_observer; |
2181 browser()->OpenURL(content::OpenURLParams( | 2175 browser()->OpenURL(content::OpenURLParams( |
2182 URLRequestMockHTTPJob::GetMockUrl("title2.html"), | 2176 URLRequestMockHTTPJob::GetMockUrl("title2.html"), content::Referrer(), |
2183 content::Referrer(), | 2177 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
2184 CURRENT_TAB, | |
2185 ui::PAGE_TRANSITION_TYPED, false)); | |
2186 // Expect two navigations: First one for stopping the hanging page, second one | 2178 // Expect two navigations: First one for stopping the hanging page, second one |
2187 // for completing the load of the above navigation. | 2179 // for completing the load of the above navigation. |
2188 test_navigation_observer.WaitForNavigations(2); | 2180 test_navigation_observer.WaitForNavigations(2); |
2189 | 2181 |
2190 // Make sure that the |ssl_error_handler| is deleted. | 2182 // Make sure that the |ssl_error_handler| is deleted. |
2191 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); | 2183 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); |
2192 | 2184 |
2193 EXPECT_FALSE(broken_tab_contents->ShowingInterstitialPage()); | 2185 EXPECT_FALSE(broken_tab_contents->ShowingInterstitialPage()); |
2194 EXPECT_FALSE(broken_tab_contents->IsLoading()); | 2186 EXPECT_FALSE(broken_tab_contents->IsLoading()); |
2195 EXPECT_EQ(0, portal_observer.num_results_received()); | 2187 EXPECT_EQ(0, portal_observer.num_results_received()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2242 FastErrorWithInterstitialTimer(browser(), cert_error_url); | 2234 FastErrorWithInterstitialTimer(browser(), cert_error_url); |
2243 // Page appears loading. Turn on response to probe request again, and navigate | 2235 // Page appears loading. Turn on response to probe request again, and navigate |
2244 // to the same page. This should result in a cert error which should | 2236 // to the same page. This should result in a cert error which should |
2245 // instantiate an |SSLErrorHandler| and end up showing an SSL interstitial. | 2237 // instantiate an |SSLErrorHandler| and end up showing an SSL interstitial. |
2246 RespondToProbeRequests(true); | 2238 RespondToProbeRequests(true); |
2247 // Can't have ui_test_utils do the navigation because it will wait for loading | 2239 // Can't have ui_test_utils do the navigation because it will wait for loading |
2248 // tabs to stop loading before navigating. | 2240 // tabs to stop loading before navigating. |
2249 CaptivePortalObserver portal_observer(browser()->profile()); | 2241 CaptivePortalObserver portal_observer(browser()->profile()); |
2250 MultiNavigationObserver test_navigation_observer; | 2242 MultiNavigationObserver test_navigation_observer; |
2251 browser()->OpenURL(content::OpenURLParams(cert_error_url, content::Referrer(), | 2243 browser()->OpenURL(content::OpenURLParams(cert_error_url, content::Referrer(), |
2252 CURRENT_TAB, | 2244 WindowOpenDisposition::CURRENT_TAB, |
2253 ui::PAGE_TRANSITION_TYPED, false)); | 2245 ui::PAGE_TRANSITION_TYPED, false)); |
2254 // Expect two navigations: First one for stopping the hanging page, second one | 2246 // Expect two navigations: First one for stopping the hanging page, second one |
2255 // for completing the load of the above navigation. | 2247 // for completing the load of the above navigation. |
2256 test_navigation_observer.WaitForNavigations(2); | 2248 test_navigation_observer.WaitForNavigations(2); |
2257 // Should end up with an SSL interstitial. | 2249 // Should end up with an SSL interstitial. |
2258 WaitForInterstitialAttach(broken_tab_contents); | 2250 WaitForInterstitialAttach(broken_tab_contents); |
2259 ASSERT_TRUE(broken_tab_contents->ShowingInterstitialPage()); | 2251 ASSERT_TRUE(broken_tab_contents->ShowingInterstitialPage()); |
2260 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2252 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2261 broken_tab_contents->GetInterstitialPage() | 2253 broken_tab_contents->GetInterstitialPage() |
2262 ->GetDelegateForTesting() | 2254 ->GetDelegateForTesting() |
(...skipping 28 matching lines...) Expand all Loading... |
2291 FastErrorWithInterstitialTimer(browser(), cert_error_url); | 2283 FastErrorWithInterstitialTimer(browser(), cert_error_url); |
2292 // Page appears loading. Turn on response to probe request again, and navigate | 2284 // Page appears loading. Turn on response to probe request again, and navigate |
2293 // to the same page. This should result in a cert error which should | 2285 // to the same page. This should result in a cert error which should |
2294 // instantiate an |SSLErrorHandler| and end up showing an SSL. | 2286 // instantiate an |SSLErrorHandler| and end up showing an SSL. |
2295 RespondToProbeRequests(true); | 2287 RespondToProbeRequests(true); |
2296 // Can't have ui_test_utils do the navigation because it will wait for loading | 2288 // Can't have ui_test_utils do the navigation because it will wait for loading |
2297 // tabs to stop loading before navigating. | 2289 // tabs to stop loading before navigating. |
2298 CaptivePortalObserver portal_observer(browser()->profile()); | 2290 CaptivePortalObserver portal_observer(browser()->profile()); |
2299 MultiNavigationObserver test_navigation_observer; | 2291 MultiNavigationObserver test_navigation_observer; |
2300 browser()->OpenURL(content::OpenURLParams(cert_error_url, content::Referrer(), | 2292 browser()->OpenURL(content::OpenURLParams(cert_error_url, content::Referrer(), |
2301 CURRENT_TAB, | 2293 WindowOpenDisposition::CURRENT_TAB, |
2302 ui::PAGE_TRANSITION_TYPED, false)); | 2294 ui::PAGE_TRANSITION_TYPED, false)); |
2303 // Expect three navigations: | 2295 // Expect three navigations: |
2304 // 1- For stopping the hanging page. | 2296 // 1- For stopping the hanging page. |
2305 // 2- For completing the load of the above navigation. | 2297 // 2- For completing the load of the above navigation. |
2306 // 3- For completing the load of the login tab. | 2298 // 3- For completing the load of the login tab. |
2307 test_navigation_observer.WaitForNavigations(3); | 2299 test_navigation_observer.WaitForNavigations(3); |
2308 // Should end up with a captive portal interstitial and a new login tab. | 2300 // Should end up with a captive portal interstitial and a new login tab. |
2309 WaitForInterstitialAttach(broken_tab_contents); | 2301 WaitForInterstitialAttach(broken_tab_contents); |
2310 ASSERT_TRUE(broken_tab_contents->ShowingInterstitialPage()); | 2302 ASSERT_TRUE(broken_tab_contents->ShowingInterstitialPage()); |
2311 EXPECT_EQ(CaptivePortalBlockingPage::kTypeForTesting, | 2303 EXPECT_EQ(CaptivePortalBlockingPage::kTypeForTesting, |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2406 // tabs only timeout after logging in. | 2398 // tabs only timeout after logging in. |
2407 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, TwoBrokenTabs) { | 2399 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, TwoBrokenTabs) { |
2408 SlowLoadBehindCaptivePortal(browser(), true); | 2400 SlowLoadBehindCaptivePortal(browser(), true); |
2409 | 2401 |
2410 // Can't set the TabReloader HTTPS timeout on a new tab without doing some | 2402 // Can't set the TabReloader HTTPS timeout on a new tab without doing some |
2411 // acrobatics, so open a new tab at a normal page, and then navigate it to a | 2403 // acrobatics, so open a new tab at a normal page, and then navigate it to a |
2412 // timeout. | 2404 // timeout. |
2413 MultiNavigationObserver navigation_observer; | 2405 MultiNavigationObserver navigation_observer; |
2414 CaptivePortalObserver portal_observer(browser()->profile()); | 2406 CaptivePortalObserver portal_observer(browser()->profile()); |
2415 ui_test_utils::NavigateToURLWithDisposition( | 2407 ui_test_utils::NavigateToURLWithDisposition( |
2416 browser(), | 2408 browser(), URLRequestMockHTTPJob::GetMockUrl("title2.html"), |
2417 URLRequestMockHTTPJob::GetMockUrl("title2.html"), | 2409 WindowOpenDisposition::NEW_FOREGROUND_TAB, |
2418 NEW_FOREGROUND_TAB, | |
2419 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2410 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
2420 | 2411 |
2421 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2412 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2422 ASSERT_EQ(3, tab_strip_model->count()); | 2413 ASSERT_EQ(3, tab_strip_model->count()); |
2423 EXPECT_FALSE(CheckPending(browser())); | 2414 EXPECT_FALSE(CheckPending(browser())); |
2424 EXPECT_EQ(0, portal_observer.num_results_received()); | 2415 EXPECT_EQ(0, portal_observer.num_results_received()); |
2425 EXPECT_EQ(1, NumLoadingTabs()); | 2416 EXPECT_EQ(1, NumLoadingTabs()); |
2426 EXPECT_EQ(1, navigation_observer.num_navigations()); | 2417 EXPECT_EQ(1, navigation_observer.num_navigations()); |
2427 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( | 2418 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( |
2428 tab_strip_model->GetWebContentsAt(2))); | 2419 tab_strip_model->GetWebContentsAt(2))); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2539 // Go to the error page. | 2530 // Go to the error page. |
2540 SlowLoadBehindCaptivePortal(browser(), true); | 2531 SlowLoadBehindCaptivePortal(browser(), true); |
2541 FailLoadsWithoutLogin(browser(), 1); | 2532 FailLoadsWithoutLogin(browser(), 1); |
2542 | 2533 |
2543 CaptivePortalObserver portal_observer(browser()->profile()); | 2534 CaptivePortalObserver portal_observer(browser()->profile()); |
2544 MultiNavigationObserver navigation_observer; | 2535 MultiNavigationObserver navigation_observer; |
2545 | 2536 |
2546 // Activate the error page tab again and go back. | 2537 // Activate the error page tab again and go back. |
2547 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2538 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2548 tab_strip_model->ActivateTabAt(0, true); | 2539 tab_strip_model->ActivateTabAt(0, true); |
2549 chrome::GoBack(browser(), CURRENT_TAB); | 2540 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
2550 navigation_observer.WaitForNavigations(1); | 2541 navigation_observer.WaitForNavigations(1); |
2551 | 2542 |
2552 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( | 2543 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( |
2553 tab_strip_model->GetWebContentsAt(0))); | 2544 tab_strip_model->GetWebContentsAt(0))); |
2554 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, | 2545 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, |
2555 GetStateOfTabReloaderAt(browser(), 0)); | 2546 GetStateOfTabReloaderAt(browser(), 0)); |
2556 EXPECT_EQ(0, portal_observer.num_results_received()); | 2547 EXPECT_EQ(0, portal_observer.num_results_received()); |
2557 } | 2548 } |
2558 | 2549 |
2559 // Checks that navigating back to a timeout triggers captive portal detection. | 2550 // Checks that navigating back to a timeout triggers captive portal detection. |
(...skipping 14 matching lines...) Expand all Loading... |
2574 | 2565 |
2575 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2566 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2576 CaptivePortalTabReloader* tab_reloader = | 2567 CaptivePortalTabReloader* tab_reloader = |
2577 GetTabReloader(tab_strip_model->GetActiveWebContents()); | 2568 GetTabReloader(tab_strip_model->GetActiveWebContents()); |
2578 ASSERT_TRUE(tab_reloader); | 2569 ASSERT_TRUE(tab_reloader); |
2579 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); | 2570 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); |
2580 | 2571 |
2581 // Go to the error page. | 2572 // Go to the error page. |
2582 MultiNavigationObserver navigation_observer; | 2573 MultiNavigationObserver navigation_observer; |
2583 CaptivePortalObserver portal_observer(browser()->profile()); | 2574 CaptivePortalObserver portal_observer(browser()->profile()); |
2584 chrome::GoBack(browser(), CURRENT_TAB); | 2575 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
2585 | 2576 |
2586 // Wait for the check triggered by the broken tab and for the login tab to | 2577 // Wait for the check triggered by the broken tab and for the login tab to |
2587 // stop loading. | 2578 // stop loading. |
2588 portal_observer.WaitForResults(1); | 2579 portal_observer.WaitForResults(1); |
2589 navigation_observer.WaitForNavigations(1); | 2580 navigation_observer.WaitForNavigations(1); |
2590 // Make sure the request has been issued. | 2581 // Make sure the request has been issued. |
2591 URLRequestTimeoutOnDemandJob::WaitForJobs(1); | 2582 URLRequestTimeoutOnDemandJob::WaitForJobs(1); |
2592 | 2583 |
2593 EXPECT_EQ(1, portal_observer.num_results_received()); | 2584 EXPECT_EQ(1, portal_observer.num_results_received()); |
2594 ASSERT_FALSE(CheckPending(browser())); | 2585 ASSERT_FALSE(CheckPending(browser())); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2693 | 2684 |
2694 CaptivePortalObserver portal_observer(browser()->profile()); | 2685 CaptivePortalObserver portal_observer(browser()->profile()); |
2695 MultiNavigationObserver navigation_observer; | 2686 MultiNavigationObserver navigation_observer; |
2696 | 2687 |
2697 // Navigate the tab in the inactive browser to an SSL timeout. Have to use | 2688 // Navigate the tab in the inactive browser to an SSL timeout. Have to use |
2698 // chrome::NavigateParams and NEW_BACKGROUND_TAB to avoid activating the | 2689 // chrome::NavigateParams and NEW_BACKGROUND_TAB to avoid activating the |
2699 // window. | 2690 // window. |
2700 chrome::NavigateParams params(inactive_browser, | 2691 chrome::NavigateParams params(inactive_browser, |
2701 GURL(kMockHttpsQuickTimeoutUrl), | 2692 GURL(kMockHttpsQuickTimeoutUrl), |
2702 ui::PAGE_TRANSITION_TYPED); | 2693 ui::PAGE_TRANSITION_TYPED); |
2703 params.disposition = NEW_BACKGROUND_TAB; | 2694 params.disposition = WindowOpenDisposition::NEW_BACKGROUND_TAB; |
2704 params.window_action = chrome::NavigateParams::NO_ACTION; | 2695 params.window_action = chrome::NavigateParams::NO_ACTION; |
2705 ui_test_utils::NavigateToURL(¶ms); | 2696 ui_test_utils::NavigateToURL(¶ms); |
2706 navigation_observer.WaitForNavigations(2); | 2697 navigation_observer.WaitForNavigations(2); |
2707 | 2698 |
2708 // Make sure the active window hasn't changed, and its new tab is | 2699 // Make sure the active window hasn't changed, and its new tab is |
2709 // active. | 2700 // active. |
2710 ASSERT_EQ(active_browser, | 2701 ASSERT_EQ(active_browser, |
2711 chrome::FindTabbedBrowser(browser()->profile(), true)); | 2702 chrome::FindTabbedBrowser(browser()->profile(), true)); |
2712 ASSERT_EQ(1, active_browser->tab_strip_model()->active_index()); | 2703 ASSERT_EQ(1, active_browser->tab_strip_model()->active_index()); |
2713 | 2704 |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2837 | 2828 |
2838 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2829 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2839 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2830 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2840 | 2831 |
2841 WaitForInterstitialAttach(broken_tab_contents); | 2832 WaitForInterstitialAttach(broken_tab_contents); |
2842 portal_observer.WaitForResults(1); | 2833 portal_observer.WaitForResults(1); |
2843 | 2834 |
2844 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2835 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2845 GetInterstitialType(broken_tab_contents)); | 2836 GetInterstitialType(broken_tab_contents)); |
2846 } | 2837 } |
OLD | NEW |