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

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

Issue 2889193003: [subresource_filter] Reland: Remove Forwarding NavigationThrottles (Closed)
Patch Set: Fix 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
Index: components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc
diff --git a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc
index 20804b31a9afaf9f1beb4733dec749802a18f984..91c049639b85dad7ebbd4e956bbf2749b44b43f4 100644
--- a/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc
+++ b/components/subresource_filter/content/browser/subresource_filter_safe_browsing_activation_throttle_unittest.cc
@@ -82,31 +82,6 @@ class MockSubresourceFilterClient
DISALLOW_COPY_AND_ASSIGN(MockSubresourceFilterClient);
};
-// Throttle to call WillProcessResponse on the factory, which is otherwise
-// called by the ThrottleManager.
-class TestForwardingNavigationThrottle : public content::NavigationThrottle {
- public:
- explicit TestForwardingNavigationThrottle(content::NavigationHandle* handle)
- : content::NavigationThrottle(handle) {}
- ~TestForwardingNavigationThrottle() override {}
-
- // content::NavigationThrottle:
- content::NavigationThrottle::ThrottleCheckResult WillProcessResponse()
- override {
- content::WebContents* web_contents = navigation_handle()->GetWebContents();
- ContentSubresourceFilterDriverFactory* factory =
- ContentSubresourceFilterDriverFactory::FromWebContents(web_contents);
- factory->WillProcessResponse(navigation_handle());
- return content::NavigationThrottle::PROCEED;
- }
- const char* GetNameForLogging() override {
- return "TestForwardingNavigationThrottle";
- }
-
- private:
- DISALLOW_COPY_AND_ASSIGN(TestForwardingNavigationThrottle);
-};
-
std::string GetSuffixForList(const ActivationList& type) {
switch (type) {
case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL:
@@ -198,8 +173,6 @@ class SubresourceFilterSafeBrowsingActivationThrottleTest
base::MakeUnique<SubresourceFilterSafeBrowsingActivationThrottle>(
navigation_handle, test_io_task_runner_,
fake_safe_browsing_database_));
- navigation_handle->RegisterThrottleForTesting(
- base::MakeUnique<TestForwardingNavigationThrottle>(navigation_handle));
}
content::NavigationThrottle::ThrottleCheckResult SimulateStart() {
@@ -268,6 +241,9 @@ class SubresourceFilterSafeBrowsingActivationThrottleTest
fake_safe_browsing_database_->RemoveAllBlacklistedUrls();
}
+ // With a null database the throttle becomes pass-through.
+ void UsePassThroughThrottle() { fake_safe_browsing_database_ = nullptr; }
+
void RunUntilIdle() {
test_io_task_runner_->RunUntilIdle();
base::RunLoop().RunUntilIdle();
@@ -356,6 +332,35 @@ class SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling
SubresourceFilterSafeBrowsingActivationThrottleTestWithCancelling);
};
+TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest,
+ PassThroughThrottle) {
+ UsePassThroughThrottle();
+ CreateTestNavigationForMainFrame(GURL(kURL));
+ SimulateStartAndExpectProceed();
+ SimulateRedirectAndExpectProceed(GURL(kRedirectURL));
+ SimulateCommitAndExpectProceed();
+ EXPECT_EQ(ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET,
+ factory()->GetActivationDecisionForLastCommittedPageLoad());
+
+ scoped_configuration()->ResetConfiguration(
+ Configuration(ActivationLevel::ENABLED, ActivationScope::ALL_SITES));
+ CreateTestNavigationForMainFrame(GURL(kURL));
+ SimulateStartAndExpectProceed();
+ SimulateRedirectAndExpectProceed(GURL(kRedirectURL));
+ SimulateCommitAndExpectProceed();
+ EXPECT_EQ(ActivationDecision::ACTIVATED,
+ factory()->GetActivationDecisionForLastCommittedPageLoad());
+
+ scoped_configuration()->ResetConfiguration(
+ Configuration(ActivationLevel::ENABLED, ActivationScope::NO_SITES));
+ CreateTestNavigationForMainFrame(GURL(kURL));
+ SimulateStartAndExpectProceed();
+ SimulateRedirectAndExpectProceed(GURL(kRedirectURL));
+ SimulateCommitAndExpectProceed();
+ EXPECT_EQ(ActivationDecision::ACTIVATION_CONDITIONS_NOT_MET,
+ factory()->GetActivationDecisionForLastCommittedPageLoad());
+}
+
TEST_P(SubresourceFilterSafeBrowsingActivationThrottleParamTest,
ListNotMatched_NoActivation) {
const ActivationListTestData& test_data = GetParam();

Powered by Google App Engine
This is Rietveld 408576698