OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" | 5 #include "components/subresource_filter/content/browser/content_subresource_filt
er_driver_factory.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 case ActivationList::SUBRESOURCE_FILTER: | 82 case ActivationList::SUBRESOURCE_FILTER: |
83 return "SubresourceFilterOnly"; | 83 return "SubresourceFilterOnly"; |
84 case ActivationList::NONE: | 84 case ActivationList::NONE: |
85 return std::string(); | 85 return std::string(); |
86 } | 86 } |
87 return std::string(); | 87 return std::string(); |
88 } | 88 } |
89 | 89 |
90 struct ActivationListTestData { | 90 struct ActivationListTestData { |
91 ActivationDecision expected_activation_decision; | 91 ActivationDecision expected_activation_decision; |
92 const char* const activation_list; | 92 ActivationList activation_list; |
93 safe_browsing::SBThreatType threat_type; | 93 safe_browsing::SBThreatType threat_type; |
94 safe_browsing::ThreatPatternType threat_type_metadata; | 94 safe_browsing::ThreatPatternType threat_type_metadata; |
95 }; | 95 }; |
96 | 96 |
97 const ActivationListTestData kActivationListTestData[] = { | 97 const ActivationListTestData kActivationListTestData[] = { |
98 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, "", | 98 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, ActivationList::NONE, |
99 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 99 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
100 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 100 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
101 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 101 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
102 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, | 102 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL, |
103 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 103 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
104 safe_browsing::ThreatPatternType::NONE}, | 104 safe_browsing::ThreatPatternType::NONE}, |
105 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 105 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
106 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, | 106 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL, |
107 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 107 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
108 safe_browsing::ThreatPatternType::MALWARE_LANDING}, | 108 safe_browsing::ThreatPatternType::MALWARE_LANDING}, |
109 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 109 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
110 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, | 110 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL, |
111 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 111 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
112 safe_browsing::ThreatPatternType::MALWARE_DISTRIBUTION}, | 112 safe_browsing::ThreatPatternType::MALWARE_DISTRIBUTION}, |
113 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 113 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
114 subresource_filter::kActivationListPhishingInterstitial, | 114 ActivationList::PHISHING_INTERSTITIAL, |
115 safe_browsing::SB_THREAT_TYPE_API_ABUSE, | 115 safe_browsing::SB_THREAT_TYPE_API_ABUSE, |
116 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 116 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
117 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 117 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
118 subresource_filter::kActivationListPhishingInterstitial, | 118 ActivationList::PHISHING_INTERSTITIAL, |
119 safe_browsing::SB_THREAT_TYPE_BLACKLISTED_RESOURCE, | 119 safe_browsing::SB_THREAT_TYPE_BLACKLISTED_RESOURCE, |
120 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 120 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
121 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 121 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
122 subresource_filter::kActivationListPhishingInterstitial, | 122 ActivationList::PHISHING_INTERSTITIAL, |
123 safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, | 123 safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, |
124 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 124 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
125 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 125 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
126 subresource_filter::kActivationListPhishingInterstitial, | 126 ActivationList::PHISHING_INTERSTITIAL, |
127 safe_browsing::SB_THREAT_TYPE_BINARY_MALWARE_URL, | 127 safe_browsing::SB_THREAT_TYPE_BINARY_MALWARE_URL, |
128 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 128 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
129 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 129 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
130 subresource_filter::kActivationListPhishingInterstitial, | 130 ActivationList::PHISHING_INTERSTITIAL, |
131 safe_browsing::SB_THREAT_TYPE_URL_UNWANTED, | 131 safe_browsing::SB_THREAT_TYPE_URL_UNWANTED, |
132 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 132 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
133 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 133 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
134 subresource_filter::kActivationListPhishingInterstitial, | 134 ActivationList::PHISHING_INTERSTITIAL, |
135 safe_browsing::SB_THREAT_TYPE_URL_MALWARE, | 135 safe_browsing::SB_THREAT_TYPE_URL_MALWARE, |
136 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 136 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
137 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 137 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
138 subresource_filter::kActivationListPhishingInterstitial, | 138 ActivationList::PHISHING_INTERSTITIAL, |
139 safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, | 139 safe_browsing::SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, |
140 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 140 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
141 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 141 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
142 subresource_filter::kActivationListPhishingInterstitial, | 142 ActivationList::PHISHING_INTERSTITIAL, safe_browsing::SB_THREAT_TYPE_SAFE, |
143 safe_browsing::SB_THREAT_TYPE_SAFE, | |
144 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 143 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
145 {ActivationDecision::ACTIVATED, | 144 {ActivationDecision::ACTIVATED, ActivationList::PHISHING_INTERSTITIAL, |
146 subresource_filter::kActivationListPhishingInterstitial, | |
147 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 145 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
148 safe_browsing::ThreatPatternType::NONE}, | 146 safe_browsing::ThreatPatternType::NONE}, |
149 {ActivationDecision::ACTIVATED, | 147 {ActivationDecision::ACTIVATED, ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL, |
150 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, | |
151 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 148 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
152 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 149 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
153 {ActivationDecision::ACTIVATED, | 150 {ActivationDecision::ACTIVATED, ActivationList::PHISHING_INTERSTITIAL, |
154 subresource_filter::kActivationListPhishingInterstitial, | |
155 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 151 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
156 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 152 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
157 }; | 153 }; |
158 | 154 |
159 struct ActivationScopeTestData { | 155 struct ActivationScopeTestData { |
160 ActivationDecision expected_activation_decision; | 156 ActivationDecision expected_activation_decision; |
161 bool url_matches_activation_list; | 157 bool url_matches_activation_list; |
162 const char* const activation_scope; | 158 ActivationScope activation_scope; |
163 }; | 159 }; |
164 | 160 |
165 const ActivationScopeTestData kActivationScopeTestData[] = { | 161 const ActivationScopeTestData kActivationScopeTestData[] = { |
166 {ActivationDecision::ACTIVATED, false /* url_matches_activation_list */, | 162 {ActivationDecision::ACTIVATED, false /* url_matches_activation_list */, |
167 kActivationScopeAllSites}, | 163 ActivationScope::ALL_SITES}, |
168 {ActivationDecision::ACTIVATED, true /* url_matches_activation_list */, | 164 {ActivationDecision::ACTIVATED, true /* url_matches_activation_list */, |
169 kActivationScopeAllSites}, | 165 ActivationScope::ALL_SITES}, |
170 {ActivationDecision::ACTIVATION_DISABLED, | 166 {ActivationDecision::ACTIVATION_DISABLED, |
171 true /* url_matches_activation_list */, kActivationScopeNoSites}, | 167 true /* url_matches_activation_list */, ActivationScope::NO_SITES}, |
172 {ActivationDecision::ACTIVATED, true /* url_matches_activation_list */, | 168 {ActivationDecision::ACTIVATED, true /* url_matches_activation_list */, |
173 kActivationScopeActivationList}, | 169 ActivationScope::ACTIVATION_LIST}, |
174 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, | 170 {ActivationDecision::ACTIVATION_LIST_NOT_MATCHED, |
175 false /* url_matches_activation_list */, kActivationScopeActivationList}, | 171 false /* url_matches_activation_list */, ActivationScope::ACTIVATION_LIST}, |
176 }; | 172 }; |
177 | 173 |
178 struct ActivationLevelTestData { | 174 struct ActivationLevelTestData { |
179 ActivationDecision expected_activation_decision; | 175 ActivationDecision expected_activation_decision; |
180 const char* const activation_level; | 176 ActivationLevel activation_level; |
181 }; | 177 }; |
182 | 178 |
183 const ActivationLevelTestData kActivationLevelTestData[] = { | 179 const ActivationLevelTestData kActivationLevelTestData[] = { |
184 {ActivationDecision::ACTIVATED, kActivationLevelDryRun}, | 180 {ActivationDecision::ACTIVATED, ActivationLevel::DRYRUN}, |
185 {ActivationDecision::ACTIVATED, kActivationLevelEnabled}, | 181 {ActivationDecision::ACTIVATED, ActivationLevel::ENABLED}, |
186 {ActivationDecision::ACTIVATION_DISABLED, kActivationLevelDisabled}, | 182 {ActivationDecision::ACTIVATION_DISABLED, ActivationLevel::DISABLED}, |
187 }; | 183 }; |
188 | 184 |
189 class MockSubresourceFilterClient : public SubresourceFilterClient { | 185 class MockSubresourceFilterClient : public SubresourceFilterClient { |
190 public: | 186 public: |
191 MockSubresourceFilterClient(VerifiedRulesetDealer::Handle* ruleset_dealer) | 187 MockSubresourceFilterClient(VerifiedRulesetDealer::Handle* ruleset_dealer) |
192 : ruleset_dealer_(ruleset_dealer) {} | 188 : ruleset_dealer_(ruleset_dealer) {} |
193 | 189 |
194 ~MockSubresourceFilterClient() override = default; | 190 ~MockSubresourceFilterClient() override = default; |
195 | 191 |
196 bool ShouldSuppressActivation(content::NavigationHandle* handle) override { | 192 bool ShouldSuppressActivation(content::NavigationHandle* handle) override { |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 rules.push_back(testing::CreateSuffixRule("disallowed.html")); | 232 rules.push_back(testing::CreateSuffixRule("disallowed.html")); |
237 ASSERT_NO_FATAL_FAILURE(test_ruleset_creator_.CreateRulesetWithRules( | 233 ASSERT_NO_FATAL_FAILURE(test_ruleset_creator_.CreateRulesetWithRules( |
238 rules, &test_ruleset_pair_)); | 234 rules, &test_ruleset_pair_)); |
239 ruleset_dealer_ = base::MakeUnique<VerifiedRulesetDealer::Handle>( | 235 ruleset_dealer_ = base::MakeUnique<VerifiedRulesetDealer::Handle>( |
240 base::MessageLoop::current()->task_runner()); | 236 base::MessageLoop::current()->task_runner()); |
241 ruleset_dealer_->SetRulesetFile( | 237 ruleset_dealer_->SetRulesetFile( |
242 testing::TestRuleset::Open(test_ruleset_pair_.indexed)); | 238 testing::TestRuleset::Open(test_ruleset_pair_.indexed)); |
243 client_ = new MockSubresourceFilterClient(ruleset_dealer_.get()); | 239 client_ = new MockSubresourceFilterClient(ruleset_dealer_.get()); |
244 ContentSubresourceFilterDriverFactory::CreateForWebContents( | 240 ContentSubresourceFilterDriverFactory::CreateForWebContents( |
245 RenderViewHostTestHarness::web_contents(), base::WrapUnique(client())); | 241 RenderViewHostTestHarness::web_contents(), base::WrapUnique(client())); |
| 242 ResetConfigurationToEnableFilteringOnSocialEngineeringSites(); |
246 | 243 |
247 // Add a subframe. | 244 // Add a subframe. |
248 content::RenderFrameHostTester* rfh_tester = | 245 content::RenderFrameHostTester* rfh_tester = |
249 content::RenderFrameHostTester::For(main_rfh()); | 246 content::RenderFrameHostTester::For(main_rfh()); |
250 rfh_tester->InitializeRenderFrameIfNeeded(); | 247 rfh_tester->InitializeRenderFrameIfNeeded(); |
251 rfh_tester->AppendChild(kSubframeName); | 248 rfh_tester->AppendChild(kSubframeName); |
252 | 249 |
253 Observe(content::RenderViewHostTestHarness::web_contents()); | 250 Observe(content::RenderViewHostTestHarness::web_contents()); |
254 } | 251 } |
255 | 252 |
256 void TearDown() override { | 253 void TearDown() override { |
257 ruleset_dealer_.reset(); | 254 ruleset_dealer_.reset(); |
258 base::RunLoop().RunUntilIdle(); | 255 base::RunLoop().RunUntilIdle(); |
259 RenderViewHostTestHarness::TearDown(); | 256 RenderViewHostTestHarness::TearDown(); |
260 } | 257 } |
261 | 258 |
| 259 void ResetConfiguration(Configuration config) { |
| 260 scoped_configuration_.ResetConfiguration(std::move(config)); |
| 261 } |
| 262 |
| 263 void ResetConfigurationToEnableFilteringOnAllSites() { |
| 264 ResetConfiguration( |
| 265 Configuration(ActivationLevel::ENABLED, ActivationScope::ALL_SITES)); |
| 266 } |
| 267 |
| 268 void ResetConfigurationToEnableFilteringOnSocialEngineeringSites() { |
| 269 ResetConfiguration(Configuration( |
| 270 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, |
| 271 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
| 272 } |
| 273 |
262 ContentSubresourceFilterDriverFactory* factory() { | 274 ContentSubresourceFilterDriverFactory* factory() { |
263 return ContentSubresourceFilterDriverFactory::FromWebContents( | 275 return ContentSubresourceFilterDriverFactory::FromWebContents( |
264 RenderViewHostTestHarness::web_contents()); | 276 RenderViewHostTestHarness::web_contents()); |
265 } | 277 } |
266 | 278 |
267 MockSubresourceFilterClient* client() { return client_; } | 279 MockSubresourceFilterClient* client() { return client_; } |
268 | 280 |
269 content::RenderFrameHost* GetSubframeRFH() { | 281 content::RenderFrameHost* GetSubframeRFH() { |
270 for (content::RenderFrameHost* rfh : | 282 for (content::RenderFrameHost* rfh : |
271 RenderViewHostTestHarness::web_contents()->GetAllFrames()) { | 283 RenderViewHostTestHarness::web_contents()->GetAllFrames()) { |
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
470 private: | 482 private: |
471 static bool expected_measure_performance() { | 483 static bool expected_measure_performance() { |
472 const double rate = GetActiveConfigurations() | 484 const double rate = GetActiveConfigurations() |
473 ->the_one_and_only() | 485 ->the_one_and_only() |
474 .performance_measurement_rate; | 486 .performance_measurement_rate; |
475 // Note: The case when 0 < rate < 1 is not deterministic, don't test it. | 487 // Note: The case when 0 < rate < 1 is not deterministic, don't test it. |
476 EXPECT_TRUE(rate == 0 || rate == 1); | 488 EXPECT_TRUE(rate == 0 || rate == 1); |
477 return rate == 1; | 489 return rate == 1; |
478 } | 490 } |
479 | 491 |
| 492 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; |
480 testing::TestRulesetCreator test_ruleset_creator_; | 493 testing::TestRulesetCreator test_ruleset_creator_; |
481 testing::TestRulesetPair test_ruleset_pair_; | 494 testing::TestRulesetPair test_ruleset_pair_; |
482 | 495 |
483 // Owned by the factory. | 496 // Owned by the factory. |
484 MockSubresourceFilterClient* client_; | 497 MockSubresourceFilterClient* client_; |
485 | 498 |
486 std::unique_ptr<VerifiedRulesetDealer::Handle> ruleset_dealer_; | 499 std::unique_ptr<VerifiedRulesetDealer::Handle> ruleset_dealer_; |
487 | 500 |
488 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactoryTest); | 501 DISALLOW_COPY_AND_ASSIGN(ContentSubresourceFilterDriverFactoryTest); |
489 }; | 502 }; |
(...skipping 27 matching lines...) Expand all Loading... |
517 public: | 530 public: |
518 ContentSubresourceFilterDriverFactoryActivationLevelTest() {} | 531 ContentSubresourceFilterDriverFactoryActivationLevelTest() {} |
519 ~ContentSubresourceFilterDriverFactoryActivationLevelTest() override {} | 532 ~ContentSubresourceFilterDriverFactoryActivationLevelTest() override {} |
520 | 533 |
521 private: | 534 private: |
522 DISALLOW_COPY_AND_ASSIGN( | 535 DISALLOW_COPY_AND_ASSIGN( |
523 ContentSubresourceFilterDriverFactoryActivationLevelTest); | 536 ContentSubresourceFilterDriverFactoryActivationLevelTest); |
524 }; | 537 }; |
525 | 538 |
526 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 539 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
527 ActivateForFrameHostDisabledFeature) { | 540 NoActivationWhenActivationLevelIsDisabled) { |
528 // Activation scope is set to NONE => no activation should happen even if URL | 541 Configuration config(ActivationLevel::DISABLED, |
529 // which is visited was a SB hit. | 542 ActivationScope::ACTIVATION_LIST, |
530 base::FieldTrialList field_trial_list(nullptr); | 543 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL); |
531 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 544 config.activation_level = ActivationLevel::DISABLED; |
532 base::FeatureList::OVERRIDE_DISABLE_FEATURE, kActivationLevelEnabled, | 545 ResetConfiguration(std::move(config)); |
533 kActivationScopeAllSites, | 546 |
534 kActivationListSocialEngineeringAdsInterstitial); | |
535 const GURL url(kExampleUrlWithParams); | 547 const GURL url(kExampleUrlWithParams); |
536 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 548 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, |
537 ActivationDecision::ACTIVATION_DISABLED); | 549 ActivationDecision::ACTIVATION_DISABLED); |
538 factory()->client()->WhitelistInCurrentWebContents(url); | 550 factory()->client()->WhitelistInCurrentWebContents(url); |
539 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 551 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, |
540 ActivationDecision::ACTIVATION_DISABLED); | 552 ActivationDecision::ACTIVATION_DISABLED); |
541 } | 553 } |
542 | 554 |
543 TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) { | 555 TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) { |
544 base::FieldTrialList field_trial_list(nullptr); | |
545 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
546 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
547 kActivationScopeActivationList, | |
548 kActivationListSocialEngineeringAdsInterstitial); | |
549 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, | 556 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, |
550 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); | 557 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
551 } | 558 } |
552 | 559 |
553 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 560 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
554 SpecialCaseNavigationAllSitesEnabled) { | 561 SpecialCaseNavigationAllSitesEnabled) { |
555 // Check that when the experiment is enabled for all site, the activation | 562 // Check that when the experiment is enabled for all site, the activation |
556 // signal is always sent. | 563 // signal is always sent. |
557 base::FieldTrialList field_trial_list(nullptr); | 564 ResetConfigurationToEnableFilteringOnAllSites(); |
558 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
559 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
560 kActivationScopeAllSites); | |
561 EmulateInPageNavigation({false}, EMPTY, ActivationDecision::ACTIVATED); | 565 EmulateInPageNavigation({false}, EMPTY, ActivationDecision::ACTIVATED); |
562 } | 566 } |
563 | 567 |
564 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 568 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
565 SpecialCaseNavigationActivationListEnabled) { | 569 SpecialCaseNavigationActivationListEnabled) { |
566 base::FieldTrialList field_trial_list(nullptr); | |
567 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
568 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
569 kActivationScopeActivationList, | |
570 kActivationListSocialEngineeringAdsInterstitial); | |
571 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, | 570 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, |
572 ActivationDecision::ACTIVATED); | 571 ActivationDecision::ACTIVATED); |
573 } | 572 } |
574 | 573 |
575 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 574 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
576 SpecialCaseNavigationActivationListEnabledWithPerformanceMeasurement) { | 575 SpecialCaseNavigationActivationListEnabledWithPerformanceMeasurement) { |
577 base::FieldTrialList field_trial_list(nullptr); | 576 Configuration config(ActivationLevel::ENABLED, |
578 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 577 ActivationScope::ACTIVATION_LIST, |
579 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 578 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL); |
580 kActivationScopeActivationList, | 579 config.performance_measurement_rate = 1.0; |
581 kActivationListSocialEngineeringAdsInterstitial, | 580 ResetConfiguration(std::move(config)); |
582 "1" /* performance_measurement_rate */); | 581 |
583 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, | 582 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, |
584 ActivationDecision::ACTIVATED); | 583 ActivationDecision::ACTIVATED); |
585 } | 584 } |
586 | 585 |
587 TEST_F(ContentSubresourceFilterDriverFactoryTest, FailedNavigation) { | 586 TEST_F(ContentSubresourceFilterDriverFactoryTest, FailedNavigation) { |
588 base::FieldTrialList field_trial_list(nullptr); | |
589 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
590 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
591 kActivationScopeAllSites); | |
592 const GURL url(kExampleUrl); | 587 const GURL url(kExampleUrl); |
| 588 ResetConfigurationToEnableFilteringOnAllSites(); |
593 NavigateAndExpectActivation({false}, {url}, EMPTY, | 589 NavigateAndExpectActivation({false}, {url}, EMPTY, |
594 ActivationDecision::ACTIVATED); | 590 ActivationDecision::ACTIVATED); |
595 EmulateFailedNavigationAndExpectNoActivation(url); | 591 EmulateFailedNavigationAndExpectNoActivation(url); |
596 } | 592 } |
597 | 593 |
598 // TODO(melandory): refactor the test so it no longer require the current | 594 // TODO(melandory): refactor the test so it no longer require the current |
599 // activation list to be matching. | 595 // activation list to be matching. |
600 TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { | 596 TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { |
601 base::FieldTrialList field_trial_list(nullptr); | |
602 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
603 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
604 kActivationScopeActivationList, | |
605 kActivationListSocialEngineeringAdsInterstitial); | |
606 struct RedirectRedirectChainMatchPatternTestData { | 597 struct RedirectRedirectChainMatchPatternTestData { |
607 std::vector<bool> blacklisted_urls; | 598 std::vector<bool> blacklisted_urls; |
608 std::vector<GURL> navigation_chain; | 599 std::vector<GURL> navigation_chain; |
609 RedirectChainMatchPattern hit_expected_pattern; | 600 RedirectChainMatchPattern hit_expected_pattern; |
610 ActivationDecision expected_activation_decision; | 601 ActivationDecision expected_activation_decision; |
611 } kRedirectRedirectChainMatchPatternTestData[] = { | 602 } kRedirectRedirectChainMatchPatternTestData[] = { |
612 {{false}, | 603 {{false}, |
613 {GURL(kUrlA)}, | 604 {GURL(kUrlA)}, |
614 EMPTY, | 605 EMPTY, |
615 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 606 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
685 test_data.blacklisted_urls, test_data.navigation_chain, | 676 test_data.blacklisted_urls, test_data.navigation_chain, |
686 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, | 677 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, |
687 safe_browsing::ThreatPatternType::NONE, content::Referrer(), | 678 safe_browsing::ThreatPatternType::NONE, content::Referrer(), |
688 ui::PAGE_TRANSITION_LINK, test_data.hit_expected_pattern, | 679 ui::PAGE_TRANSITION_LINK, test_data.hit_expected_pattern, |
689 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); | 680 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
690 #endif | 681 #endif |
691 } | 682 } |
692 } | 683 } |
693 | 684 |
694 TEST_F(ContentSubresourceFilterDriverFactoryTest, NotificationVisibility) { | 685 TEST_F(ContentSubresourceFilterDriverFactoryTest, NotificationVisibility) { |
695 base::FieldTrialList field_trial_list(nullptr); | 686 ResetConfigurationToEnableFilteringOnAllSites(); |
696 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | |
697 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | |
698 kActivationScopeAllSites); | |
699 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, | 687 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, |
700 ActivationDecision::ACTIVATED); | 688 ActivationDecision::ACTIVATED); |
701 EXPECT_CALL(*client(), ToggleNotificationVisibility(true)).Times(1); | 689 EXPECT_CALL(*client(), ToggleNotificationVisibility(true)).Times(1); |
702 NavigateSubframeAndExpectCheckResult(GURL(kDisallowedUrl), | 690 NavigateSubframeAndExpectCheckResult(GURL(kDisallowedUrl), |
703 true /* expect_cancelled */); | 691 true /* expect_cancelled */); |
704 } | 692 } |
705 | 693 |
706 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 694 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
707 SuppressNotificationVisibility) { | 695 SuppressNotificationVisibility) { |
708 base::FieldTrialList field_trial_list(nullptr); | 696 Configuration config(ActivationLevel::ENABLED, ActivationScope::ALL_SITES); |
709 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 697 config.should_suppress_notifications = true; |
710 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 698 ResetConfiguration(std::move(config)); |
711 kActivationScopeAllSites, "" /* activation_lists */, | |
712 "" /* performance_measurement_rate */, | |
713 "true" /* suppress_notifications */); | |
714 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, | 699 NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY, |
715 ActivationDecision::ACTIVATED); | 700 ActivationDecision::ACTIVATED); |
716 EXPECT_CALL(*client(), ToggleNotificationVisibility(::testing::_)).Times(0); | 701 EXPECT_CALL(*client(), ToggleNotificationVisibility(::testing::_)).Times(0); |
717 NavigateSubframeAndExpectCheckResult(GURL(kDisallowedUrl), | 702 NavigateSubframeAndExpectCheckResult(GURL(kDisallowedUrl), |
718 true /* expect_cancelled */); | 703 true /* expect_cancelled */); |
719 } | 704 } |
720 | 705 |
721 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 706 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
722 InactiveMainFrame_SubframeNotFiltered) { | 707 InactiveMainFrame_SubframeNotFiltered) { |
723 GURL url(kExampleUrl); | 708 GURL url(kExampleUrl); |
| 709 Configuration config(ActivationLevel::DISABLED, ActivationScope::ALL_SITES); |
| 710 ResetConfiguration(std::move(config)); |
724 NavigateAndExpectActivation({false}, {url}, EMPTY, | 711 NavigateAndExpectActivation({false}, {url}, EMPTY, |
725 ActivationDecision::ACTIVATION_DISABLED); | 712 ActivationDecision::ACTIVATION_DISABLED); |
726 NavigateSubframeAndExpectCheckResult(url, false /* expect_cancelled */); | 713 NavigateSubframeAndExpectCheckResult(url, false /* expect_cancelled */); |
727 } | 714 } |
728 | 715 |
729 TEST_F(ContentSubresourceFilterDriverFactoryTest, WhitelistSiteOnReload) { | 716 TEST_F(ContentSubresourceFilterDriverFactoryTest, WhitelistSiteOnReload) { |
730 const struct { | 717 const struct { |
731 content::Referrer referrer; | 718 content::Referrer referrer; |
732 ui::PageTransition transition; | 719 ui::PageTransition transition; |
733 ActivationDecision expected_activation_decision; | 720 ActivationDecision expected_activation_decision; |
734 } kTestCases[] = { | 721 } kTestCases[] = { |
735 {content::Referrer(), ui::PAGE_TRANSITION_LINK, | 722 {content::Referrer(), ui::PAGE_TRANSITION_LINK, |
736 ActivationDecision::ACTIVATED}, | 723 ActivationDecision::ACTIVATED}, |
737 {content::Referrer(GURL(kUrlA), blink::kWebReferrerPolicyDefault), | 724 {content::Referrer(GURL(kUrlA), blink::kWebReferrerPolicyDefault), |
738 ui::PAGE_TRANSITION_LINK, ActivationDecision::ACTIVATED}, | 725 ui::PAGE_TRANSITION_LINK, ActivationDecision::ACTIVATED}, |
739 {content::Referrer(GURL(kExampleUrl), blink::kWebReferrerPolicyDefault), | 726 {content::Referrer(GURL(kExampleUrl), blink::kWebReferrerPolicyDefault), |
740 ui::PAGE_TRANSITION_LINK, ActivationDecision::URL_WHITELISTED}, | 727 ui::PAGE_TRANSITION_LINK, ActivationDecision::URL_WHITELISTED}, |
741 {content::Referrer(), ui::PAGE_TRANSITION_RELOAD, | 728 {content::Referrer(), ui::PAGE_TRANSITION_RELOAD, |
742 ActivationDecision::URL_WHITELISTED}}; | 729 ActivationDecision::URL_WHITELISTED}}; |
743 | 730 |
744 for (const auto& test_case : kTestCases) { | 731 for (const auto& test_case : kTestCases) { |
745 SCOPED_TRACE(::testing::Message("referrer = \"") | 732 SCOPED_TRACE(::testing::Message("referrer = \"") |
746 << test_case.referrer.url << "\"" | 733 << test_case.referrer.url << "\"" |
747 << " transition = \"" << test_case.transition << "\""); | 734 << " transition = \"" << test_case.transition << "\""); |
748 | 735 |
749 base::FieldTrialList field_trial_list(nullptr); | 736 Configuration config(ActivationLevel::ENABLED, ActivationScope::ALL_SITES); |
750 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 737 config.should_whitelist_site_on_reload = true; |
751 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 738 ResetConfiguration(std::move(config)); |
752 kActivationScopeAllSites, "" /* activation_lists */, | |
753 "" /* performance_measurement_rate */, "" /* suppress_notifications */, | |
754 "true" /* whitelist_site_on_reload */); | |
755 | 739 |
756 NavigateAndExpectActivation( | 740 NavigateAndExpectActivation( |
757 {false}, {GURL(kExampleUrl)}, | 741 {false}, {GURL(kExampleUrl)}, |
758 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 742 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
759 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, | 743 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
760 test_case.referrer, test_case.transition, EMPTY, | 744 test_case.referrer, test_case.transition, EMPTY, |
761 test_case.expected_activation_decision); | 745 test_case.expected_activation_decision); |
762 // Verify that if the first URL failed to activate, subsequent same-origin | 746 // Verify that if the first URL failed to activate, subsequent same-origin |
763 // navigations also fail to activate. | 747 // navigations also fail to activate. |
764 NavigateAndExpectActivation({false}, {GURL(kExampleUrlWithParams)}, EMPTY, | 748 NavigateAndExpectActivation({false}, {GURL(kExampleUrlWithParams)}, EMPTY, |
765 test_case.expected_activation_decision); | 749 test_case.expected_activation_decision); |
766 } | 750 } |
767 } | 751 } |
768 | 752 |
769 TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest, | 753 TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest, |
770 ActivateForFrameState) { | 754 ActivateForFrameState) { |
771 const ActivationLevelTestData& test_data = GetParam(); | 755 const ActivationLevelTestData& test_data = GetParam(); |
772 base::FieldTrialList field_trial_list(nullptr); | 756 ResetConfiguration(Configuration( |
773 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 757 test_data.activation_level, ActivationScope::ACTIVATION_LIST, |
774 base::FeatureList::OVERRIDE_ENABLE_FEATURE, test_data.activation_level, | 758 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
775 kActivationScopeActivationList, | |
776 kActivationListSocialEngineeringAdsInterstitial); | |
777 | 759 |
778 const GURL url(kExampleUrlWithParams); | 760 const GURL url(kExampleUrlWithParams); |
779 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 761 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, |
780 test_data.expected_activation_decision); | 762 test_data.expected_activation_decision); |
781 factory()->client()->WhitelistInCurrentWebContents(url); | 763 factory()->client()->WhitelistInCurrentWebContents(url); |
782 NavigateAndExpectActivation( | 764 NavigateAndExpectActivation( |
783 {true}, {GURL(kExampleUrlWithParams)}, NO_REDIRECTS_HIT, | 765 {true}, {GURL(kExampleUrlWithParams)}, NO_REDIRECTS_HIT, |
784 GetActiveConfigurations()->the_one_and_only().activation_level == | 766 GetActiveConfigurations()->the_one_and_only().activation_level == |
785 ActivationLevel::DISABLED | 767 ActivationLevel::DISABLED |
786 ? ActivationDecision::ACTIVATION_DISABLED | 768 ? ActivationDecision::ACTIVATION_DISABLED |
787 : ActivationDecision::URL_WHITELISTED); | 769 : ActivationDecision::URL_WHITELISTED); |
788 } | 770 } |
789 | 771 |
790 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, | 772 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, |
791 ActivateForTheListType) { | 773 ActivateForTheListType) { |
792 // Sets up the experiment in a way that the activation decision depends on the | 774 // Sets up the experiment in a way that the activation decision depends on the |
793 // list for which the Safe Browsing hit has happened. | 775 // list for which the Safe Browsing hit has happened. |
794 const ActivationListTestData& test_data = GetParam(); | 776 const ActivationListTestData& test_data = GetParam(); |
795 base::FieldTrialList field_trial_list(nullptr); | 777 ResetConfiguration(Configuration(ActivationLevel::ENABLED, |
796 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 778 ActivationScope::ACTIVATION_LIST, |
797 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 779 test_data.activation_list)); |
798 kActivationScopeActivationList, test_data.activation_list); | |
799 | 780 |
800 const GURL test_url("https://example.com/nonsoceng?q=engsocnon"); | 781 const GURL test_url("https://example.com/nonsoceng?q=engsocnon"); |
801 std::vector<GURL> navigation_chain; | 782 std::vector<GURL> navigation_chain; |
802 | 783 |
803 ActivationList effective_list = GetListForThreatTypeAndMetadata( | 784 ActivationList effective_list = GetListForThreatTypeAndMetadata( |
804 test_data.threat_type, test_data.threat_type_metadata); | 785 test_data.threat_type, test_data.threat_type_metadata); |
805 NavigateAndExpectActivation( | 786 NavigateAndExpectActivation( |
806 {false, false, false, true}, | 787 {false, false, false, true}, |
807 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type, | 788 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type, |
808 test_data.threat_type_metadata, content::Referrer(), | 789 test_data.threat_type_metadata, content::Referrer(), |
809 ui::PAGE_TRANSITION_LINK, | 790 ui::PAGE_TRANSITION_LINK, |
810 effective_list != ActivationList::NONE ? F0M0L1 : EMPTY, | 791 effective_list != ActivationList::NONE ? F0M0L1 : EMPTY, |
811 test_data.expected_activation_decision); | 792 test_data.expected_activation_decision); |
812 }; | 793 }; |
813 | 794 |
814 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, | 795 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, |
815 ActivateForScopeType) { | 796 ActivateForScopeType) { |
816 const ActivationScopeTestData& test_data = GetParam(); | 797 const ActivationScopeTestData& test_data = GetParam(); |
817 base::FieldTrialList field_trial_list(nullptr); | 798 ResetConfiguration( |
818 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 799 Configuration(ActivationLevel::ENABLED, test_data.activation_scope, |
819 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 800 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
820 test_data.activation_scope, | |
821 kActivationListSocialEngineeringAdsInterstitial); | |
822 | 801 |
823 const GURL test_url(kExampleUrlWithParams); | 802 const GURL test_url(kExampleUrlWithParams); |
824 | 803 |
825 RedirectChainMatchPattern expected_pattern = | 804 RedirectChainMatchPattern expected_pattern = |
826 test_data.url_matches_activation_list ? NO_REDIRECTS_HIT : EMPTY; | 805 test_data.url_matches_activation_list ? NO_REDIRECTS_HIT : EMPTY; |
827 NavigateAndExpectActivation({test_data.url_matches_activation_list}, | 806 NavigateAndExpectActivation({test_data.url_matches_activation_list}, |
828 {test_url}, expected_pattern, | 807 {test_url}, expected_pattern, |
829 test_data.expected_activation_decision); | 808 test_data.expected_activation_decision); |
830 if (test_data.url_matches_activation_list) { | 809 if (test_data.url_matches_activation_list) { |
831 factory()->client()->WhitelistInCurrentWebContents(test_url); | 810 factory()->client()->WhitelistInCurrentWebContents(test_url); |
832 NavigateAndExpectActivation( | 811 NavigateAndExpectActivation( |
833 {test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)}, | 812 {test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)}, |
834 expected_pattern, | 813 expected_pattern, |
835 GetActiveConfigurations()->the_one_and_only().activation_scope == | 814 GetActiveConfigurations()->the_one_and_only().activation_scope == |
836 ActivationScope::NO_SITES | 815 ActivationScope::NO_SITES |
837 ? ActivationDecision::ACTIVATION_DISABLED | 816 ? ActivationDecision::ACTIVATION_DISABLED |
838 : ActivationDecision::URL_WHITELISTED); | 817 : ActivationDecision::URL_WHITELISTED); |
839 } | 818 } |
840 }; | 819 }; |
841 | 820 |
842 // Only main frames with http/https schemes should activate, unless the | 821 // Only main frames with http/https schemes should activate, unless the |
843 // activation scope is for all sites. | 822 // activation scope is for all sites. |
844 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, | 823 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, |
845 ActivateForSupportedUrlScheme) { | 824 ActivateForSupportedUrlScheme) { |
846 const ActivationScopeTestData& test_data = GetParam(); | 825 const ActivationScopeTestData& test_data = GetParam(); |
847 base::FieldTrialList field_trial_list(nullptr); | 826 ResetConfiguration( |
848 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 827 Configuration(ActivationLevel::ENABLED, test_data.activation_scope, |
849 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 828 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL)); |
850 test_data.activation_scope, | |
851 kActivationListSocialEngineeringAdsInterstitial); | |
852 | 829 |
853 // data URLs are also not supported, but not listed here, as it's not possible | 830 // data URLs are also not supported, but not listed here, as it's not possible |
854 // for a page to redirect to them after https://crbug.com/594215 is fixed. | 831 // for a page to redirect to them after https://crbug.com/594215 is fixed. |
855 const char* unsupported_urls[] = {"ftp://example.com/", "chrome://settings", | 832 const char* unsupported_urls[] = {"ftp://example.com/", "chrome://settings", |
856 "chrome-extension://some-extension", | 833 "chrome-extension://some-extension", |
857 "file:///var/www/index.html"}; | 834 "file:///var/www/index.html"}; |
858 const char* supported_urls[] = {"http://example.test", | 835 const char* supported_urls[] = {"http://example.test", |
859 "https://example.test"}; | 836 "https://example.test"}; |
860 for (auto* url : unsupported_urls) { | 837 for (auto* url : unsupported_urls) { |
861 SCOPED_TRACE(url); | 838 SCOPED_TRACE(url); |
(...skipping 23 matching lines...) Expand all Loading... |
885 ActivationScopeTest, | 862 ActivationScopeTest, |
886 ContentSubresourceFilterDriverFactoryActivationScopeTest, | 863 ContentSubresourceFilterDriverFactoryActivationScopeTest, |
887 ::testing::ValuesIn(kActivationScopeTestData)); | 864 ::testing::ValuesIn(kActivationScopeTestData)); |
888 | 865 |
889 INSTANTIATE_TEST_CASE_P( | 866 INSTANTIATE_TEST_CASE_P( |
890 ActivationLevelTest, | 867 ActivationLevelTest, |
891 ContentSubresourceFilterDriverFactoryActivationLevelTest, | 868 ContentSubresourceFilterDriverFactoryActivationLevelTest, |
892 ::testing::ValuesIn(kActivationLevelTestData)); | 869 ::testing::ValuesIn(kActivationLevelTestData)); |
893 | 870 |
894 } // namespace subresource_filter | 871 } // namespace subresource_filter |
OLD | NEW |