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

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

Issue 2874663002: [subresource_filter] s/ShouldSuppressActivation/OnPageActivationComputed (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
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 814d137987e1f613c2f1928a601738c7e278dfc4..bf02f836e9983663ca604fc5da51ab7804fd1feb 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
@@ -189,10 +189,10 @@ class MockSubresourceFilterClient : public SubresourceFilterClient {
~MockSubresourceFilterClient() override = default;
- bool ShouldSuppressActivation(content::NavigationHandle* handle) override {
- return handle->IsInMainFrame() &&
- whitelisted_hosts_.find(handle->GetURL().host()) !=
- whitelisted_hosts_.end();
+ bool OnPageActivationComputed(content::NavigationHandle* handle,
+ bool activated) override {
+ DCHECK(handle->IsInMainFrame());
+ return whitelisted_hosts_.count(handle->GetURL().host());
}
void WhitelistByContentSettings(const GURL& url) override {}
@@ -544,9 +544,10 @@ TEST_F(ContentSubresourceFilterDriverFactoryTest,
NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
ActivationDecision::ACTIVATION_DISABLED);
+ // Whitelisting occurs last, so the decision should still be DISABLED.
factory()->client()->WhitelistInCurrentWebContents(url);
NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
- ActivationDecision::URL_WHITELISTED);
+ ActivationDecision::ACTIVATION_DISABLED);
}
TEST_F(ContentSubresourceFilterDriverFactoryTest, NoActivationWhenNoMatch) {
@@ -797,9 +798,13 @@ TEST_P(ContentSubresourceFilterDriverFactoryActivationLevelTest,
NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT,
test_data.expected_activation_decision);
factory()->client()->WhitelistInCurrentWebContents(url);
- NavigateAndExpectActivation({true}, {GURL(kExampleUrlWithParams)},
- NO_REDIRECTS_HIT,
- ActivationDecision::URL_WHITELISTED);
+
+ // Whitelisting is only applied when the page will otherwise activate.
engedy 2017/05/11 09:13:14 I started deprioritizing ActivationDecision::WHITE
Charlie Harrison 2017/05/11 12:07:15 woohoo!
+ ActivationDecision decision =
+ test_data.activation_level == ActivationLevel::DISABLED
+ ? test_data.expected_activation_decision
+ : ActivationDecision::URL_WHITELISTED;
+ NavigateAndExpectActivation({true}, {url}, NO_REDIRECTS_HIT, decision);
}
TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest,

Powered by Google App Engine
This is Rietveld 408576698