Chromium Code Reviews| 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 "base/macros.h" | 7 #include "base/macros.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 30 matching lines...) Expand all Loading... | |
| 41 const char kExampleUrlWithParams[] = "https://example.com/soceng?q=engsoc"; | 41 const char kExampleUrlWithParams[] = "https://example.com/soceng?q=engsoc"; |
| 42 const char kExampleUrl[] = "https://example.com"; | 42 const char kExampleUrl[] = "https://example.com"; |
| 43 const char kExampleLoginUrl[] = "https://example.com/login"; | 43 const char kExampleLoginUrl[] = "https://example.com/login"; |
| 44 const char kUrlA[] = "https://example_a.com"; | 44 const char kUrlA[] = "https://example_a.com"; |
| 45 const char kUrlB[] = "https://example_b.com"; | 45 const char kUrlB[] = "https://example_b.com"; |
| 46 const char kUrlC[] = "https://example_c.com"; | 46 const char kUrlC[] = "https://example_c.com"; |
| 47 const char kUrlD[] = "https://example_d.com"; | 47 const char kUrlD[] = "https://example_d.com"; |
| 48 const char kSubframeName[] = "Child"; | 48 const char kSubframeName[] = "Child"; |
| 49 const char kDisallowedUrl[] = "https://example.com/disallowed.html"; | 49 const char kDisallowedUrl[] = "https://example.com/disallowed.html"; |
| 50 | 50 |
| 51 const char kMatchesPatternHistogramName[] = | 51 const char kMatchesHistogramName[] = "SubresourceFilter.PageLoad.Match."; |
|
engedy
2017/04/20 11:16:11
How about `SubresourecFilter.PageLoad.FinalURLMatc
melandory
2017/04/25 13:48:13
Done.
| |
| 52 "SubresourceFilter.PageLoad.RedirectChainMatchPattern."; | |
| 53 const char kNavigationChainSize[] = | 52 const char kNavigationChainSize[] = |
| 54 "SubresourceFilter.PageLoad.RedirectChainLength."; | 53 "SubresourceFilter.PageLoad.RedirectChainLength."; |
| 55 | 54 |
| 56 // Human readable representation of expected redirect chain match patterns. | 55 // Enum helps to setup test cases. In future, when checking first URL in the |
| 57 // The explanations for the buckets given for the following redirect chain: | 56 // redirect chain is implemented, the enum will be expanded. |
| 58 // A->B->C->D, where A is initial URL and D is a final URL. | 57 enum RecordHistograms { |
|
engedy
2017/04/20 11:16:11
naming nit: RecordedHistograms
melandory
2017/04/25 13:48:13
Done.
| |
| 59 enum RedirectChainMatchPattern { | 58 EMPTY, |
| 60 EMPTY, // No histograms were recorded. | 59 MATCH, |
| 61 F0M0L1, // D is a Safe Browsing match. | 60 NUM_MATCH_PATTERNS, |
|
engedy
2017/04/20 11:16:11
nit: Never used.
melandory
2017/04/25 13:48:13
Done.
| |
| 62 F0M1L0, // B or C, or both are Safe Browsing matches. | |
| 63 F0M1L1, // B or C, or both and D are Safe Browsing matches. | |
| 64 F1M0L0, // A is Safe Browsing match | |
| 65 F1M0L1, // A and D are Safe Browsing matches. | |
| 66 F1M1L0, // B and/or C and A are Safe Browsing matches. | |
| 67 F1M1L1, // B and/or C and A and D are Safe Browsing matches. | |
| 68 NO_REDIRECTS_HIT, // Redirect chain consists of single URL, aka no redirects | |
| 69 // has happened, and this URL was a Safe Browsing hit. | |
| 70 NUM_HIT_PATTERNS, | |
| 71 }; | 61 }; |
| 72 | 62 |
| 73 std::string GetSuffixForList(const ActivationList& type) { | 63 std::string GetSuffixForList(const ActivationList& type) { |
| 74 switch (type) { | 64 switch (type) { |
| 75 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL: | 65 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL: |
| 76 return "SocialEngineeringAdsInterstitial"; | 66 return "SocialEngineeringAdsInterstitial"; |
| 77 case ActivationList::PHISHING_INTERSTITIAL: | 67 case ActivationList::PHISHING_INTERSTITIAL: |
| 78 return "PhishingInterstital"; | 68 return "PhishingInterstital"; |
| 79 case ActivationList::SUBRESOURCE_FILTER: | 69 case ActivationList::SUBRESOURCE_FILTER: |
| 80 return "SubresourceFilterOnly"; | 70 return "SubresourceFilterOnly"; |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 144 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 134 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 145 safe_browsing::ThreatPatternType::NONE}, | 135 safe_browsing::ThreatPatternType::NONE}, |
| 146 {ActivationDecision::ACTIVATED, | 136 {ActivationDecision::ACTIVATED, |
| 147 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, | 137 subresource_filter::kActivationListSocialEngineeringAdsInterstitial, |
| 148 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 138 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 149 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 139 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
| 150 {ActivationDecision::ACTIVATED, | 140 {ActivationDecision::ACTIVATED, |
| 151 subresource_filter::kActivationListPhishingInterstitial, | 141 subresource_filter::kActivationListPhishingInterstitial, |
| 152 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 142 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 153 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, | 143 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
| 144 {ActivationDecision::ACTIVATED, | |
|
engedy
2017/04/20 11:16:11
Could you please add corresponding NOT_MATCHED tes
| |
| 145 subresource_filter::kActivationListSubresourceFilter, | |
| 146 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, | |
| 147 safe_browsing::ThreatPatternType::NONE}, | |
| 154 }; | 148 }; |
| 155 | 149 |
| 156 struct ActivationScopeTestData { | 150 struct ActivationScopeTestData { |
| 157 ActivationDecision expected_activation_decision; | 151 ActivationDecision expected_activation_decision; |
| 158 bool url_matches_activation_list; | 152 bool url_matches_activation_list; |
| 159 const char* const activation_scope; | 153 const char* const activation_scope; |
| 160 }; | 154 }; |
| 161 | 155 |
| 162 const ActivationScopeTestData kActivationScopeTestData[] = { | 156 const ActivationScopeTestData kActivationScopeTestData[] = { |
| 163 {ActivationDecision::ACTIVATED, false /* url_matches_activation_list */, | 157 {ActivationDecision::ACTIVATED, false /* url_matches_activation_list */, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 282 render_process_host->sink().ClearMessages(); | 276 render_process_host->sink().ClearMessages(); |
| 283 } | 277 } |
| 284 | 278 |
| 285 void BlacklistURLWithRedirectsNavigateAndCommit( | 279 void BlacklistURLWithRedirectsNavigateAndCommit( |
| 286 const std::vector<bool>& blacklisted_urls, | 280 const std::vector<bool>& blacklisted_urls, |
| 287 const std::vector<GURL>& navigation_chain, | 281 const std::vector<GURL>& navigation_chain, |
| 288 safe_browsing::SBThreatType threat_type, | 282 safe_browsing::SBThreatType threat_type, |
| 289 safe_browsing::ThreatPatternType threat_type_metadata, | 283 safe_browsing::ThreatPatternType threat_type_metadata, |
| 290 const content::Referrer& referrer, | 284 const content::Referrer& referrer, |
| 291 ui::PageTransition transition, | 285 ui::PageTransition transition, |
| 292 RedirectChainMatchPattern expected_pattern, | 286 RecordHistograms expected_pattern, |
|
engedy
2017/04/20 11:16:11
nit: expected_histograms
melandory
2017/04/25 13:48:13
Done.
| |
| 293 ActivationDecision expected_activation_decision) { | 287 ActivationDecision expected_activation_decision) { |
| 294 const bool expected_activation = | 288 const bool expected_activation = |
| 295 expected_activation_decision == ActivationDecision::ACTIVATED; | 289 expected_activation_decision == ActivationDecision::ACTIVATED; |
| 296 base::HistogramTester tester; | 290 base::HistogramTester tester; |
| 297 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); | 291 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); |
| 298 | 292 |
| 299 std::unique_ptr<content::NavigationSimulator> navigation_simulator = | 293 std::unique_ptr<content::NavigationSimulator> navigation_simulator = |
| 300 content::NavigationSimulator::CreateRendererInitiated( | 294 content::NavigationSimulator::CreateRendererInitiated( |
| 301 navigation_chain.front(), main_rfh()); | 295 navigation_chain.front(), main_rfh()); |
| 302 navigation_simulator->SetReferrer(referrer); | 296 navigation_simulator->SetReferrer(referrer); |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 326 | 320 |
| 327 // Re-create a subframe now that the frame has navigated. | 321 // Re-create a subframe now that the frame has navigated. |
| 328 content::RenderFrameHostTester* rfh_tester = | 322 content::RenderFrameHostTester* rfh_tester = |
| 329 content::RenderFrameHostTester::For(main_rfh()); | 323 content::RenderFrameHostTester::For(main_rfh()); |
| 330 rfh_tester->AppendChild(kSubframeName); | 324 rfh_tester->AppendChild(kSubframeName); |
| 331 ActivationList activation_list = | 325 ActivationList activation_list = |
| 332 GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata); | 326 GetListForThreatTypeAndMetadata(threat_type, threat_type_metadata); |
| 333 | 327 |
| 334 const std::string suffix(GetSuffixForList(activation_list)); | 328 const std::string suffix(GetSuffixForList(activation_list)); |
| 335 size_t all_pattern = | 329 size_t all_pattern = |
| 336 tester.GetTotalCountsForPrefix(kMatchesPatternHistogramName).size(); | 330 tester.GetTotalCountsForPrefix(kMatchesHistogramName).size(); |
| 337 size_t all_chain_size = | 331 size_t all_chain_size = |
| 338 tester.GetTotalCountsForPrefix(kNavigationChainSize).size(); | 332 tester.GetTotalCountsForPrefix(kNavigationChainSize).size(); |
| 339 if (expected_pattern != EMPTY) { | 333 if (expected_pattern != EMPTY) { |
| 340 EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName + suffix), | 334 tester.ExpectTotalCount(kMatchesHistogramName + suffix, 1); |
|
engedy
2017/04/20 11:16:11
Let's also check that the correct value is recorde
melandory
2017/04/25 13:48:13
Done.
| |
| 341 ::testing::ElementsAre(base::Bucket(expected_pattern, 1))); | 335 tester.ExpectUniqueSample(kNavigationChainSize + suffix, |
| 342 EXPECT_THAT( | 336 navigation_chain.size(), 1); |
| 343 tester.GetAllSamples(kNavigationChainSize + suffix), | |
| 344 ::testing::ElementsAre(base::Bucket(navigation_chain.size(), 1))); | |
| 345 // Check that we recorded only what is needed. | 337 // Check that we recorded only what is needed. |
| 346 EXPECT_EQ(1u, all_pattern); | 338 EXPECT_EQ(1u, all_pattern); |
| 347 EXPECT_EQ(1u, all_chain_size); | 339 EXPECT_EQ(1u, all_chain_size); |
| 348 } else { | 340 } else { |
| 349 EXPECT_EQ(0u, all_pattern); | 341 EXPECT_EQ(0u, all_pattern); |
| 350 EXPECT_EQ(0u, all_chain_size); | 342 EXPECT_EQ(0u, all_chain_size); |
| 351 } | 343 } |
| 352 } | 344 } |
| 353 | 345 |
| 354 void NavigateSubframeAndExpectCheckResult(const GURL& url, | 346 void NavigateSubframeAndExpectCheckResult(const GURL& url, |
| (...skipping 21 matching lines...) Expand all Loading... | |
| 376 ::testing::Mock::VerifyAndClearExpectations(client()); | 368 ::testing::Mock::VerifyAndClearExpectations(client()); |
| 377 } | 369 } |
| 378 | 370 |
| 379 void NavigateAndExpectActivation( | 371 void NavigateAndExpectActivation( |
| 380 const std::vector<bool>& blacklisted_urls, | 372 const std::vector<bool>& blacklisted_urls, |
| 381 const std::vector<GURL>& navigation_chain, | 373 const std::vector<GURL>& navigation_chain, |
| 382 safe_browsing::SBThreatType threat_type, | 374 safe_browsing::SBThreatType threat_type, |
| 383 safe_browsing::ThreatPatternType threat_type_metadata, | 375 safe_browsing::ThreatPatternType threat_type_metadata, |
| 384 const content::Referrer& referrer, | 376 const content::Referrer& referrer, |
| 385 ui::PageTransition transition, | 377 ui::PageTransition transition, |
| 386 RedirectChainMatchPattern expected_pattern, | 378 RecordHistograms expected_pattern, |
| 387 ActivationDecision expected_activation_decision) { | 379 ActivationDecision expected_activation_decision) { |
| 388 const bool expected_activation = | 380 const bool expected_activation = |
| 389 expected_activation_decision == ActivationDecision::ACTIVATED; | 381 expected_activation_decision == ActivationDecision::ACTIVATED; |
| 390 BlacklistURLWithRedirectsNavigateAndCommit( | 382 BlacklistURLWithRedirectsNavigateAndCommit( |
| 391 blacklisted_urls, navigation_chain, threat_type, threat_type_metadata, | 383 blacklisted_urls, navigation_chain, threat_type, threat_type_metadata, |
| 392 referrer, transition, expected_pattern, expected_activation_decision); | 384 referrer, transition, expected_pattern, expected_activation_decision); |
| 393 | 385 |
| 394 NavigateAndCommitSubframe(GURL(kExampleLoginUrl), expected_activation); | 386 NavigateAndCommitSubframe(GURL(kExampleLoginUrl), expected_activation); |
| 395 } | 387 } |
| 396 | 388 |
| 397 void NavigateAndExpectActivation( | 389 void NavigateAndExpectActivation( |
| 398 const std::vector<bool>& blacklisted_urls, | 390 const std::vector<bool>& blacklisted_urls, |
| 399 const std::vector<GURL>& navigation_chain, | 391 const std::vector<GURL>& navigation_chain, |
| 400 RedirectChainMatchPattern expected_pattern, | 392 RecordHistograms expected_pattern, |
| 401 ActivationDecision expected_activation_decision) { | 393 ActivationDecision expected_activation_decision) { |
| 402 NavigateAndExpectActivation( | 394 NavigateAndExpectActivation( |
| 403 blacklisted_urls, navigation_chain, | 395 blacklisted_urls, navigation_chain, |
| 404 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 396 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 405 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, | 397 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
| 406 content::Referrer(), ui::PAGE_TRANSITION_LINK, expected_pattern, | 398 content::Referrer(), ui::PAGE_TRANSITION_LINK, expected_pattern, |
| 407 expected_activation_decision); | 399 expected_activation_decision); |
| 408 } | 400 } |
| 409 | 401 |
| 410 void EmulateFailedNavigationAndExpectNoActivation(const GURL& url) { | 402 void EmulateFailedNavigationAndExpectNoActivation(const GURL& url) { |
| 411 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); | 403 EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); |
| 412 | 404 |
| 413 // With browser-side navigation enabled, ReadyToCommitNavigation is invoked | 405 // With browser-side navigation enabled, ReadyToCommitNavigation is invoked |
| 414 // even for failed navigations. This is correctly simulated by | 406 // even for failed navigations. This is correctly simulated by |
| 415 // NavigationSimulator. Make sure no activation message is sent in this | 407 // NavigationSimulator. Make sure no activation message is sent in this |
| 416 // case. | 408 // case. |
| 417 content::NavigationSimulator::NavigateAndFailFromDocument( | 409 content::NavigationSimulator::NavigateAndFailFromDocument( |
| 418 url, net::ERR_TIMED_OUT, main_rfh()); | 410 url, net::ERR_TIMED_OUT, main_rfh()); |
| 419 ExpectActivationSignalForFrame(main_rfh(), false); | 411 ExpectActivationSignalForFrame(main_rfh(), false); |
| 420 ::testing::Mock::VerifyAndClearExpectations(client()); | 412 ::testing::Mock::VerifyAndClearExpectations(client()); |
| 421 } | 413 } |
| 422 | 414 |
| 423 void EmulateInPageNavigation( | 415 void EmulateInPageNavigation( |
| 424 const std::vector<bool>& blacklisted_urls, | 416 const std::vector<bool>& blacklisted_urls, |
| 425 RedirectChainMatchPattern expected_pattern, | 417 RecordHistograms expected_pattern, |
| 426 ActivationDecision expected_activation_decision) { | 418 ActivationDecision expected_activation_decision) { |
| 427 // This test examines the navigation with the following sequence of events: | 419 // This test examines the navigation with the following sequence of events: |
| 428 // DidStartProvisional(main, "example.com") | 420 // DidStartProvisional(main, "example.com") |
| 429 // ReadyToCommitNavigation(“example.com”) | 421 // ReadyToCommitNavigation(“example.com”) |
| 430 // DidCommitProvisional(main, "example.com") | 422 // DidCommitProvisional(main, "example.com") |
| 431 // DidStartProvisional(sub, "example.com/login") | 423 // DidStartProvisional(sub, "example.com/login") |
| 432 // DidCommitProvisional(sub, "example.com/login") | 424 // DidCommitProvisional(sub, "example.com/login") |
| 433 // DidCommitProvisional(main, "example.com#ref") | 425 // DidCommitProvisional(main, "example.com#ref") |
| 434 | 426 |
| 435 NavigateAndExpectActivation(blacklisted_urls, {GURL(kExampleUrl)}, | 427 NavigateAndExpectActivation(blacklisted_urls, {GURL(kExampleUrl)}, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 ActivateForFrameHostDisabledFeature) { | 507 ActivateForFrameHostDisabledFeature) { |
| 516 // Activation scope is set to NONE => no activation should happen even if URL | 508 // Activation scope is set to NONE => no activation should happen even if URL |
| 517 // which is visited was a SB hit. | 509 // which is visited was a SB hit. |
| 518 base::FieldTrialList field_trial_list(nullptr); | 510 base::FieldTrialList field_trial_list(nullptr); |
| 519 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 511 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 520 base::FeatureList::OVERRIDE_DISABLE_FEATURE, kActivationLevelEnabled, | 512 base::FeatureList::OVERRIDE_DISABLE_FEATURE, kActivationLevelEnabled, |
| 521 kActivationScopeAllSites, | 513 kActivationScopeAllSites, |
| 522 kActivationListSocialEngineeringAdsInterstitial); | 514 kActivationListSocialEngineeringAdsInterstitial); |
| 523 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 515 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 524 const GURL url(kExampleUrlWithParams); | 516 const GURL url(kExampleUrlWithParams); |
| 525 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 517 NavigateAndExpectActivation({true}, {url}, MATCH, |
| 526 ActivationDecision::ACTIVATION_DISABLED); | 518 ActivationDecision::ACTIVATION_DISABLED); |
| 527 factory()->AddHostOfURLToWhitelistSet(url); | 519 factory()->AddHostOfURLToWhitelistSet(url); |
| 528 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 520 NavigateAndExpectActivation({true}, {url}, MATCH, |
| 529 ActivationDecision::ACTIVATION_DISABLED); | 521 ActivationDecision::ACTIVATION_DISABLED); |
| 530 } | 522 } |
| 531 | 523 |
| 532 TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) { | 524 TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) { |
| 533 base::FieldTrialList field_trial_list(nullptr); | 525 base::FieldTrialList field_trial_list(nullptr); |
| 534 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 526 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 535 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 527 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 536 kActivationScopeActivationList, | 528 kActivationScopeActivationList, |
| 537 kActivationListSocialEngineeringAdsInterstitial); | 529 kActivationListSocialEngineeringAdsInterstitial); |
| 538 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 530 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 553 } | 545 } |
| 554 | 546 |
| 555 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 547 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
| 556 SpecialCaseNavigationActivationListEnabled) { | 548 SpecialCaseNavigationActivationListEnabled) { |
| 557 base::FieldTrialList field_trial_list(nullptr); | 549 base::FieldTrialList field_trial_list(nullptr); |
| 558 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 550 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 559 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 551 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 560 kActivationScopeActivationList, | 552 kActivationScopeActivationList, |
| 561 kActivationListSocialEngineeringAdsInterstitial); | 553 kActivationListSocialEngineeringAdsInterstitial); |
| 562 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 554 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 563 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, | 555 EmulateInPageNavigation({true}, MATCH, ActivationDecision::ACTIVATED); |
| 564 ActivationDecision::ACTIVATED); | |
| 565 } | 556 } |
| 566 | 557 |
| 567 TEST_F(ContentSubresourceFilterDriverFactoryTest, | 558 TEST_F(ContentSubresourceFilterDriverFactoryTest, |
| 568 SpecialCaseNavigationActivationListEnabledWithPerformanceMeasurement) { | 559 SpecialCaseNavigationActivationListEnabledWithPerformanceMeasurement) { |
| 569 base::FieldTrialList field_trial_list(nullptr); | 560 base::FieldTrialList field_trial_list(nullptr); |
| 570 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 561 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 571 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 562 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 572 kActivationScopeActivationList, | 563 kActivationScopeActivationList, |
| 573 kActivationListSocialEngineeringAdsInterstitial, | 564 kActivationListSocialEngineeringAdsInterstitial, |
| 574 "1" /* performance_measurement_rate */); | 565 "1" /* performance_measurement_rate */); |
| 575 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 566 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 576 EmulateInPageNavigation({true}, NO_REDIRECTS_HIT, | 567 EmulateInPageNavigation({true}, MATCH, ActivationDecision::ACTIVATED); |
| 577 ActivationDecision::ACTIVATED); | |
| 578 } | 568 } |
| 579 | 569 |
| 580 TEST_F(ContentSubresourceFilterDriverFactoryTest, FailedNavigation) { | 570 TEST_F(ContentSubresourceFilterDriverFactoryTest, FailedNavigation) { |
| 581 base::FieldTrialList field_trial_list(nullptr); | 571 base::FieldTrialList field_trial_list(nullptr); |
| 582 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 572 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 583 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 573 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 584 kActivationScopeAllSites); | 574 kActivationScopeAllSites); |
| 585 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 575 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 586 const GURL url(kExampleUrl); | 576 const GURL url(kExampleUrl); |
| 587 NavigateAndExpectActivation({false}, {url}, EMPTY, | 577 NavigateAndExpectActivation({false}, {url}, EMPTY, |
| 588 ActivationDecision::ACTIVATED); | 578 ActivationDecision::ACTIVATED); |
| 589 EmulateFailedNavigationAndExpectNoActivation(url); | 579 EmulateFailedNavigationAndExpectNoActivation(url); |
| 590 } | 580 } |
| 591 | 581 |
| 592 // TODO(melandory): refactor the test so it no longer require the current | 582 // TODO(melandory): refactor the test so it no longer require the current |
| 593 // activation list to be matching. | 583 // activation list to be matching. |
| 594 TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { | 584 TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { |
| 595 base::FieldTrialList field_trial_list(nullptr); | 585 base::FieldTrialList field_trial_list(nullptr); |
| 596 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 586 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 597 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 587 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 598 kActivationScopeActivationList, | 588 kActivationScopeActivationList, |
| 599 kActivationListSocialEngineeringAdsInterstitial); | 589 kActivationListSocialEngineeringAdsInterstitial); |
| 600 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 590 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 601 struct RedirectRedirectChainMatchPatternTestData { | 591 struct RedirectRecordHistogramsTestData { |
| 602 std::vector<bool> blacklisted_urls; | 592 std::vector<bool> blacklisted_urls; |
| 603 std::vector<GURL> navigation_chain; | 593 std::vector<GURL> navigation_chain; |
| 604 RedirectChainMatchPattern hit_expected_pattern; | 594 RecordHistograms hit_expected_pattern; |
| 605 ActivationDecision expected_activation_decision; | 595 ActivationDecision expected_activation_decision; |
| 606 } kRedirectRedirectChainMatchPatternTestData[] = { | 596 } kRedirectRecordHistogramsTestData[] = { |
| 607 {{false}, | 597 {{false}, |
| 608 {GURL(kUrlA)}, | 598 {GURL(kUrlA)}, |
| 609 EMPTY, | 599 EMPTY, |
| 610 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 600 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 611 {{true}, {GURL(kUrlA)}, NO_REDIRECTS_HIT, ActivationDecision::ACTIVATED}, | 601 {{true}, {GURL(kUrlA)}, MATCH, ActivationDecision::ACTIVATED}, |
| 612 {{false, false}, | 602 {{false, false}, |
| 613 {GURL(kUrlA), GURL(kUrlB)}, | 603 {GURL(kUrlA), GURL(kUrlB)}, |
| 614 EMPTY, | 604 EMPTY, |
| 615 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 605 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 616 {{false, true}, | 606 {{false, true}, |
| 617 {GURL(kUrlA), GURL(kUrlB)}, | 607 {GURL(kUrlA), GURL(kUrlB)}, |
| 618 F0M0L1, | 608 MATCH, |
| 619 ActivationDecision::ACTIVATED}, | 609 ActivationDecision::ACTIVATED}, |
| 620 {{true, false}, | 610 {{true, false}, |
| 621 {GURL(kUrlA), GURL(kUrlB)}, | 611 {GURL(kUrlA), GURL(kUrlB)}, |
| 622 F1M0L0, | 612 EMPTY, |
| 623 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 613 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 624 {{true, true}, | 614 {{true, true}, |
| 625 {GURL(kUrlA), GURL(kUrlB)}, | 615 {GURL(kUrlA), GURL(kUrlB)}, |
| 626 F1M0L1, | 616 MATCH, |
| 627 ActivationDecision::ACTIVATED}, | 617 ActivationDecision::ACTIVATED}, |
| 628 {{false, false, false}, | 618 {{false, false, false}, |
| 629 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 619 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 630 EMPTY, | 620 EMPTY, |
| 631 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 621 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 632 {{false, false, true}, | 622 {{false, false, true}, |
| 633 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 623 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 634 F0M0L1, | 624 MATCH, |
| 635 ActivationDecision::ACTIVATED}, | 625 ActivationDecision::ACTIVATED}, |
| 636 {{false, true, false}, | 626 {{false, true, false}, |
| 637 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 627 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 638 F0M1L0, | 628 EMPTY, |
| 639 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 629 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 640 {{false, true, true}, | 630 {{false, true, true}, |
| 641 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 631 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 642 F0M1L1, | 632 MATCH, |
| 643 ActivationDecision::ACTIVATED}, | 633 ActivationDecision::ACTIVATED}, |
| 644 {{true, false, false}, | 634 {{true, false, false}, |
| 645 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 635 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 646 F1M0L0, | 636 EMPTY, |
| 647 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 637 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 648 {{true, false, true}, | 638 {{true, false, true}, |
| 649 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 639 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 650 F1M0L1, | 640 MATCH, |
| 651 ActivationDecision::ACTIVATED}, | 641 ActivationDecision::ACTIVATED}, |
| 652 {{true, true, false}, | 642 {{true, true, false}, |
| 653 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 643 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 654 F1M1L0, | 644 EMPTY, |
| 655 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 645 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 656 {{true, true, true}, | 646 {{true, true, true}, |
| 657 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, | 647 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
| 658 F1M1L1, | 648 MATCH, |
| 659 ActivationDecision::ACTIVATED}, | 649 ActivationDecision::ACTIVATED}, |
| 660 {{false, true, false, false}, | 650 {{false, true, false, false}, |
| 661 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), GURL(kUrlD)}, | 651 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), GURL(kUrlD)}, |
| 662 F0M1L0, | 652 EMPTY, |
| 663 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, | 653 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED}, |
| 664 }; | 654 }; |
| 665 | 655 |
| 666 for (size_t i = 0U; i < arraysize(kRedirectRedirectChainMatchPatternTestData); | 656 for (size_t i = 0U; i < arraysize(kRedirectRecordHistogramsTestData); ++i) { |
|
engedy
2017/04/20 11:16:11
nit: If you are already changing this line, could
| |
| 667 ++i) { | 657 auto test_data = kRedirectRecordHistogramsTestData[i]; |
| 668 auto test_data = kRedirectRedirectChainMatchPatternTestData[i]; | |
| 669 NavigateAndExpectActivation( | 658 NavigateAndExpectActivation( |
| 670 test_data.blacklisted_urls, test_data.navigation_chain, | 659 test_data.blacklisted_urls, test_data.navigation_chain, |
| 671 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, | 660 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 672 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, | 661 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
| 673 content::Referrer(), ui::PAGE_TRANSITION_LINK, | 662 content::Referrer(), ui::PAGE_TRANSITION_LINK, |
| 674 test_data.hit_expected_pattern, test_data.expected_activation_decision); | 663 test_data.hit_expected_pattern, test_data.expected_activation_decision); |
| 675 NavigateAndExpectActivation( | 664 NavigateAndExpectActivation( |
| 676 {false}, {GURL("https://dummy.com")}, EMPTY, | 665 {false}, {GURL("https://dummy.com")}, EMPTY, |
| 677 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); | 666 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
| 678 #if defined(GOOGLE_CHROME_BUILD) | 667 #if defined(GOOGLE_CHROME_BUILD) |
|
engedy
2017/04/20 11:16:11
nit: Do we need this anymore?
melandory
2017/04/25 13:48:13
ditto
| |
| 679 NavigateAndExpectActivation( | 668 NavigateAndExpectActivation( |
| 680 test_data.blacklisted_urls, test_data.navigation_chain, | 669 test_data.blacklisted_urls, test_data.navigation_chain, |
| 681 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, | 670 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, |
| 682 safe_browsing::ThreatPatternType::NONE, content::Referrer(), | 671 safe_browsing::ThreatPatternType::NONE, content::Referrer(), |
| 683 ui::PAGE_TRANSITION_LINK, test_data.hit_expected_pattern, | 672 ui::PAGE_TRANSITION_LINK, test_data.hit_expected_pattern, |
| 684 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); | 673 ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
| 685 #endif | 674 #endif |
| 686 } | 675 } |
| 687 } | 676 } |
| 688 | 677 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 770 ActivateForFrameState) { | 759 ActivateForFrameState) { |
| 771 const ActivationLevelTestData& test_data = GetParam(); | 760 const ActivationLevelTestData& test_data = GetParam(); |
| 772 base::FieldTrialList field_trial_list(nullptr); | 761 base::FieldTrialList field_trial_list(nullptr); |
| 773 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 762 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 774 base::FeatureList::OVERRIDE_ENABLE_FEATURE, test_data.activation_level, | 763 base::FeatureList::OVERRIDE_ENABLE_FEATURE, test_data.activation_level, |
| 775 kActivationScopeActivationList, | 764 kActivationScopeActivationList, |
| 776 kActivationListSocialEngineeringAdsInterstitial); | 765 kActivationListSocialEngineeringAdsInterstitial); |
| 777 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 766 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 778 | 767 |
| 779 const GURL url(kExampleUrlWithParams); | 768 const GURL url(kExampleUrlWithParams); |
| 780 NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, | 769 NavigateAndExpectActivation({true}, {url}, MATCH, |
| 781 test_data.expected_activation_decision); | 770 test_data.expected_activation_decision); |
| 782 factory()->AddHostOfURLToWhitelistSet(url); | 771 factory()->AddHostOfURLToWhitelistSet(url); |
| 783 NavigateAndExpectActivation( | 772 NavigateAndExpectActivation( |
| 784 {true}, {GURL(kExampleUrlWithParams)}, NO_REDIRECTS_HIT, | 773 {true}, {GURL(kExampleUrlWithParams)}, MATCH, |
| 785 GetActiveConfiguration().activation_level == ActivationLevel::DISABLED | 774 GetActiveConfiguration().activation_level == ActivationLevel::DISABLED |
| 786 ? ActivationDecision::ACTIVATION_DISABLED | 775 ? ActivationDecision::ACTIVATION_DISABLED |
| 787 : ActivationDecision::URL_WHITELISTED); | 776 : ActivationDecision::URL_WHITELISTED); |
| 788 } | 777 } |
| 789 | 778 |
| 790 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, | 779 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, |
| 791 ActivateForTheListType) { | 780 ActivateForTheListType) { |
| 792 // Sets up the experiment in a way that the activation decision depends on the | 781 // Sets up the experiment in a way that the activation decision depends on the |
| 793 // list for which the Safe Browsing hit has happened. | 782 // list for which the Safe Browsing hit has happened. |
| 794 const ActivationListTestData& test_data = GetParam(); | 783 const ActivationListTestData& test_data = GetParam(); |
| 795 base::FieldTrialList field_trial_list(nullptr); | 784 base::FieldTrialList field_trial_list(nullptr); |
| 796 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 785 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 797 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 786 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 798 kActivationScopeActivationList, test_data.activation_list); | 787 kActivationScopeActivationList, test_data.activation_list); |
| 799 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 788 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 800 | 789 |
| 801 const GURL test_url("https://example.com/nonsoceng?q=engsocnon"); | 790 const GURL test_url("https://example.com/nonsoceng?q=engsocnon"); |
| 802 std::vector<GURL> navigation_chain; | 791 std::vector<GURL> navigation_chain; |
| 803 | 792 |
| 804 ActivationList effective_list = GetListForThreatTypeAndMetadata( | 793 ActivationList effective_list = GetListForThreatTypeAndMetadata( |
| 805 test_data.threat_type, test_data.threat_type_metadata); | 794 test_data.threat_type, test_data.threat_type_metadata); |
| 806 NavigateAndExpectActivation( | 795 NavigateAndExpectActivation( |
| 807 {false, false, false, true}, | 796 {false, false, false, true}, |
| 808 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type, | 797 {GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type, |
| 809 test_data.threat_type_metadata, content::Referrer(), | 798 test_data.threat_type_metadata, content::Referrer(), |
| 810 ui::PAGE_TRANSITION_LINK, | 799 ui::PAGE_TRANSITION_LINK, |
| 811 effective_list != ActivationList::NONE ? F0M0L1 : EMPTY, | 800 effective_list != ActivationList::NONE ? MATCH : EMPTY, |
| 812 test_data.expected_activation_decision); | 801 test_data.expected_activation_decision); |
| 813 }; | 802 }; |
| 814 | 803 |
| 815 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, | 804 TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, |
| 816 ActivateForScopeType) { | 805 ActivateForScopeType) { |
| 817 const ActivationScopeTestData& test_data = GetParam(); | 806 const ActivationScopeTestData& test_data = GetParam(); |
| 818 base::FieldTrialList field_trial_list(nullptr); | 807 base::FieldTrialList field_trial_list(nullptr); |
| 819 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( | 808 testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle( |
| 820 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 809 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
| 821 test_data.activation_scope, | 810 test_data.activation_scope, |
| 822 kActivationListSocialEngineeringAdsInterstitial); | 811 kActivationListSocialEngineeringAdsInterstitial); |
| 823 factory()->set_configuration_for_testing(GetActiveConfiguration()); | 812 factory()->set_configuration_for_testing(GetActiveConfiguration()); |
| 824 | 813 |
| 825 const GURL test_url(kExampleUrlWithParams); | 814 const GURL test_url(kExampleUrlWithParams); |
| 826 | 815 |
| 827 RedirectChainMatchPattern expected_pattern = | 816 RecordHistograms expected_pattern = |
| 828 test_data.url_matches_activation_list ? NO_REDIRECTS_HIT : EMPTY; | 817 test_data.url_matches_activation_list ? MATCH : EMPTY; |
| 829 NavigateAndExpectActivation({test_data.url_matches_activation_list}, | 818 NavigateAndExpectActivation({test_data.url_matches_activation_list}, |
| 830 {test_url}, expected_pattern, | 819 {test_url}, expected_pattern, |
| 831 test_data.expected_activation_decision); | 820 test_data.expected_activation_decision); |
| 832 if (test_data.url_matches_activation_list) { | 821 if (test_data.url_matches_activation_list) { |
| 833 factory()->AddHostOfURLToWhitelistSet(test_url); | 822 factory()->AddHostOfURLToWhitelistSet(test_url); |
| 834 NavigateAndExpectActivation( | 823 NavigateAndExpectActivation( |
| 835 {test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)}, | 824 {test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)}, |
| 836 expected_pattern, | 825 expected_pattern, |
| 837 GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES | 826 GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES |
| 838 ? ActivationDecision::ACTIVATION_DISABLED | 827 ? ActivationDecision::ACTIVATION_DISABLED |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 854 | 843 |
| 855 // data URLs are also not supported, but not listed here, as it's not possible | 844 // data URLs are also not supported, but not listed here, as it's not possible |
| 856 // for a page to redirect to them after https://crbug.com/594215 is fixed. | 845 // for a page to redirect to them after https://crbug.com/594215 is fixed. |
| 857 const char* unsupported_urls[] = {"ftp://example.com/", "chrome://settings", | 846 const char* unsupported_urls[] = {"ftp://example.com/", "chrome://settings", |
| 858 "chrome-extension://some-extension", | 847 "chrome-extension://some-extension", |
| 859 "file:///var/www/index.html"}; | 848 "file:///var/www/index.html"}; |
| 860 const char* supported_urls[] = {"http://example.test", | 849 const char* supported_urls[] = {"http://example.test", |
| 861 "https://example.test"}; | 850 "https://example.test"}; |
| 862 for (auto* url : unsupported_urls) { | 851 for (auto* url : unsupported_urls) { |
| 863 SCOPED_TRACE(url); | 852 SCOPED_TRACE(url); |
| 864 RedirectChainMatchPattern expected_pattern = EMPTY; | 853 RecordHistograms expected_pattern = EMPTY; |
| 865 NavigateAndExpectActivation( | 854 NavigateAndExpectActivation( |
| 866 {test_data.url_matches_activation_list}, {GURL(url)}, expected_pattern, | 855 {test_data.url_matches_activation_list}, {GURL(url)}, expected_pattern, |
| 867 GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES | 856 GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES |
| 868 ? ActivationDecision::ACTIVATION_DISABLED | 857 ? ActivationDecision::ACTIVATION_DISABLED |
| 869 : ActivationDecision::UNSUPPORTED_SCHEME); | 858 : ActivationDecision::UNSUPPORTED_SCHEME); |
| 870 } | 859 } |
| 871 for (auto* url : supported_urls) { | 860 for (auto* url : supported_urls) { |
| 872 SCOPED_TRACE(url); | 861 SCOPED_TRACE(url); |
| 873 RedirectChainMatchPattern expected_pattern = | 862 RecordHistograms expected_pattern = |
| 874 test_data.url_matches_activation_list ? NO_REDIRECTS_HIT : EMPTY; | 863 test_data.url_matches_activation_list ? MATCH : EMPTY; |
| 875 NavigateAndExpectActivation({test_data.url_matches_activation_list}, | 864 NavigateAndExpectActivation({test_data.url_matches_activation_list}, |
| 876 {GURL(url)}, expected_pattern, | 865 {GURL(url)}, expected_pattern, |
| 877 test_data.expected_activation_decision); | 866 test_data.expected_activation_decision); |
| 878 } | 867 } |
| 879 }; | 868 }; |
| 880 | 869 |
| 881 INSTANTIATE_TEST_CASE_P(NoSocEngHit, | 870 INSTANTIATE_TEST_CASE_P(NoSocEngHit, |
| 882 ContentSubresourceFilterDriverFactoryThreatTypeTest, | 871 ContentSubresourceFilterDriverFactoryThreatTypeTest, |
| 883 ::testing::ValuesIn(kActivationListTestData)); | 872 ::testing::ValuesIn(kActivationListTestData)); |
| 884 | 873 |
| 885 INSTANTIATE_TEST_CASE_P( | 874 INSTANTIATE_TEST_CASE_P( |
| 886 ActivationScopeTest, | 875 ActivationScopeTest, |
| 887 ContentSubresourceFilterDriverFactoryActivationScopeTest, | 876 ContentSubresourceFilterDriverFactoryActivationScopeTest, |
| 888 ::testing::ValuesIn(kActivationScopeTestData)); | 877 ::testing::ValuesIn(kActivationScopeTestData)); |
| 889 | 878 |
| 890 INSTANTIATE_TEST_CASE_P( | 879 INSTANTIATE_TEST_CASE_P( |
| 891 ActivationLevelTest, | 880 ActivationLevelTest, |
| 892 ContentSubresourceFilterDriverFactoryActivationLevelTest, | 881 ContentSubresourceFilterDriverFactoryActivationLevelTest, |
| 893 ::testing::ValuesIn(kActivationLevelTestData)); | 882 ::testing::ValuesIn(kActivationLevelTestData)); |
| 894 | 883 |
| 895 } // namespace subresource_filter | 884 } // namespace subresource_filter |
| OLD | NEW |