Index: components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc |
diff --git a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc |
index 19d02222603ba19c529e8500f2a4257edbf9b939..7673aba87d41be43f6f217e850f9fa767cfc6fd6 100644 |
--- a/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc |
+++ b/components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc |
@@ -34,16 +34,21 @@ namespace { |
const char kExampleUrlWithParams[] = "https://example.com/soceng?q=engsoc"; |
const char kExampleUrl[] = "https://example.com"; |
const char kExampleLoginUrl[] = "https://example.com/login"; |
-const char kMatchesPatternHistogramName[] = |
- "SubresourceFilter.PageLoad.RedirectChainMatchPattern"; |
-const char kNavigationChainSize[] = |
- "SubresourceFilter.PageLoad.RedirectChainLength"; |
const char kUrlA[] = "https://example_a.com"; |
const char kUrlB[] = "https://example_b.com"; |
const char kUrlC[] = "https://example_c.com"; |
const char kUrlD[] = "https://example_d.com"; |
const char kSubframeName[] = "Child"; |
+const char kMatchesPatternHistogramName[] = |
+ "SubresourceFilter.PageLoad.RedirectChainMatchPattern"; |
+const char kNavigationChainSize[] = |
+ "SubresourceFilter.PageLoad.RedirectChainLength"; |
+ |
+#if defined(GOOGLE_CHROME_BUILD) |
+const char kSubresourceFilterSuffix[] = ".SubresourceFilter"; |
+#endif |
+ |
// Human readable representation of expected redirect chain match patterns. |
// The explanations for the buckets given for the following redirect chain: |
// A->B->C->D, where A is initial URL and D is a final URL. |
@@ -230,6 +235,7 @@ class ContentSubresourceFilterDriverFactoryTest |
const content::Referrer& referrer, |
ui::PageTransition transition, |
RedirectChainMatchPattern expected_pattern, |
+ const std::string& histogram_suffix, |
ActivationDecision expected_activation_decision) { |
const bool expected_activation = |
expected_activation_decision == ActivationDecision::ACTIVATED; |
@@ -270,16 +276,18 @@ class ContentSubresourceFilterDriverFactoryTest |
rfh_tester->AppendChild(kSubframeName); |
if (expected_pattern != EMPTY) { |
- EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName), |
- ::testing::ElementsAre(base::Bucket(expected_pattern, 1))); |
EXPECT_THAT( |
- tester.GetAllSamples(kNavigationChainSize), |
+ tester.GetAllSamples(kMatchesPatternHistogramName + histogram_suffix), |
+ ::testing::ElementsAre(base::Bucket(expected_pattern, 1))); |
+ EXPECT_THAT( |
+ tester.GetAllSamples(kNavigationChainSize + histogram_suffix), |
::testing::ElementsAre(base::Bucket(navigation_chain.size(), 1))); |
} else { |
- EXPECT_THAT(tester.GetAllSamples(kMatchesPatternHistogramName), |
- ::testing::IsEmpty()); |
- EXPECT_THAT(tester.GetAllSamples(kNavigationChainSize), |
+ EXPECT_THAT( |
+ tester.GetAllSamples(kMatchesPatternHistogramName + histogram_suffix), |
+ ::testing::IsEmpty()); |
+ EXPECT_THAT(tester.GetAllSamples(kNavigationChainSize + histogram_suffix), |
::testing::IsEmpty()); |
} |
} |
@@ -301,12 +309,14 @@ class ContentSubresourceFilterDriverFactoryTest |
const content::Referrer& referrer, |
ui::PageTransition transition, |
RedirectChainMatchPattern expected_pattern, |
+ const std::string& histogram_suffix, |
ActivationDecision expected_activation_decision) { |
const bool expected_activation = |
expected_activation_decision == ActivationDecision::ACTIVATED; |
BlacklistURLWithRedirectsNavigateAndCommit( |
blacklisted_urls, navigation_chain, threat_type, threat_type_metadata, |
- referrer, transition, expected_pattern, expected_activation_decision); |
+ referrer, transition, expected_pattern, histogram_suffix, |
+ expected_activation_decision); |
NavigateAndCommitSubframe(GURL(kExampleLoginUrl), expected_activation); |
} |
@@ -321,7 +331,7 @@ class ContentSubresourceFilterDriverFactoryTest |
safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
content::Referrer(), ui::PAGE_TRANSITION_LINK, expected_pattern, |
- expected_activation_decision); |
+ std::string(), expected_activation_decision); |
} |
void EmulateDidDisallowFirstSubresourceMessage() { |
@@ -521,7 +531,6 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { |
{GURL(kUrlA), GURL(kUrlB)}, |
F1M0L1, |
ActivationDecision::ACTIVATED}, |
- |
{{false, false, false}, |
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
EMPTY, |
@@ -568,10 +577,20 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { |
safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
content::Referrer(), ui::PAGE_TRANSITION_LINK, |
- test_data.hit_expected_pattern, test_data.expected_activation_decision); |
+ test_data.hit_expected_pattern, std::string(), |
+ test_data.expected_activation_decision); |
NavigateAndExpectActivation( |
{false}, {GURL("https://dummy.com")}, EMPTY, |
ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
+#if defined(GOOGLE_CHROME_BUILD) |
+ NavigateAndExpectActivation( |
+ test_data.blacklisted_urls, test_data.navigation_chain, |
+ safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, |
+ safe_browsing::ThreatPatternType::NONE, content::Referrer(), |
+ ui::PAGE_TRANSITION_LINK, EMPTY, test_data.hit_expected_pattern, |
+ kSubresourceFilterSuffix, |
+ ActivationDecision::ACTIVATION_LIST_NOT_MATCHED); |
+#endif |
} |
} |
@@ -633,7 +652,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, WhitelistSiteOnReload) { |
{false}, {GURL(kExampleUrl)}, |
safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS, |
- test_case.referrer, test_case.transition, EMPTY, |
+ test_case.referrer, test_case.transition, EMPTY, std::string(), |
test_case.expected_activation_decision); |
// Verify that if the first URL failed to activate, subsequent same-origin |
// navigations also fail to activate. |
@@ -682,7 +701,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, |
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC), test_url}, test_data.threat_type, |
test_data.threat_type_metadata, content::Referrer(), |
ui::PAGE_TRANSITION_LINK, expected_activation ? F0M0L1 : EMPTY, |
- test_data.expected_activation_decision); |
+ std::string(), test_data.expected_activation_decision); |
}; |
TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, |