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 <set> | 6 #include <set> |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/base_switches.h" | 10 #include "base/base_switches.h" |
(...skipping 2173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2184 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); | 2184 WebContents* broken_tab_contents = tab_strip_model->GetActiveWebContents(); |
2185 | 2185 |
2186 CaptivePortalObserver portal_observer(browser()->profile()); | 2186 CaptivePortalObserver portal_observer(browser()->profile()); |
2187 FastErrorWithInterstitialTimer(browser(), cert_error_url); | 2187 FastErrorWithInterstitialTimer(browser(), cert_error_url); |
2188 | 2188 |
2189 // Page appears loading. Navigating away shouldn't result in any interstitial. | 2189 // Page appears loading. Navigating away shouldn't result in any interstitial. |
2190 // Can't use ui_test_utils::NavigateToURLWithDisposition because it waits for | 2190 // Can't use ui_test_utils::NavigateToURLWithDisposition because it waits for |
2191 // a load stop notification before starting a new navigation. | 2191 // a load stop notification before starting a new navigation. |
2192 MultiNavigationObserver test_navigation_observer; | 2192 MultiNavigationObserver test_navigation_observer; |
2193 browser()->OpenURL(content::OpenURLParams( | 2193 browser()->OpenURL(content::OpenURLParams( |
2194 URLRequestMockHTTPJob::GetMockUrl( | 2194 URLRequestMockHTTPJob::GetMockUrl("title2.html"), |
2195 base::FilePath(FILE_PATH_LITERAL("title2.html"))), | |
2196 content::Referrer(), | 2195 content::Referrer(), |
2197 CURRENT_TAB, | 2196 CURRENT_TAB, |
2198 ui::PAGE_TRANSITION_TYPED, false)); | 2197 ui::PAGE_TRANSITION_TYPED, false)); |
2199 // Expect two navigations: First one for stopping the hanging page, second one | 2198 // Expect two navigations: First one for stopping the hanging page, second one |
2200 // for completing the load of the above navigation. | 2199 // for completing the load of the above navigation. |
2201 test_navigation_observer.WaitForNavigations(2); | 2200 test_navigation_observer.WaitForNavigations(2); |
2202 | 2201 |
2203 // Make sure that the |ssl_error_handler| is deleted. | 2202 // Make sure that the |ssl_error_handler| is deleted. |
2204 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); | 2203 EXPECT_TRUE(nullptr == SSLErrorHandler::FromWebContents(broken_tab_contents)); |
2205 | 2204 |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2429 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, TwoBrokenTabs) { | 2428 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, TwoBrokenTabs) { |
2430 SlowLoadBehindCaptivePortal(browser(), true); | 2429 SlowLoadBehindCaptivePortal(browser(), true); |
2431 | 2430 |
2432 // Can't set the TabReloader HTTPS timeout on a new tab without doing some | 2431 // Can't set the TabReloader HTTPS timeout on a new tab without doing some |
2433 // acrobatics, so open a new tab at a normal page, and then navigate it to a | 2432 // acrobatics, so open a new tab at a normal page, and then navigate it to a |
2434 // timeout. | 2433 // timeout. |
2435 MultiNavigationObserver navigation_observer; | 2434 MultiNavigationObserver navigation_observer; |
2436 CaptivePortalObserver portal_observer(browser()->profile()); | 2435 CaptivePortalObserver portal_observer(browser()->profile()); |
2437 ui_test_utils::NavigateToURLWithDisposition( | 2436 ui_test_utils::NavigateToURLWithDisposition( |
2438 browser(), | 2437 browser(), |
2439 URLRequestMockHTTPJob::GetMockUrl( | 2438 URLRequestMockHTTPJob::GetMockUrl("title2.html"), |
2440 base::FilePath(FILE_PATH_LITERAL("title2.html"))), | |
2441 NEW_FOREGROUND_TAB, | 2439 NEW_FOREGROUND_TAB, |
2442 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 2440 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
2443 | 2441 |
2444 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2442 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2445 ASSERT_EQ(3, tab_strip_model->count()); | 2443 ASSERT_EQ(3, tab_strip_model->count()); |
2446 EXPECT_FALSE(CheckPending(browser())); | 2444 EXPECT_FALSE(CheckPending(browser())); |
2447 EXPECT_EQ(0, portal_observer.num_results_received()); | 2445 EXPECT_EQ(0, portal_observer.num_results_received()); |
2448 EXPECT_EQ(1, NumLoadingTabs()); | 2446 EXPECT_EQ(1, NumLoadingTabs()); |
2449 EXPECT_EQ(1, navigation_observer.num_navigations()); | 2447 EXPECT_EQ(1, navigation_observer.num_navigations()); |
2450 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( | 2448 EXPECT_EQ(1, navigation_observer.NumNavigationsForTab( |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2495 // logging in. | 2493 // logging in. |
2496 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, NavigateBrokenTab) { | 2494 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, NavigateBrokenTab) { |
2497 // Go to the error page. | 2495 // Go to the error page. |
2498 SlowLoadBehindCaptivePortal(browser(), true); | 2496 SlowLoadBehindCaptivePortal(browser(), true); |
2499 FailLoadsWithoutLogin(browser(), 1); | 2497 FailLoadsWithoutLogin(browser(), 1); |
2500 | 2498 |
2501 // Navigate the error tab to a non-error page. | 2499 // Navigate the error tab to a non-error page. |
2502 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2500 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2503 tab_strip_model->ActivateTabAt(0, true); | 2501 tab_strip_model->ActivateTabAt(0, true); |
2504 ui_test_utils::NavigateToURL( | 2502 ui_test_utils::NavigateToURL( |
2505 browser(), URLRequestMockHTTPJob::GetMockUrl( | 2503 browser(), URLRequestMockHTTPJob::GetMockUrl("title2.html")); |
2506 base::FilePath(FILE_PATH_LITERAL("title2.html")))); | |
2507 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, | 2504 EXPECT_EQ(CaptivePortalTabReloader::STATE_NONE, |
2508 GetStateOfTabReloaderAt(browser(), 0)); | 2505 GetStateOfTabReloaderAt(browser(), 0)); |
2509 | 2506 |
2510 // Simulate logging in. | 2507 // Simulate logging in. |
2511 tab_strip_model->ActivateTabAt(1, true); | 2508 tab_strip_model->ActivateTabAt(1, true); |
2512 Login(browser(), 0, 0); | 2509 Login(browser(), 0, 0); |
2513 } | 2510 } |
2514 | 2511 |
2515 // Checks that captive portal detection triggers correctly when a same-site | 2512 // Checks that captive portal detection triggers correctly when a same-site |
2516 // navigation is cancelled by a navigation to the same site. | 2513 // navigation is cancelled by a navigation to the same site. |
(...skipping 25 matching lines...) Expand all Loading... |
2542 GURL(kMockHttpsUrl), | 2539 GURL(kMockHttpsUrl), |
2543 GURL(kMockHttpsUrl2)); | 2540 GURL(kMockHttpsUrl2)); |
2544 } | 2541 } |
2545 | 2542 |
2546 // Checks that captive portal detection triggers correctly when a cross-site | 2543 // Checks that captive portal detection triggers correctly when a cross-site |
2547 // navigation is cancelled by a navigation to yet another site. | 2544 // navigation is cancelled by a navigation to yet another site. |
2548 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, | 2545 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, |
2549 NavigateLoadingTabToTimeoutThreeSites) { | 2546 NavigateLoadingTabToTimeoutThreeSites) { |
2550 RunNavigateLoadingTabToTimeoutTest( | 2547 RunNavigateLoadingTabToTimeoutTest( |
2551 browser(), | 2548 browser(), |
2552 URLRequestMockHTTPJob::GetMockUrl( | 2549 URLRequestMockHTTPJob::GetMockUrl("title.html"), |
2553 base::FilePath(FILE_PATH_LITERAL("title.html"))), | |
2554 GURL(kMockHttpsUrl), | 2550 GURL(kMockHttpsUrl), |
2555 GURL(kMockHttpsUrl2)); | 2551 GURL(kMockHttpsUrl2)); |
2556 } | 2552 } |
2557 | 2553 |
2558 // Checks that navigating a timed out tab back clears its state. | 2554 // Checks that navigating a timed out tab back clears its state. |
2559 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBack) { | 2555 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBack) { |
2560 // Navigate to a working page. | 2556 // Navigate to a working page. |
2561 ui_test_utils::NavigateToURL( | 2557 ui_test_utils::NavigateToURL( |
2562 browser(), | 2558 browser(), URLRequestMockHTTPJob::GetMockUrl("title2.html")); |
2563 URLRequestMockHTTPJob::GetMockUrl( | |
2564 base::FilePath(FILE_PATH_LITERAL("title2.html")))); | |
2565 | 2559 |
2566 // Go to the error page. | 2560 // Go to the error page. |
2567 SlowLoadBehindCaptivePortal(browser(), true); | 2561 SlowLoadBehindCaptivePortal(browser(), true); |
2568 FailLoadsWithoutLogin(browser(), 1); | 2562 FailLoadsWithoutLogin(browser(), 1); |
2569 | 2563 |
2570 CaptivePortalObserver portal_observer(browser()->profile()); | 2564 CaptivePortalObserver portal_observer(browser()->profile()); |
2571 MultiNavigationObserver navigation_observer; | 2565 MultiNavigationObserver navigation_observer; |
2572 | 2566 |
2573 // Activate the error page tab again and go back. | 2567 // Activate the error page tab again and go back. |
2574 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2568 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
(...skipping 11 matching lines...) Expand all Loading... |
2586 // Checks that navigating back to a timeout triggers captive portal detection. | 2580 // Checks that navigating back to a timeout triggers captive portal detection. |
2587 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBackToTimeout) { | 2581 IN_PROC_BROWSER_TEST_F(CaptivePortalBrowserTest, GoBackToTimeout) { |
2588 // Disable captive portal detection so the first navigation doesn't open a | 2582 // Disable captive portal detection so the first navigation doesn't open a |
2589 // login tab. | 2583 // login tab. |
2590 EnableCaptivePortalDetection(browser()->profile(), false); | 2584 EnableCaptivePortalDetection(browser()->profile(), false); |
2591 | 2585 |
2592 SlowLoadNoCaptivePortal(browser(), captive_portal::RESULT_INTERNET_CONNECTED); | 2586 SlowLoadNoCaptivePortal(browser(), captive_portal::RESULT_INTERNET_CONNECTED); |
2593 | 2587 |
2594 // Navigate to a working page. | 2588 // Navigate to a working page. |
2595 ui_test_utils::NavigateToURL( | 2589 ui_test_utils::NavigateToURL( |
2596 browser(), URLRequestMockHTTPJob::GetMockUrl( | 2590 browser(), URLRequestMockHTTPJob::GetMockUrl("title2.html")); |
2597 base::FilePath(FILE_PATH_LITERAL("title2.html")))); | |
2598 ASSERT_EQ(CaptivePortalTabReloader::STATE_NONE, | 2591 ASSERT_EQ(CaptivePortalTabReloader::STATE_NONE, |
2599 GetStateOfTabReloaderAt(browser(), 0)); | 2592 GetStateOfTabReloaderAt(browser(), 0)); |
2600 | 2593 |
2601 EnableCaptivePortalDetection(browser()->profile(), true); | 2594 EnableCaptivePortalDetection(browser()->profile(), true); |
2602 | 2595 |
2603 TabStripModel* tab_strip_model = browser()->tab_strip_model(); | 2596 TabStripModel* tab_strip_model = browser()->tab_strip_model(); |
2604 CaptivePortalTabReloader* tab_reloader = | 2597 CaptivePortalTabReloader* tab_reloader = |
2605 GetTabReloader(tab_strip_model->GetActiveWebContents()); | 2598 GetTabReloader(tab_strip_model->GetActiveWebContents()); |
2606 ASSERT_TRUE(tab_reloader); | 2599 ASSERT_TRUE(tab_reloader); |
2607 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); | 2600 SetSlowSSLLoadTime(tab_reloader, base::TimeDelta()); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2871 | 2864 |
2872 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, | 2865 EXPECT_EQ(CaptivePortalTabReloader::STATE_NEEDS_RELOAD, |
2873 GetStateOfTabReloaderAt(browser(), broken_tab_index)); | 2866 GetStateOfTabReloaderAt(browser(), broken_tab_index)); |
2874 | 2867 |
2875 WaitForInterstitialAttach(broken_tab_contents); | 2868 WaitForInterstitialAttach(broken_tab_contents); |
2876 portal_observer.WaitForResults(1); | 2869 portal_observer.WaitForResults(1); |
2877 | 2870 |
2878 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, | 2871 EXPECT_EQ(SSLBlockingPage::kTypeForTesting, |
2879 GetInterstitialType(broken_tab_contents)); | 2872 GetInterstitialType(broken_tab_contents)); |
2880 } | 2873 } |
OLD | NEW |