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 e0312a73b2a8e4a5d3f873cf59b12e1be6f0019f..0a5e66e8f030bef9651a77169e91b039151471ee 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 |
@@ -29,15 +29,17 @@ 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 kMatchesPatternHistogramName[] = |
+ "SubresourceFilter.PageLoad.RedirectChainMatchPattern"; |
+const char kNavigationChainSize[] = |
+ "SubresourceFilter.PageLoad.RedirectChainLength"; |
+const char kSubresourceFilterSuffix[] = ".SubresourceFilter"; |
+ |
// 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. |
@@ -216,6 +218,7 @@ class ContentSubresourceFilterDriverFactoryTest |
const content::Referrer& referrer, |
ui::PageTransition transition, |
RedirectChainMatchPattern expected_pattern, |
+ const std::string histogram_suffix, |
bool expected_activation) { |
base::HistogramTester tester; |
EXPECT_CALL(*client(), ToggleNotificationVisibility(false)).Times(1); |
@@ -244,16 +247,18 @@ class ContentSubresourceFilterDriverFactoryTest |
ExpectActivationSignalForFrame(main_rfh(), expected_activation); |
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()); |
} |
} |
@@ -277,11 +282,12 @@ class ContentSubresourceFilterDriverFactoryTest |
const content::Referrer& referrer, |
ui::PageTransition transition, |
RedirectChainMatchPattern expected_pattern, |
+ const std::string& histogram_suffix, |
bool expected_activation) { |
BlacklistURLWithRedirectsNavigateAndCommit( |
blacklisted_urls, navigation_chain, threat_type, threat_type_metadata, |
- referrer, transition, expected_pattern, expected_activation); |
- |
+ referrer, transition, expected_pattern, histogram_suffix, |
+ expected_activation); |
NavigateAndCommitSubframe(GURL(kExampleLoginUrl), expected_activation); |
} |
@@ -294,7 +300,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); |
+ std::string(), expected_activation); |
} |
void EmulateDidDisallowFirstSubresourceMessage() { |
@@ -480,7 +486,6 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) { |
{{false, true}, {GURL(kUrlA), GURL(kUrlB)}, F0M0L1, true}, |
{{true, false}, {GURL(kUrlA), GURL(kUrlB)}, F1M0L0, false}, |
{{true, true}, {GURL(kUrlA), GURL(kUrlB)}, F1M0L1, true}, |
- |
{{false, false, false}, |
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)}, |
EMPTY, |
@@ -527,9 +532,15 @@ 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); |
+ test_data.hit_expected_pattern, std::string(), |
+ test_data.expected_activation); |
NavigateAndExpectActivation({false}, {GURL("https://dummy.com")}, EMPTY, |
false); |
+ NavigateAndExpectActivation( |
+ test_data.blacklisted_urls, test_data.navigation_chain, |
+ safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, |
+ safe_browsing::ThreatPatternType::NONE, test_data.hit_expected_pattern, |
+ kSubresourceFilterSuffix, false); |
} |
} |
@@ -640,7 +651,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, test_data.expected_activation ? F0M0L1 : EMPTY, |
- test_data.expected_activation); |
+ std::string(), test_data.expected_activation); |
}; |
TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest, |