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

Unified Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc

Issue 2645283007: Add the client for accessing Subresource Filter only list. (Closed)
Patch Set: fix HistoryNavTest Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 231c7aef89b188ee5bcf78a5d9daea94192f204d..ab69a29fe269273e207b47c41b3de04a8753913d 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
@@ -32,15 +32,20 @@ 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";
+
+#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.
@@ -233,6 +238,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;
@@ -265,16 +271,18 @@ class ContentSubresourceFilterDriverFactoryTest
factory()->GetActivationDecisionForLastCommittedPageLoad());
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());
}
}
@@ -298,12 +306,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);
}
@@ -318,7 +328,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() {
@@ -520,7 +530,6 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) {
{GURL(kUrlA), GURL(kUrlB)},
F1M0L1,
ActivationDecision::ACTIVATED},
-
{{false, false, false},
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)},
EMPTY,
@@ -567,10 +576,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
}
}
@@ -638,7 +657,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.
@@ -687,7 +706,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,

Powered by Google App Engine
This is Rietveld 408576698