| 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 // This test creates a fake safebrowsing service, where we can inject known- | 5 // This test creates a fake safebrowsing service, where we can inject known- |
| 6 // threat urls. It then uses a real browser to go to these urls, and sends | 6 // threat urls. It then uses a real browser to go to these urls, and sends |
| 7 // "goback" or "proceed" commands and verifies they work. | 7 // "goback" or "proceed" commands and verifies they work. |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 | 10 |
| (...skipping 1029 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1040 ui_test_utils::NavigateToURL(browser(), GURL(kUnrelatedUrl)); | 1040 ui_test_utils::NavigateToURL(browser(), GURL(kUnrelatedUrl)); |
| 1041 AssertNoInterstitial(false); | 1041 AssertNoInterstitial(false); |
| 1042 | 1042 |
| 1043 // The non-whitelisted page should now show an interstitial. | 1043 // The non-whitelisted page should now show an interstitial. |
| 1044 ui_test_utils::NavigateToURL(browser(), url); | 1044 ui_test_utils::NavigateToURL(browser(), url); |
| 1045 EXPECT_TRUE(WaitForReady()); | 1045 EXPECT_TRUE(WaitForReady()); |
| 1046 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); | 1046 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); |
| 1047 AssertNoInterstitial(true); | 1047 AssertNoInterstitial(true); |
| 1048 } | 1048 } |
| 1049 | 1049 |
| 1050 namespace { | |
| 1051 | |
| 1052 class SecurityStyleTestObserver : public content::WebContentsObserver { | |
| 1053 public: | |
| 1054 explicit SecurityStyleTestObserver(content::WebContents* web_contents) | |
| 1055 : content::WebContentsObserver(web_contents), | |
| 1056 latest_security_style_(blink::WebSecurityStyleUnknown){}; | |
| 1057 | |
| 1058 blink::WebSecurityStyle latest_security_style() const { | |
| 1059 return latest_security_style_; | |
| 1060 } | |
| 1061 | |
| 1062 // WebContentsObserver: | |
| 1063 void SecurityStyleChanged(blink::WebSecurityStyle security_style, | |
| 1064 const content::SecurityStyleExplanations& | |
| 1065 security_style_explanations) override { | |
| 1066 latest_security_style_ = security_style; | |
| 1067 } | |
| 1068 | |
| 1069 private: | |
| 1070 blink::WebSecurityStyle latest_security_style_; | |
| 1071 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver); | |
| 1072 }; | |
| 1073 | |
| 1074 } // namespace | |
| 1075 | |
| 1076 // Test that the security indicator gets updated on a Safe Browsing | |
| 1077 // interstitial triggered by a subresource. Regression test for | |
| 1078 // https://crbug.com/659713. | |
| 1079 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, | |
| 1080 SecurityStateDowngradedForSubresourceInterstitial) { | |
| 1081 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1082 ASSERT_TRUE(error_tab); | |
| 1083 SecurityStyleTestObserver observer(error_tab); | |
| 1084 // The security indicator should be downgraded while the interstitial shows. | |
| 1085 SetupThreatIframeWarningAndNavigate(); | |
| 1086 ExpectSecurityIndicatorDowngrade(error_tab, 0u); | |
| 1087 EXPECT_EQ(blink::WebSecurityStyleAuthenticationBroken, | |
| 1088 observer.latest_security_style()); | |
| 1089 | |
| 1090 // The security indicator should still be downgraded post-interstitial. | |
| 1091 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); | |
| 1092 AssertNoInterstitial(true); | |
| 1093 WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1094 ASSERT_TRUE(post_tab); | |
| 1095 ExpectSecurityIndicatorDowngrade(post_tab, 0u); | |
| 1096 } | |
| 1097 | |
| 1098 // Test that the security indicator is downgraded after clicking through a | 1050 // Test that the security indicator is downgraded after clicking through a |
| 1099 // Safe Browsing interstitial. | 1051 // Safe Browsing interstitial. |
| 1100 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, | 1052 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, |
| 1101 SecurityState_HTTP) { | 1053 SecurityState_HTTP) { |
| 1102 // The security indicator should be downgraded while the interstitial shows. | 1054 // The security indicator should be downgraded while the interstitial shows. |
| 1103 SetupWarningAndNavigate(); | 1055 SetupWarningAndNavigate(); |
| 1104 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents(); | 1056 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 1105 ASSERT_TRUE(error_tab); | 1057 ASSERT_TRUE(error_tab); |
| 1106 ExpectSecurityIndicatorDowngrade(error_tab, 0u); | 1058 ExpectSecurityIndicatorDowngrade(error_tab, 0u); |
| 1107 | 1059 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1199 | 1151 |
| 1200 INSTANTIATE_TEST_CASE_P( | 1152 INSTANTIATE_TEST_CASE_P( |
| 1201 SafeBrowsingBlockingPageIDNTestWithThreatType, | 1153 SafeBrowsingBlockingPageIDNTestWithThreatType, |
| 1202 SafeBrowsingBlockingPageIDNTest, | 1154 SafeBrowsingBlockingPageIDNTest, |
| 1203 testing::Combine(testing::Values(false, true), | 1155 testing::Combine(testing::Values(false, true), |
| 1204 testing::Values(SB_THREAT_TYPE_URL_MALWARE, | 1156 testing::Values(SB_THREAT_TYPE_URL_MALWARE, |
| 1205 SB_THREAT_TYPE_URL_PHISHING, | 1157 SB_THREAT_TYPE_URL_PHISHING, |
| 1206 SB_THREAT_TYPE_URL_UNWANTED))); | 1158 SB_THREAT_TYPE_URL_UNWANTED))); |
| 1207 | 1159 |
| 1208 } // namespace safe_browsing | 1160 } // namespace safe_browsing |
| OLD | NEW |