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

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: only changes specific to this cl Created 3 years, 9 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 7d5644d76711146fe7f11e7a0c92ba746b27e772..266c78cad9f482e5761550861681a9734acaee5e 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
@@ -35,16 +35,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.
@@ -68,6 +73,8 @@ std::string GetSuffixForList(const ActivationList& type) {
return ".SocialEngineeringAdsInterstitial";
case ActivationList::PHISHING_INTERSTITIAL:
return ".PhishingInterstital";
+ case ActivationList::SUBRESOURCE_FILTER:
+ return ".SubresourceFilterOnly";
case ActivationList::NONE:
return std::string();
}
@@ -247,6 +254,7 @@ class ContentSubresourceFilterDriverFactoryTest
const content::Referrer& referrer,
ui::PageTransition transition,
RedirectChainMatchPattern expected_pattern,
+ const std::string& histogram_suffix,
engedy 2017/03/21 13:44:16 Note that this is not used.
melandory 2017/03/24 15:49:28 Done.
ActivationDecision expected_activation_decision) {
const bool expected_activation =
expected_activation_decision == ActivationDecision::ACTIVATED;
@@ -320,12 +328,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);
}
@@ -340,7 +350,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() {
@@ -542,7 +552,6 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) {
{GURL(kUrlA), GURL(kUrlB)},
F1M0L1,
ActivationDecision::ACTIVATED},
-
{{false, false, false},
{GURL(kUrlA), GURL(kUrlB), GURL(kUrlC)},
EMPTY,
@@ -589,10 +598,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
}
}
@@ -654,7 +673,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.
@@ -703,7 +722,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,
- effective_list != ActivationList::NONE ? F0M0L1 : EMPTY,
+ effective_list != ActivationList::NONE ? F0M0L1 : EMPTY, std::string(),
test_data.expected_activation_decision);
};

Powered by Google App Engine
This is Rietveld 408576698