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/base64.h" | 7 #include "base/base64.h" |
8 #include "base/base_switches.h" | 8 #include "base/base_switches.h" |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 #include "components/content_settings/core/browser/host_content_settings_map.h" | 61 #include "components/content_settings/core/browser/host_content_settings_map.h" |
62 #include "components/network_session_configurator/common/network_switches.h" | 62 #include "components/network_session_configurator/common/network_switches.h" |
63 #include "components/network_time/network_time_test_utils.h" | 63 #include "components/network_time/network_time_test_utils.h" |
64 #include "components/network_time/network_time_tracker.h" | 64 #include "components/network_time/network_time_tracker.h" |
65 #include "components/policy/core/browser/browser_policy_connector.h" | 65 #include "components/policy/core/browser/browser_policy_connector.h" |
66 #include "components/policy/core/common/mock_configuration_policy_provider.h" | 66 #include "components/policy/core/common/mock_configuration_policy_provider.h" |
67 #include "components/policy/core/common/policy_map.h" | 67 #include "components/policy/core/common/policy_map.h" |
68 #include "components/policy/policy_constants.h" | 68 #include "components/policy/policy_constants.h" |
69 #include "components/prefs/testing_pref_service.h" | 69 #include "components/prefs/testing_pref_service.h" |
70 #include "components/safe_browsing/common/safe_browsing_prefs.h" | 70 #include "components/safe_browsing/common/safe_browsing_prefs.h" |
| 71 #include "components/security_interstitials/content/security_interstitial_contro
ller_client.h" |
71 #include "components/security_interstitials/core/controller_client.h" | 72 #include "components/security_interstitials/core/controller_client.h" |
72 #include "components/security_interstitials/core/metrics_helper.h" | 73 #include "components/security_interstitials/core/metrics_helper.h" |
73 #include "components/security_state/core/security_state.h" | 74 #include "components/security_state/core/security_state.h" |
74 #include "components/security_state/core/switches.h" | 75 #include "components/security_state/core/switches.h" |
75 #include "components/ssl_config/ssl_config_prefs.h" | 76 #include "components/ssl_config/ssl_config_prefs.h" |
76 #include "components/ssl_errors/error_classification.h" | 77 #include "components/ssl_errors/error_classification.h" |
77 #include "components/strings/grit/components_strings.h" | 78 #include "components/strings/grit/components_strings.h" |
78 #include "components/variations/variations_associated_data.h" | 79 #include "components/variations/variations_associated_data.h" |
79 #include "components/variations/variations_switches.h" | 80 #include "components/variations/variations_switches.h" |
80 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 81 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 #include "net/cert/nss_cert_database.h" | 134 #include "net/cert/nss_cert_database.h" |
134 #endif // defined(USE_NSS_CERTS) | 135 #endif // defined(USE_NSS_CERTS) |
135 | 136 |
136 using base::ASCIIToUTF16; | 137 using base::ASCIIToUTF16; |
137 using chrome_browser_interstitials::SecurityInterstitialIDNTest; | 138 using chrome_browser_interstitials::SecurityInterstitialIDNTest; |
138 using content::InterstitialPage; | 139 using content::InterstitialPage; |
139 using content::NavigationController; | 140 using content::NavigationController; |
140 using content::NavigationEntry; | 141 using content::NavigationEntry; |
141 using content::SSLStatus; | 142 using content::SSLStatus; |
142 using content::WebContents; | 143 using content::WebContents; |
| 144 using security_interstitials::SecurityInterstitialControllerClient; |
143 using web_modal::WebContentsModalDialogManager; | 145 using web_modal::WebContentsModalDialogManager; |
144 | 146 |
145 const base::FilePath::CharType kDocRoot[] = | 147 const base::FilePath::CharType kDocRoot[] = |
146 FILE_PATH_LITERAL("chrome/test/data"); | 148 FILE_PATH_LITERAL("chrome/test/data"); |
147 | 149 |
148 namespace { | 150 namespace { |
149 | 151 |
150 enum ProceedDecision { | 152 enum ProceedDecision { |
151 SSL_INTERSTITIAL_PROCEED, | 153 SSL_INTERSTITIAL_PROCEED, |
152 SSL_INTERSTITIAL_DO_NOT_PROCEED | 154 SSL_INTERSTITIAL_DO_NOT_PROCEED |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
703 policy::POLICY_SOURCE_CLOUD, | 705 policy::POLICY_SOURCE_CLOUD, |
704 base::MakeUnique<base::Value>(true), nullptr); | 706 base::MakeUnique<base::Value>(true), nullptr); |
705 UpdateChromePolicy(policy_map); | 707 UpdateChromePolicy(policy_map); |
706 | 708 |
707 EXPECT_TRUE(g_browser_process->local_state()->GetBoolean( | 709 EXPECT_TRUE(g_browser_process->local_state()->GetBoolean( |
708 ssl_config::prefs::kCertRevocationCheckingEnabled)); | 710 ssl_config::prefs::kCertRevocationCheckingEnabled)); |
709 EXPECT_TRUE(g_browser_process->local_state()->IsManagedPreference( | 711 EXPECT_TRUE(g_browser_process->local_state()->IsManagedPreference( |
710 ssl_config::prefs::kCertRevocationCheckingEnabled)); | 712 ssl_config::prefs::kCertRevocationCheckingEnabled)); |
711 } | 713 } |
712 | 714 |
| 715 // Helper function for TestInterstitialLinksOpenInNewTab. Implemented as a |
| 716 // test fixture method because the whole test fixture class is friended by |
| 717 // SSLBlockingPage. |
| 718 security_interstitials::SecurityInterstitialControllerClient* |
| 719 GetControllerClientFromInterstitialPage(SSLBlockingPage* ssl_interstitial) { |
| 720 return ssl_interstitial->controller(); |
| 721 } |
| 722 |
713 net::EmbeddedTestServer https_server_; | 723 net::EmbeddedTestServer https_server_; |
714 net::EmbeddedTestServer https_server_expired_; | 724 net::EmbeddedTestServer https_server_expired_; |
715 net::EmbeddedTestServer https_server_mismatched_; | 725 net::EmbeddedTestServer https_server_mismatched_; |
716 net::SpawnedTestServer https_server_ocsp_ok_; | 726 net::SpawnedTestServer https_server_ocsp_ok_; |
717 net::SpawnedTestServer https_server_ocsp_revoked_; | 727 net::SpawnedTestServer https_server_ocsp_revoked_; |
718 net::SpawnedTestServer wss_server_expired_; | 728 net::SpawnedTestServer wss_server_expired_; |
719 net::SpawnedTestServer wss_server_mismatched_; | 729 net::SpawnedTestServer wss_server_mismatched_; |
720 | 730 |
721 protected: | 731 protected: |
722 // Navigates to an interstitial and clicks through the certificate | 732 // Navigates to an interstitial and clicks through the certificate |
(...skipping 2283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3006 | 3016 |
3007 content::WindowedNotificationObserver observer( | 3017 content::WindowedNotificationObserver observer( |
3008 content::NOTIFICATION_LOAD_STOP, | 3018 content::NOTIFICATION_LOAD_STOP, |
3009 content::Source<NavigationController>(&tab->GetController())); | 3019 content::Source<NavigationController>(&tab->GetController())); |
3010 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 3020 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
3011 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 3021 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
3012 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 3022 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
3013 content::RenderViewHost* interstitial_rvh = | 3023 content::RenderViewHost* interstitial_rvh = |
3014 interstitial_page->GetMainFrame()->GetRenderViewHost(); | 3024 interstitial_page->GetMainFrame()->GetRenderViewHost(); |
3015 int result = -1; | 3025 int result = -1; |
3016 std::string javascript = | 3026 const std::string javascript = |
3017 base::StringPrintf("window.domAutomationController.send(%d);", | 3027 base::StringPrintf("window.domAutomationController.send(%d);", |
3018 security_interstitials::CMD_PROCEED); | 3028 security_interstitials::CMD_PROCEED); |
3019 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 3029 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
3020 interstitial_rvh, javascript, &result)); | 3030 interstitial_rvh, javascript, &result)); |
3021 // The above will hang without the fix. | 3031 // The above will hang without the fix. |
3022 EXPECT_EQ(1, result); | 3032 EXPECT_EQ(1, result); |
3023 observer.Wait(); | 3033 observer.Wait(); |
3024 CheckAuthenticationBrokenState( | 3034 CheckAuthenticationBrokenState( |
3025 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); | 3035 tab, net::CERT_STATUS_DATE_INVALID, AuthState::NONE); |
3026 } | 3036 } |
(...skipping 14 matching lines...) Expand all Loading... |
3041 | 3051 |
3042 content::WindowedNotificationObserver observer( | 3052 content::WindowedNotificationObserver observer( |
3043 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, | 3053 content::NOTIFICATION_RENDER_WIDGET_HOST_DESTROYED, |
3044 content::NotificationService::AllSources()); | 3054 content::NotificationService::AllSources()); |
3045 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); | 3055 InterstitialPage* interstitial_page = tab->GetInterstitialPage(); |
3046 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, | 3056 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
3047 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); | 3057 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
3048 content::RenderViewHost* interstitial_rvh = | 3058 content::RenderViewHost* interstitial_rvh = |
3049 interstitial_page->GetMainFrame()->GetRenderViewHost(); | 3059 interstitial_page->GetMainFrame()->GetRenderViewHost(); |
3050 int result = -1; | 3060 int result = -1; |
3051 std::string javascript = | 3061 const std::string javascript = |
3052 base::StringPrintf("window.domAutomationController.send(%d);", | 3062 base::StringPrintf("window.domAutomationController.send(%d);", |
3053 security_interstitials::CMD_DONT_PROCEED); | 3063 security_interstitials::CMD_DONT_PROCEED); |
3054 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( | 3064 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
3055 interstitial_rvh, javascript, &result)); | 3065 interstitial_rvh, javascript, &result)); |
3056 // The above will hang without the fix. | 3066 // The above will hang without the fix. |
3057 EXPECT_EQ(0, result); | 3067 EXPECT_EQ(0, result); |
3058 observer.Wait(); | 3068 observer.Wait(); |
3059 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); | 3069 EXPECT_EQ("about:blank", tab->GetVisibleURL().spec()); |
3060 } | 3070 } |
3061 | 3071 |
| 3072 // Verifies that links in the interstitial open in a new tab. |
| 3073 // https://crbug.com/717616 |
| 3074 IN_PROC_BROWSER_TEST_F(SSLUITest, TestInterstitialLinksOpenInNewTab) { |
| 3075 ASSERT_TRUE(https_server_.Start()); |
| 3076 ASSERT_TRUE(https_server_expired_.Start()); |
| 3077 |
| 3078 WebContents* interstitial_tab = |
| 3079 browser()->tab_strip_model()->GetActiveWebContents(); |
| 3080 ui_test_utils::NavigateToURL( |
| 3081 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
| 3082 content::WaitForInterstitialAttach( |
| 3083 browser()->tab_strip_model()->GetActiveWebContents()); |
| 3084 InterstitialPage* interstitial_page = interstitial_tab->GetInterstitialPage(); |
| 3085 ASSERT_TRUE( |
| 3086 content::WaitForRenderFrameReady(interstitial_page->GetMainFrame())); |
| 3087 CheckAuthenticationBrokenState(interstitial_tab, |
| 3088 net::CERT_STATUS_DATE_INVALID, |
| 3089 AuthState::SHOWING_INTERSTITIAL); |
| 3090 ASSERT_EQ(SSLBlockingPage::kTypeForTesting, |
| 3091 interstitial_page->GetDelegateForTesting()->GetTypeForTesting()); |
| 3092 |
| 3093 content::TestNavigationObserver nav_observer(nullptr); |
| 3094 nav_observer.StartWatchingNewWebContents(); |
| 3095 |
| 3096 SSLBlockingPage* ssl_interstitial = |
| 3097 static_cast<SSLBlockingPage*>(interstitial_page->GetDelegateForTesting()); |
| 3098 security_interstitials::SecurityInterstitialControllerClient* client = |
| 3099 GetControllerClientFromInterstitialPage(ssl_interstitial); |
| 3100 |
| 3101 // Mock out the help center URL so that our test will hit the test server |
| 3102 // instead of a real server. |
| 3103 // NOTE: The CMD_OPEN_HELP_CENTER code in |
| 3104 // components/security_interstitials/core/ssl_error_ui.cc ends up appending |
| 3105 // a path to whatever URL is passed to it. Since that path doesn't exist on |
| 3106 // our test server, this results in a 404. This is expected behavior, and |
| 3107 // things are still working as expected so long as the test passes! |
| 3108 const GURL mock_help_center_url = https_server_.GetURL("/title1.html"); |
| 3109 client->SetBaseHelpCenterUrlForTesting(mock_help_center_url); |
| 3110 |
| 3111 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
| 3112 |
| 3113 int result = -1; |
| 3114 const std::string javascript = |
| 3115 base::StringPrintf("window.domAutomationController.send(%d);", |
| 3116 security_interstitials::CMD_OPEN_HELP_CENTER); |
| 3117 ASSERT_TRUE(content::ExecuteScriptAndExtractInt( |
| 3118 interstitial_page->GetMainFrame(), javascript, &result)); |
| 3119 EXPECT_EQ(security_interstitials::CMD_OPEN_HELP_CENTER, result); |
| 3120 |
| 3121 nav_observer.Wait(); |
| 3122 |
| 3123 EXPECT_EQ(2, browser()->tab_strip_model()->count()); |
| 3124 WebContents* new_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 3125 ASSERT_TRUE(new_tab); |
| 3126 EXPECT_EQ(mock_help_center_url.host(), new_tab->GetURL().host()); |
| 3127 } |
| 3128 |
3062 // Verifies that switching tabs, while showing interstitial page, will not | 3129 // Verifies that switching tabs, while showing interstitial page, will not |
3063 // affect the visibility of the interestitial. | 3130 // affect the visibility of the interstitial. |
3064 // https://crbug.com/381439 | 3131 // https://crbug.com/381439 |
3065 IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) { | 3132 IN_PROC_BROWSER_TEST_F(SSLUITest, InterstitialNotAffectedByHideShow) { |
3066 ASSERT_TRUE(https_server_expired_.Start()); | 3133 ASSERT_TRUE(https_server_expired_.Start()); |
3067 ASSERT_TRUE(https_server_.Start()); | 3134 ASSERT_TRUE(https_server_.Start()); |
3068 | 3135 |
3069 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 3136 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
3070 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); | 3137 EXPECT_TRUE(tab->GetRenderWidgetHostView()->IsShowing()); |
3071 ui_test_utils::NavigateToURL( | 3138 ui_test_utils::NavigateToURL( |
3072 browser(), https_server_expired_.GetURL("/ssl/google.html")); | 3139 browser(), https_server_expired_.GetURL("/ssl/google.html")); |
3073 CheckAuthenticationBrokenState( | 3140 CheckAuthenticationBrokenState( |
(...skipping 1959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5033 | 5100 |
5034 // Visit a page over https that contains a frame with a redirect. | 5101 // Visit a page over https that contains a frame with a redirect. |
5035 | 5102 |
5036 // XMLHttpRequest insecure content in synchronous mode. | 5103 // XMLHttpRequest insecure content in synchronous mode. |
5037 | 5104 |
5038 // XMLHttpRequest insecure content in asynchronous mode. | 5105 // XMLHttpRequest insecure content in asynchronous mode. |
5039 | 5106 |
5040 // XMLHttpRequest over bad ssl in synchronous mode. | 5107 // XMLHttpRequest over bad ssl in synchronous mode. |
5041 | 5108 |
5042 // XMLHttpRequest over OK ssl in synchronous mode. | 5109 // XMLHttpRequest over OK ssl in synchronous mode. |
OLD | NEW |