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

Unified Diff: chrome/browser/subresource_filter/subresource_filter_unittest.cc

Issue 2892843003: [subresource_filter] Reland: Decide UNSUPPORTED_SCHEME only if we'd otherwise activate (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/subresource_filter/subresource_filter_unittest.cc
diff --git a/chrome/browser/subresource_filter/subresource_filter_unittest.cc b/chrome/browser/subresource_filter/subresource_filter_unittest.cc
index 3dab716f5312c61f2026ff5e7b0a0d3c11a5a98c..60cc7e4994ff0f2407f0e7e9ac1d971af0a83cc0 100644
--- a/chrome/browser/subresource_filter/subresource_filter_unittest.cc
+++ b/chrome/browser/subresource_filter/subresource_filter_unittest.cc
@@ -33,6 +33,7 @@
#include "components/subresource_filter/core/browser/ruleset_service.h"
#include "components/subresource_filter/core/browser/subresource_filter_features.h"
#include "components/subresource_filter/core/browser/subresource_filter_features_test_support.h"
+#include "components/subresource_filter/core/common/activation_decision.h"
#include "components/subresource_filter/core/common/test_ruleset_creator.h"
#include "content/public/browser/navigation_throttle.h"
#include "content/public/test/navigation_simulator.h"
@@ -256,3 +257,42 @@ TEST_F(SubresourceFilterTest, ExplicitWhitelisting_ShouldNotClearMetadata) {
// blacklist.
EXPECT_NE(nullptr, settings_manager()->GetSiteMetadata(url));
}
+
+TEST_F(SubresourceFilterTest,
+ NavigationToBadSchemeUrlWithNoActivation_DoesNotReportBadScheme) {
+ // Don't report UNSUPPORTED_SCHEME if the navigation has no matching
+ // configuration.
+ scoped_configuration().ResetConfiguration(subresource_filter::Configuration(
+ subresource_filter::ActivationLevel::DISABLED,
+ subresource_filter::ActivationScope::NO_SITES));
+
+ GURL url("data:text/html,hello world");
+ SimulateNavigateAndCommit(url, main_rfh());
+ EXPECT_TRUE(CreateAndNavigateDisallowedSubframe(main_rfh()));
+ auto* driver_factory = subresource_filter::
+ ContentSubresourceFilterDriverFactory::FromWebContents(web_contents());
+ EXPECT_EQ(
+ subresource_filter::ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET,
+ driver_factory->GetActivationDecisionForLastCommittedPageLoad());
+
+ // Also don't report UNSUPPORTED_SCHEME if the navigation matches a
+ // configuration with DISABLED activation level.
+ scoped_configuration().ResetConfiguration(subresource_filter::Configuration(
+ subresource_filter::ActivationLevel::DISABLED,
+ subresource_filter::ActivationScope::ALL_SITES));
+
+ SimulateNavigateAndCommit(url, main_rfh());
+ EXPECT_TRUE(CreateAndNavigateDisallowedSubframe(main_rfh()));
+ EXPECT_EQ(subresource_filter::ActivationDecision::ACTIVATION_DISABLED,
+ driver_factory->GetActivationDecisionForLastCommittedPageLoad());
+
+ // Sanity check that UNSUPPORTED_SCHEME is reported if the navigation does
+ // activate.
+ scoped_configuration().ResetConfiguration(subresource_filter::Configuration(
+ subresource_filter::ActivationLevel::ENABLED,
+ subresource_filter::ActivationScope::ALL_SITES));
+ SimulateNavigateAndCommit(url, main_rfh());
+ EXPECT_TRUE(CreateAndNavigateDisallowedSubframe(main_rfh()));
+ EXPECT_EQ(subresource_filter::ActivationDecision::UNSUPPORTED_SCHEME,
+ driver_factory->GetActivationDecisionForLastCommittedPageLoad());
+}
« no previous file with comments | « no previous file | components/subresource_filter/content/browser/content_subresource_filter_driver_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698