Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_blocking_page_test.cc

Issue 2456383003: Reland of Trigger Dangerous indicator for unsafe subresources (Closed)
Patch Set: initialize is_subframe Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/ui_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 1027 matching lines...) Expand 10 before | Expand all | Expand 10 after
1038 ui_test_utils::NavigateToURL(browser(), GURL(kUnrelatedUrl)); 1038 ui_test_utils::NavigateToURL(browser(), GURL(kUnrelatedUrl));
1039 AssertNoInterstitial(false); 1039 AssertNoInterstitial(false);
1040 1040
1041 // The non-whitelisted page should now show an interstitial. 1041 // The non-whitelisted page should now show an interstitial.
1042 ui_test_utils::NavigateToURL(browser(), url); 1042 ui_test_utils::NavigateToURL(browser(), url);
1043 EXPECT_TRUE(WaitForReady()); 1043 EXPECT_TRUE(WaitForReady());
1044 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link")); 1044 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
1045 AssertNoInterstitial(true); 1045 AssertNoInterstitial(true);
1046 } 1046 }
1047 1047
1048 namespace {
1049
1050 class SecurityStyleTestObserver : public content::WebContentsObserver {
1051 public:
1052 explicit SecurityStyleTestObserver(content::WebContents* web_contents)
1053 : content::WebContentsObserver(web_contents),
1054 latest_security_style_(blink::WebSecurityStyleUnknown){};
1055
1056 blink::WebSecurityStyle latest_security_style() const {
1057 return latest_security_style_;
1058 }
1059
1060 // WebContentsObserver:
1061 void SecurityStyleChanged(blink::WebSecurityStyle security_style,
1062 const content::SecurityStyleExplanations&
1063 security_style_explanations) override {
1064 latest_security_style_ = security_style;
1065 }
1066
1067 private:
1068 blink::WebSecurityStyle latest_security_style_;
1069 DISALLOW_COPY_AND_ASSIGN(SecurityStyleTestObserver);
1070 };
1071
1072 } // namespace
1073
1074 // Test that the security indicator gets updated on a Safe Browsing
1075 // interstitial triggered by a subresource. Regression test for
1076 // https://crbug.com/659713.
1077 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
1078 SecurityStateDowngradedForSubresourceInterstitial) {
1079 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents();
1080 ASSERT_TRUE(error_tab);
1081 SecurityStyleTestObserver observer(error_tab);
1082 // The security indicator should be downgraded while the interstitial shows.
1083 SetupThreatIframeWarningAndNavigate();
1084 ExpectSecurityIndicatorDowngrade(error_tab, 0u);
1085 EXPECT_EQ(blink::WebSecurityStyleAuthenticationBroken,
1086 observer.latest_security_style());
1087
1088 // The security indicator should still be downgraded post-interstitial.
1089 EXPECT_TRUE(ClickAndWaitForDetach("proceed-link"));
1090 AssertNoInterstitial(true);
1091 WebContents* post_tab = browser()->tab_strip_model()->GetActiveWebContents();
1092 ASSERT_TRUE(post_tab);
1093 ExpectSecurityIndicatorDowngrade(post_tab, 0u);
1094 }
1095
1048 // Test that the security indicator is downgraded after clicking through a 1096 // Test that the security indicator is downgraded after clicking through a
1049 // Safe Browsing interstitial. 1097 // Safe Browsing interstitial.
1050 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest, 1098 IN_PROC_BROWSER_TEST_P(SafeBrowsingBlockingPageBrowserTest,
1051 SecurityState_HTTP) { 1099 SecurityState_HTTP) {
1052 // The security indicator should be downgraded while the interstitial shows. 1100 // The security indicator should be downgraded while the interstitial shows.
1053 SetupWarningAndNavigate(); 1101 SetupWarningAndNavigate();
1054 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents(); 1102 WebContents* error_tab = browser()->tab_strip_model()->GetActiveWebContents();
1055 ASSERT_TRUE(error_tab); 1103 ASSERT_TRUE(error_tab);
1056 ExpectSecurityIndicatorDowngrade(error_tab, 0u); 1104 ExpectSecurityIndicatorDowngrade(error_tab, 0u);
1057 1105
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 1197
1150 INSTANTIATE_TEST_CASE_P( 1198 INSTANTIATE_TEST_CASE_P(
1151 SafeBrowsingBlockingPageIDNTestWithThreatType, 1199 SafeBrowsingBlockingPageIDNTestWithThreatType,
1152 SafeBrowsingBlockingPageIDNTest, 1200 SafeBrowsingBlockingPageIDNTest,
1153 testing::Combine(testing::Values(false, true), 1201 testing::Combine(testing::Values(false, true),
1154 testing::Values(SB_THREAT_TYPE_URL_MALWARE, 1202 testing::Values(SB_THREAT_TYPE_URL_MALWARE,
1155 SB_THREAT_TYPE_URL_PHISHING, 1203 SB_THREAT_TYPE_URL_PHISHING,
1156 SB_THREAT_TYPE_URL_UNWANTED))); 1204 SB_THREAT_TYPE_URL_UNWANTED)));
1157 1205
1158 } // namespace safe_browsing 1206 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/ui_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698