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

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

Issue 2798983002: Introduce subresource_filter::Configuration. (Closed)
Patch Set: Address comments from csharrison@. Created 3 years, 8 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 4c1798845f45ef270ef519a848de4e7cb6dc0d0f..88a5e2d434a6a3a02dff975ef2b4e546183ae137 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
@@ -458,7 +458,7 @@ class ContentSubresourceFilterDriverFactoryTest
private:
static bool expected_measure_performance() {
- const double rate = GetPerformanceMeasurementRate();
+ const double rate = GetActiveConfiguration().performance_measurement_rate;
// Note: The case when 0 < rate < 1 is not deterministic, don't test it.
EXPECT_TRUE(rate == 0 || rate == 1);
return rate == 1;
@@ -519,6 +519,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
base::FeatureList::OVERRIDE_DISABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeAllSites,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
const GURL url(kExampleUrlWithParams);
NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATION_DISABLED);
@@ -533,6 +534,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) {
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeActivationList,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY,
ActivationDecision::ACTIVATION_LIST_NOT_MATCHED);
}
@@ -545,6 +547,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeAllSites);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
EmulateInPageNavigation({false}, EMPTY, ActivationDecision::ACTIVATED);
}
@@ -555,6 +558,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeActivationList,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
EmulateInPageNavigation({true}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATED);
}
@@ -567,6 +571,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
kActivationScopeActivationList,
kActivationListSocialEngineeringAdsInterstitial,
"1" /* performance_measurement_rate */);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
EmulateInPageNavigation({true}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATED);
}
@@ -576,6 +581,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, FailedNavigation) {
testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeAllSites);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
const GURL url(kExampleUrl);
NavigateAndExpectActivation({false}, {url}, EMPTY,
ActivationDecision::ACTIVATED);
@@ -590,6 +596,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, RedirectPatternTest) {
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeActivationList,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
struct RedirectRedirectChainMatchPatternTestData {
std::vector<bool> blacklisted_urls;
std::vector<GURL> navigation_chain;
@@ -683,6 +690,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, NotificationVisibility) {
testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeAllSites);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY,
ActivationDecision::ACTIVATED);
@@ -699,6 +707,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
kActivationScopeAllSites, "" /* activation_lists */,
"" /* performance_measurement_rate */,
"true" /* suppress_notifications */);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY,
ActivationDecision::ACTIVATED);
@@ -741,6 +750,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, WhitelistSiteOnReload) {
kActivationScopeAllSites, "" /* activation_lists */,
"" /* performance_measurement_rate */, "" /* suppress_notifications */,
"true" /* whitelist_site_on_reload */);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
NavigateAndExpectActivation(
{false}, {GURL(kExampleUrl)},
@@ -763,6 +773,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest,
base::FeatureList::OVERRIDE_ENABLE_FEATURE, test_data.activation_level,
kActivationScopeActivationList,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
const GURL url(kExampleUrlWithParams);
NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
@@ -770,7 +781,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest,
factory()->AddHostOfURLToWhitelistSet(url);
NavigateAndExpectActivation(
{true}, {GURL(kExampleUrlWithParams)}, NO_REDIRECTS_HIT,
- GetMaximumActivationLevel() == ActivationLevel::DISABLED
+ GetActiveConfiguration().activation_level == ActivationLevel::DISABLED
? ActivationDecision::ACTIVATION_DISABLED
: ActivationDecision::URL_WHITELISTED);
}
@@ -784,6 +795,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest,
testing::ScopedSubresourceFilterFeatureToggle scoped_feature_toggle(
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
kActivationScopeActivationList, test_data.activation_list);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
const GURL test_url("https://example.com/nonsoceng?q=engsocnon");
std::vector<GURL> navigation_chain;
@@ -807,6 +819,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
test_data.activation_scope,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
const GURL test_url(kExampleUrlWithParams);
@@ -820,7 +833,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
NavigateAndExpectActivation(
{test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)},
expected_pattern,
- GetCurrentActivationScope() == ActivationScope::NO_SITES
+ GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES
? ActivationDecision::ACTIVATION_DISABLED
: ActivationDecision::URL_WHITELISTED);
}
@@ -836,6 +849,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled,
test_data.activation_scope,
kActivationListSocialEngineeringAdsInterstitial);
+ factory()->set_configuration_for_testing(GetActiveConfiguration());
// data URLs are also not supported, but not listed here, as it's not possible
// for a page to redirect to them after https://crbug.com/594215 is fixed.
@@ -849,7 +863,7 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
RedirectChainMatchPattern expected_pattern = EMPTY;
NavigateAndExpectActivation(
{test_data.url_matches_activation_list}, {GURL(url)}, expected_pattern,
- GetCurrentActivationScope() == ActivationScope::NO_SITES
+ GetActiveConfiguration().activation_scope == ActivationScope::NO_SITES
? ActivationDecision::ACTIVATION_DISABLED
: ActivationDecision::UNSUPPORTED_SCHEME);
}

Powered by Google App Engine
This is Rietveld 408576698