| 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 d45a265136f96c93752aac8476e3ee24874a2619..1c4a722e4794e9d3ed663ccd43377e809d0891ed 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
|
| @@ -240,7 +240,7 @@ class ContentSubresourceFilterDriverFactoryTest
|
| base::MakeUnique<MockSubresourceFilterClient>(ruleset_dealer_.get());
|
| ContentSubresourceFilterDriverFactory::CreateForWebContents(
|
| RenderViewHostTestHarness::web_contents(), client());
|
| - ResetConfigurationToEnableFilteringOnSocialEngineeringSites();
|
| + ResetConfigurationToEnableFilteringOnPhishingSites();
|
|
|
| // Add a subframe.
|
| content::RenderFrameHostTester* rfh_tester =
|
| @@ -266,10 +266,14 @@ class ContentSubresourceFilterDriverFactoryTest
|
| Configuration(ActivationLevel::ENABLED, ActivationScope::ALL_SITES));
|
| }
|
|
|
| - void ResetConfigurationToEnableFilteringOnSocialEngineeringSites() {
|
| - ResetConfiguration(Configuration(
|
| - ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST,
|
| - ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL));
|
| + void ResetConfigurationToEnableFilteringOnPhishingSites() {
|
| + ResetConfiguration(Configuration::MakePresetForLiveRunOnPhishingSites());
|
| + }
|
| +
|
| + void GetExactlyOneEnabledConfig(Configuration* config) {
|
| + const auto config_list = GetEnabledConfigurations();
|
| + ASSERT_EQ(1u, config_list->configs_by_decreasing_priority().size());
|
| + *config = config_list->configs_by_decreasing_priority().front();
|
| }
|
|
|
| ContentSubresourceFilterDriverFactory* factory() {
|
| @@ -481,15 +485,6 @@ class ContentSubresourceFilterDriverFactoryTest
|
| }
|
|
|
| private:
|
| - static bool expected_measure_performance() {
|
| - const double rate = GetActiveConfigurations()
|
| - ->the_one_and_only()
|
| - .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;
|
| - }
|
| -
|
| testing::ScopedSubresourceFilterConfigurator scoped_configuration_;
|
| testing::TestRulesetCreator test_ruleset_creator_;
|
| testing::TestRulesetPair test_ruleset_pair_;
|
| @@ -540,7 +535,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
|
| Configuration config(ActivationLevel::DISABLED,
|
| ActivationScope::ACTIVATION_LIST,
|
| ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL);
|
| - config.activation_level = ActivationLevel::DISABLED;
|
| + config.activation_options.activation_level = ActivationLevel::DISABLED;
|
| ResetConfiguration(std::move(config));
|
|
|
| const GURL url(kExampleUrlWithParams);
|
| @@ -575,7 +570,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
|
| Configuration config(ActivationLevel::ENABLED,
|
| ActivationScope::ACTIVATION_LIST,
|
| ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL);
|
| - config.performance_measurement_rate = 1.0;
|
| + config.activation_options.performance_measurement_rate = 1.0;
|
| ResetConfiguration(std::move(config));
|
|
|
| EmulateInPageNavigation({true}, NO_REDIRECTS_HIT,
|
| @@ -693,7 +688,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, NotificationVisibility) {
|
| TEST_F(ContentSubresourceFilterDriverFactoryTest,
|
| SuppressNotificationVisibility) {
|
| Configuration config(ActivationLevel::ENABLED, ActivationScope::ALL_SITES);
|
| - config.should_suppress_notifications = true;
|
| + config.activation_options.should_suppress_notifications = true;
|
| ResetConfiguration(std::move(config));
|
| NavigateAndExpectActivation({false}, {GURL(kExampleUrl)}, EMPTY,
|
| ActivationDecision::ACTIVATED);
|
| @@ -733,7 +728,7 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest, WhitelistSiteOnReload) {
|
| << " transition = \"" << test_case.transition << "\"");
|
|
|
| Configuration config(ActivationLevel::ENABLED, ActivationScope::ALL_SITES);
|
| - config.should_whitelist_site_on_reload = true;
|
| + config.activation_options.should_whitelist_site_on_reload = true;
|
| ResetConfiguration(std::move(config));
|
|
|
| NavigateAndExpectActivation(
|
| @@ -760,12 +755,15 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest,
|
| NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
|
| test_data.expected_activation_decision);
|
| factory()->client()->WhitelistInCurrentWebContents(url);
|
| +
|
| + Configuration config;
|
| + ASSERT_NO_FATAL_FAILURE(GetExactlyOneEnabledConfig(&config));
|
| + bool expect_activation_is_disabled =
|
| + config.activation_options.activation_level == ActivationLevel::DISABLED;
|
| NavigateAndExpectActivation(
|
| {true}, {GURL(kExampleUrlWithParams)}, NO_REDIRECTS_HIT,
|
| - GetActiveConfigurations()->the_one_and_only().activation_level ==
|
| - ActivationLevel::DISABLED
|
| - ? ActivationDecision::ACTIVATION_DISABLED
|
| - : ActivationDecision::URL_WHITELISTED);
|
| + expect_activation_is_disabled ? ActivationDecision::ACTIVATION_DISABLED
|
| + : ActivationDecision::URL_WHITELISTED);
|
| }
|
|
|
| TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest,
|
| @@ -807,13 +805,17 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
|
| test_data.expected_activation_decision);
|
| if (test_data.url_matches_activation_list) {
|
| factory()->client()->WhitelistInCurrentWebContents(test_url);
|
| - NavigateAndExpectActivation(
|
| - {test_data.url_matches_activation_list}, {GURL(kExampleUrlWithParams)},
|
| - expected_pattern,
|
| - GetActiveConfigurations()->the_one_and_only().activation_scope ==
|
| - ActivationScope::NO_SITES
|
| - ? ActivationDecision::ACTIVATION_DISABLED
|
| - : ActivationDecision::URL_WHITELISTED);
|
| +
|
| + Configuration config;
|
| + ASSERT_NO_FATAL_FAILURE(GetExactlyOneEnabledConfig(&config));
|
| + bool expect_activation_is_disabled =
|
| + config.activation_conditions.activation_scope ==
|
| + ActivationScope::NO_SITES;
|
| + NavigateAndExpectActivation({test_data.url_matches_activation_list},
|
| + {GURL(kExampleUrlWithParams)}, expected_pattern,
|
| + expect_activation_is_disabled
|
| + ? ActivationDecision::ACTIVATION_DISABLED
|
| + : ActivationDecision::URL_WHITELISTED);
|
| }
|
| };
|
|
|
| @@ -835,13 +837,16 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationScopeTest,
|
| "https://example.test"};
|
| for (auto* url : unsupported_urls) {
|
| SCOPED_TRACE(url);
|
| + Configuration config;
|
| + ASSERT_NO_FATAL_FAILURE(GetExactlyOneEnabledConfig(&config));
|
| + bool expect_activation_is_disabled =
|
| + config.activation_conditions.activation_scope ==
|
| + ActivationScope::NO_SITES;
|
| RedirectChainMatchPattern expected_pattern = EMPTY;
|
| NavigateAndExpectActivation(
|
| {test_data.url_matches_activation_list}, {GURL(url)}, expected_pattern,
|
| - GetActiveConfigurations()->the_one_and_only().activation_scope ==
|
| - ActivationScope::NO_SITES
|
| - ? ActivationDecision::ACTIVATION_DISABLED
|
| - : ActivationDecision::UNSUPPORTED_SCHEME);
|
| + expect_activation_is_disabled ? ActivationDecision::ACTIVATION_DISABLED
|
| + : ActivationDecision::UNSUPPORTED_SCHEME);
|
| }
|
| for (auto* url : supported_urls) {
|
| SCOPED_TRACE(url);
|
|
|