| 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 1002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1013 | 1013 |
| 1014 // Now go to a bad HTTPS page that shows an interstitial. | 1014 // Now go to a bad HTTPS page that shows an interstitial. |
| 1015 ui_test_utils::NavigateToURL( | 1015 ui_test_utils::NavigateToURL( |
| 1016 browser(), https_server_expired_.GetURL("/ssl/google.html")); | 1016 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
| 1017 CheckAuthenticationBrokenState( | 1017 CheckAuthenticationBrokenState( |
| 1018 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); | 1018 tab, net::CERT_STATUS_DATE_INVALID, AuthState::SHOWING_INTERSTITIAL); |
| 1019 | 1019 |
| 1020 ProvisionalLoadWaiter load_failed_observer(tab); | 1020 ProvisionalLoadWaiter load_failed_observer(tab); |
| 1021 | 1021 |
| 1022 // Simulate user clicking on back button (crbug.com/39248). | 1022 // Simulate user clicking on back button (crbug.com/39248). |
| 1023 chrome::GoBack(browser(), CURRENT_TAB); | 1023 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 1024 | 1024 |
| 1025 // Wait until we hear the load failure, and make sure we haven't changed | 1025 // Wait until we hear the load failure, and make sure we haven't changed |
| 1026 // the previous RFH. Prevents regression of http://crbug.com/82667. | 1026 // the previous RFH. Prevents regression of http://crbug.com/82667. |
| 1027 load_failed_observer.Wait(); | 1027 load_failed_observer.Wait(); |
| 1028 EXPECT_EQ(rfh, tab->GetMainFrame()); | 1028 EXPECT_EQ(rfh, tab->GetMainFrame()); |
| 1029 | 1029 |
| 1030 // We should be back at the original good page. | 1030 // We should be back at the original good page. |
| 1031 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> | 1031 EXPECT_FALSE(browser()->tab_strip_model()->GetActiveWebContents()-> |
| 1032 GetInterstitialPage()); | 1032 GetInterstitialPage()); |
| 1033 CheckUnauthenticatedState(tab, AuthState::NONE); | 1033 CheckUnauthenticatedState(tab, AuthState::NONE); |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1441 | 1441 |
| 1442 // There should still be an interstitial at this point. Press the | 1442 // There should still be an interstitial at this point. Press the |
| 1443 // back button on the browser. Note that this doesn't wait for a | 1443 // back button on the browser. Note that this doesn't wait for a |
| 1444 // NAV_ENTRY_COMMITTED notification because going back with an | 1444 // NAV_ENTRY_COMMITTED notification because going back with an |
| 1445 // active interstitial simply hides the interstitial. | 1445 // active interstitial simply hides the interstitial. |
| 1446 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); | 1446 ASSERT_TRUE(tab->GetInterstitialPage() != NULL); |
| 1447 ASSERT_EQ( | 1447 ASSERT_EQ( |
| 1448 SSLBlockingPage::kTypeForTesting, | 1448 SSLBlockingPage::kTypeForTesting, |
| 1449 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting()); | 1449 tab->GetInterstitialPage()->GetDelegateForTesting()->GetTypeForTesting()); |
| 1450 EXPECT_TRUE(chrome::CanGoBack(browser())); | 1450 EXPECT_TRUE(chrome::CanGoBack(browser())); |
| 1451 chrome::GoBack(browser(), CURRENT_TAB); | 1451 chrome::GoBack(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 1452 | 1452 |
| 1453 dangerous_download_observer.WaitForFinished(); | 1453 dangerous_download_observer.WaitForFinished(); |
| 1454 } | 1454 } |
| 1455 | 1455 |
| 1456 // | 1456 // |
| 1457 // Insecure content | 1457 // Insecure content |
| 1458 // | 1458 // |
| 1459 | 1459 |
| 1460 #if defined(OS_WIN) | 1460 #if defined(OS_WIN) |
| 1461 // http://crbug.com/152940 Flaky on win. | 1461 // http://crbug.com/152940 Flaky on win. |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1727 CheckAuthenticatedState(tab1, AuthState::NONE); | 1727 CheckAuthenticatedState(tab1, AuthState::NONE); |
| 1728 | 1728 |
| 1729 // Create a new tab. | 1729 // Create a new tab. |
| 1730 std::string replacement_path; | 1730 std::string replacement_path; |
| 1731 GetFilePathWithHostAndPortReplacement( | 1731 GetFilePathWithHostAndPortReplacement( |
| 1732 "/ssl/page_displays_insecure_content.html", | 1732 "/ssl/page_displays_insecure_content.html", |
| 1733 embedded_test_server()->host_port_pair(), &replacement_path); | 1733 embedded_test_server()->host_port_pair(), &replacement_path); |
| 1734 | 1734 |
| 1735 GURL url = https_server_.GetURL(replacement_path); | 1735 GURL url = https_server_.GetURL(replacement_path); |
| 1736 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1736 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
| 1737 params.disposition = NEW_FOREGROUND_TAB; | 1737 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 1738 params.tabstrip_index = 0; | 1738 params.tabstrip_index = 0; |
| 1739 params.source_contents = tab1; | 1739 params.source_contents = tab1; |
| 1740 content::WindowedNotificationObserver observer( | 1740 content::WindowedNotificationObserver observer( |
| 1741 content::NOTIFICATION_LOAD_STOP, | 1741 content::NOTIFICATION_LOAD_STOP, |
| 1742 content::NotificationService::AllSources()); | 1742 content::NotificationService::AllSources()); |
| 1743 chrome::Navigate(¶ms); | 1743 chrome::Navigate(¶ms); |
| 1744 WebContents* tab2 = params.target_contents; | 1744 WebContents* tab2 = params.target_contents; |
| 1745 observer.Wait(); | 1745 observer.Wait(); |
| 1746 | 1746 |
| 1747 // The new tab has insecure content. | 1747 // The new tab has insecure content. |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1769 std::string replacement_path; | 1769 std::string replacement_path; |
| 1770 GetFilePathWithHostAndPortReplacement( | 1770 GetFilePathWithHostAndPortReplacement( |
| 1771 "/ssl/page_runs_insecure_content.html", | 1771 "/ssl/page_runs_insecure_content.html", |
| 1772 embedded_test_server()->host_port_pair(), &replacement_path); | 1772 embedded_test_server()->host_port_pair(), &replacement_path); |
| 1773 | 1773 |
| 1774 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB | 1774 // Create a new tab in the same process. Using a NEW_FOREGROUND_TAB |
| 1775 // disposition won't usually stay in the same process, but this works | 1775 // disposition won't usually stay in the same process, but this works |
| 1776 // because we are using process-per-site in SetUpCommandLine. | 1776 // because we are using process-per-site in SetUpCommandLine. |
| 1777 GURL url = https_server_.GetURL(replacement_path); | 1777 GURL url = https_server_.GetURL(replacement_path); |
| 1778 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); | 1778 chrome::NavigateParams params(browser(), url, ui::PAGE_TRANSITION_TYPED); |
| 1779 params.disposition = NEW_FOREGROUND_TAB; | 1779 params.disposition = WindowOpenDisposition::NEW_FOREGROUND_TAB; |
| 1780 params.source_contents = tab1; | 1780 params.source_contents = tab1; |
| 1781 content::WindowedNotificationObserver observer( | 1781 content::WindowedNotificationObserver observer( |
| 1782 content::NOTIFICATION_LOAD_STOP, | 1782 content::NOTIFICATION_LOAD_STOP, |
| 1783 content::NotificationService::AllSources()); | 1783 content::NotificationService::AllSources()); |
| 1784 chrome::Navigate(¶ms); | 1784 chrome::Navigate(¶ms); |
| 1785 WebContents* tab2 = params.target_contents; | 1785 WebContents* tab2 = params.target_contents; |
| 1786 observer.Wait(); | 1786 observer.Wait(); |
| 1787 | 1787 |
| 1788 // Both tabs should have the same process. | 1788 // Both tabs should have the same process. |
| 1789 EXPECT_EQ(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); | 1789 EXPECT_EQ(tab1->GetRenderProcessHost(), tab2->GetRenderProcessHost()); |
| (...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2895 https_server_url.ReplaceComponents(replacements); | 2895 https_server_url.ReplaceComponents(replacements); |
| 2896 | 2896 |
| 2897 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2897 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2898 CommonNameMismatchHandler::set_state_for_testing( | 2898 CommonNameMismatchHandler::set_state_for_testing( |
| 2899 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2899 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 2900 // Set delay long enough so that the page appears loading. | 2900 // Set delay long enough so that the page appears loading. |
| 2901 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2901 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 2902 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 2902 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 2903 | 2903 |
| 2904 ui_test_utils::NavigateToURLWithDisposition( | 2904 ui_test_utils::NavigateToURLWithDisposition( |
| 2905 browser(), https_server_mismatched_url, CURRENT_TAB, | 2905 browser(), https_server_mismatched_url, |
| 2906 ui_test_utils::BROWSER_TEST_NONE); | 2906 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 2907 interstitial_timer_observer.WaitForTimerStarted(); | 2907 interstitial_timer_observer.WaitForTimerStarted(); |
| 2908 | 2908 |
| 2909 EXPECT_TRUE(contents->IsLoading()); | 2909 EXPECT_TRUE(contents->IsLoading()); |
| 2910 content::WindowedNotificationObserver observer( | 2910 content::WindowedNotificationObserver observer( |
| 2911 content::NOTIFICATION_LOAD_STOP, | 2911 content::NOTIFICATION_LOAD_STOP, |
| 2912 content::NotificationService::AllSources()); | 2912 content::NotificationService::AllSources()); |
| 2913 contents->Stop(); | 2913 contents->Stop(); |
| 2914 observer.Wait(); | 2914 observer.Wait(); |
| 2915 | 2915 |
| 2916 SSLErrorHandler* ssl_error_handler = | 2916 SSLErrorHandler* ssl_error_handler = |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2963 https_server_url.ReplaceComponents(replacements); | 2963 https_server_url.ReplaceComponents(replacements); |
| 2964 | 2964 |
| 2965 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 2965 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2966 CommonNameMismatchHandler::set_state_for_testing( | 2966 CommonNameMismatchHandler::set_state_for_testing( |
| 2967 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 2967 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 2968 // Set delay long enough so that the page appears loading. | 2968 // Set delay long enough so that the page appears loading. |
| 2969 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 2969 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 2970 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 2970 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 2971 | 2971 |
| 2972 ui_test_utils::NavigateToURLWithDisposition( | 2972 ui_test_utils::NavigateToURLWithDisposition( |
| 2973 browser(), https_server_mismatched_url, CURRENT_TAB, | 2973 browser(), https_server_mismatched_url, |
| 2974 ui_test_utils::BROWSER_TEST_NONE); | 2974 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 2975 interstitial_timer_observer.WaitForTimerStarted(); | 2975 interstitial_timer_observer.WaitForTimerStarted(); |
| 2976 | 2976 |
| 2977 EXPECT_TRUE(contents->IsLoading()); | 2977 EXPECT_TRUE(contents->IsLoading()); |
| 2978 content::TestNavigationObserver observer(contents, 1); | 2978 content::TestNavigationObserver observer(contents, 1); |
| 2979 chrome::Reload(browser(), CURRENT_TAB); | 2979 chrome::Reload(browser(), WindowOpenDisposition::CURRENT_TAB); |
| 2980 observer.Wait(); | 2980 observer.Wait(); |
| 2981 | 2981 |
| 2982 SSLErrorHandler* ssl_error_handler = | 2982 SSLErrorHandler* ssl_error_handler = |
| 2983 SSLErrorHandler::FromWebContents(contents); | 2983 SSLErrorHandler::FromWebContents(contents); |
| 2984 // Make sure that the |SSLErrorHandler| is deleted. | 2984 // Make sure that the |SSLErrorHandler| is deleted. |
| 2985 EXPECT_FALSE(ssl_error_handler); | 2985 EXPECT_FALSE(ssl_error_handler); |
| 2986 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 2986 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
| 2987 EXPECT_FALSE(contents->IsLoading()); | 2987 EXPECT_FALSE(contents->IsLoading()); |
| 2988 } | 2988 } |
| 2989 | 2989 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3029 https_server_url.ReplaceComponents(replacements); | 3029 https_server_url.ReplaceComponents(replacements); |
| 3030 | 3030 |
| 3031 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); | 3031 WebContents* contents = browser()->tab_strip_model()->GetActiveWebContents(); |
| 3032 CommonNameMismatchHandler::set_state_for_testing( | 3032 CommonNameMismatchHandler::set_state_for_testing( |
| 3033 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); | 3033 CommonNameMismatchHandler::IGNORE_REQUESTS_FOR_TESTING); |
| 3034 // Set delay long enough so that the page appears loading. | 3034 // Set delay long enough so that the page appears loading. |
| 3035 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); | 3035 SSLErrorHandler::SetInterstitialDelayForTest(base::TimeDelta::FromHours(1)); |
| 3036 SSLInterstitialTimerObserver interstitial_timer_observer(contents); | 3036 SSLInterstitialTimerObserver interstitial_timer_observer(contents); |
| 3037 | 3037 |
| 3038 ui_test_utils::NavigateToURLWithDisposition( | 3038 ui_test_utils::NavigateToURLWithDisposition( |
| 3039 browser(), https_server_mismatched_url, CURRENT_TAB, | 3039 browser(), https_server_mismatched_url, |
| 3040 ui_test_utils::BROWSER_TEST_NONE); | 3040 WindowOpenDisposition::CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 3041 interstitial_timer_observer.WaitForTimerStarted(); | 3041 interstitial_timer_observer.WaitForTimerStarted(); |
| 3042 | 3042 |
| 3043 EXPECT_TRUE(contents->IsLoading()); | 3043 EXPECT_TRUE(contents->IsLoading()); |
| 3044 content::TestNavigationObserver observer(contents, 1); | 3044 content::TestNavigationObserver observer(contents, 1); |
| 3045 browser()->OpenURL(content::OpenURLParams(GURL("https://google.com"), | 3045 browser()->OpenURL(content::OpenURLParams( |
| 3046 content::Referrer(), CURRENT_TAB, | 3046 GURL("https://google.com"), content::Referrer(), |
| 3047 ui::PAGE_TRANSITION_TYPED, false)); | 3047 WindowOpenDisposition::CURRENT_TAB, ui::PAGE_TRANSITION_TYPED, false)); |
| 3048 observer.Wait(); | 3048 observer.Wait(); |
| 3049 | 3049 |
| 3050 SSLErrorHandler* ssl_error_handler = | 3050 SSLErrorHandler* ssl_error_handler = |
| 3051 SSLErrorHandler::FromWebContents(contents); | 3051 SSLErrorHandler::FromWebContents(contents); |
| 3052 // Make sure that the |SSLErrorHandler| is deleted. | 3052 // Make sure that the |SSLErrorHandler| is deleted. |
| 3053 EXPECT_FALSE(ssl_error_handler); | 3053 EXPECT_FALSE(ssl_error_handler); |
| 3054 EXPECT_FALSE(contents->ShowingInterstitialPage()); | 3054 EXPECT_FALSE(contents->ShowingInterstitialPage()); |
| 3055 EXPECT_FALSE(contents->IsLoading()); | 3055 EXPECT_FALSE(contents->IsLoading()); |
| 3056 } | 3056 } |
| 3057 | 3057 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3096 | 3096 |
| 3097 // Visit a page over https that contains a frame with a redirect. | 3097 // Visit a page over https that contains a frame with a redirect. |
| 3098 | 3098 |
| 3099 // XMLHttpRequest insecure content in synchronous mode. | 3099 // XMLHttpRequest insecure content in synchronous mode. |
| 3100 | 3100 |
| 3101 // XMLHttpRequest insecure content in asynchronous mode. | 3101 // XMLHttpRequest insecure content in asynchronous mode. |
| 3102 | 3102 |
| 3103 // XMLHttpRequest over bad ssl in synchronous mode. | 3103 // XMLHttpRequest over bad ssl in synchronous mode. |
| 3104 | 3104 |
| 3105 // XMLHttpRequest over OK ssl in synchronous mode. | 3105 // XMLHttpRequest over OK ssl in synchronous mode. |
| OLD | NEW |