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

Side by Side Diff: components/subresource_filter/content/browser/content_subresource_filter_driver_factory_unittest.cc

Issue 2272323002: Allow Safe Browsing Saresource Filter to distinguish between different lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow Safe Browsing Saresource Filter to distinguish between different lists. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/macros.h" 5 #include "base/macros.h"
6 #include "base/memory/ptr_util.h" 6 #include "base/memory/ptr_util.h"
7 #include "base/metrics/field_trial.h" 7 #include "base/metrics/field_trial.h"
8 #include "components/safe_browsing_db/util.h" 8 #include "components/safe_browsing_db/util.h"
9 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver.h" 9 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver.h"
10 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h" 10 #include "components/subresource_filter/content/browser/content_subresource_filt er_driver_factory.h"
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 91
92 MockSubresourceFilterClient* client() { return client_; } 92 MockSubresourceFilterClient* client() { return client_; }
93 MockSubresourceFilterDriver* driver() { return driver_; } 93 MockSubresourceFilterDriver* driver() { return driver_; }
94 94
95 MockSubresourceFilterDriver* subframe_driver() { return subframe_driver_; } 95 MockSubresourceFilterDriver* subframe_driver() { return subframe_driver_; }
96 content::RenderFrameHost* subframe_rfh() { return subframe_rfh_; } 96 content::RenderFrameHost* subframe_rfh() { return subframe_rfh_; }
97 97
98 void BlacklistURLWithRedirects(const GURL& url, 98 void BlacklistURLWithRedirects(const GURL& url,
99 const std::vector<GURL>& redirects) { 99 const std::vector<GURL>& redirects) {
100 factory()->OnMainResourceMatchedSafeBrowsingBlacklist( 100 factory()->OnMainResourceMatchedSafeBrowsingBlacklist(
101 url, redirects, 101 url, redirects, safe_browsing::SB_THREAT_TYPE_URL_PHISHING,
102 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS); 102 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS);
103 } 103 }
104 104
105 void ActivateAndExpectForFrameHostForUrl(MockSubresourceFilterDriver* driver, 105 void ActivateAndExpectForFrameHostForUrl(MockSubresourceFilterDriver* driver,
106 content::RenderFrameHost* rfh, 106 content::RenderFrameHost* rfh,
107 const GURL& url, 107 const GURL& url,
108 bool should_activate) { 108 bool should_activate) {
109 EXPECT_CALL(*driver, ActivateForProvisionalLoad(::testing::_)) 109 EXPECT_CALL(*driver, ActivateForProvisionalLoad(::testing::_))
110 .Times(should_activate); 110 .Times(should_activate);
111 factory()->ReadyToCommitMainFrameNavigation(rfh, url); 111 factory()->ReadyToCommitMainFrameNavigation(rfh, url);
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 } 236 }
237 237
238 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, NonSocEngHit) { 238 TEST_P(ContentSubresourceFilterDriverFactoryThreatTypeTest, NonSocEngHit) {
239 std::vector<GURL> redirects; 239 std::vector<GURL> redirects;
240 redirects.push_back(GURL("https://example1.com")); 240 redirects.push_back(GURL("https://example1.com"));
241 redirects.push_back(GURL("https://example2.com")); 241 redirects.push_back(GURL("https://example2.com"));
242 redirects.push_back(GURL("https://example3.com")); 242 redirects.push_back(GURL("https://example3.com"));
243 243
244 const GURL test_url("https://example.com/nonsoceng?q=engsocnon"); 244 const GURL test_url("https://example.com/nonsoceng?q=engsocnon");
245 factory()->OnMainResourceMatchedSafeBrowsingBlacklist( 245 factory()->OnMainResourceMatchedSafeBrowsingBlacklist(
246 GURL(test_url), std::vector<GURL>(), GetParam()); 246 GURL(test_url), std::vector<GURL>(),
247 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, GetParam());
247 EXPECT_EQ(0U, factory()->activation_set().size()); 248 EXPECT_EQ(0U, factory()->activation_set().size());
248 EXPECT_FALSE(factory()->ShouldActivateForURL(GURL(test_url))); 249 EXPECT_FALSE(factory()->ShouldActivateForURL(GURL(test_url)));
249 EXPECT_FALSE( 250 EXPECT_FALSE(
250 factory()->ShouldActivateForURL(GURL(test_url.GetWithEmptyPath()))); 251 factory()->ShouldActivateForURL(GURL(test_url.GetWithEmptyPath())));
251 EXPECT_FALSE(factory()->ShouldActivateForURL( 252 EXPECT_FALSE(factory()->ShouldActivateForURL(
252 GURL("http://" + test_url.host() + "/path?q=q"))); 253 GURL("http://" + test_url.host() + "/path?q=q")));
253 for (const auto& redirect : redirects) { 254 for (const auto& redirect : redirects) {
254 EXPECT_FALSE(factory()->ShouldActivateForURL(redirect)); 255 EXPECT_FALSE(factory()->ShouldActivateForURL(redirect));
255 EXPECT_FALSE(factory()->ShouldActivateForURL(redirect.GetWithEmptyPath())); 256 EXPECT_FALSE(factory()->ShouldActivateForURL(redirect.GetWithEmptyPath()));
256 EXPECT_FALSE( 257 EXPECT_FALSE(
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
325 INSTANTIATE_TEST_CASE_P( 326 INSTANTIATE_TEST_CASE_P(
326 NoSonEngHit, 327 NoSonEngHit,
327 ContentSubresourceFilterDriverFactoryThreatTypeTest, 328 ContentSubresourceFilterDriverFactoryThreatTypeTest,
328 ::testing::Values( 329 ::testing::Values(
329 safe_browsing::ThreatPatternType::NONE, 330 safe_browsing::ThreatPatternType::NONE,
330 safe_browsing::ThreatPatternType::MALWARE_LANDING, 331 safe_browsing::ThreatPatternType::MALWARE_LANDING,
331 safe_browsing::ThreatPatternType::MALWARE_DISTRIBUTION, 332 safe_browsing::ThreatPatternType::MALWARE_DISTRIBUTION,
332 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_LANDING)); 333 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_LANDING));
333 334
334 } // namespace subresource_filter 335 } // namespace subresource_filter
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698