OLD | NEW |
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" | 5 #include "components/subresource_filter/content/browser/subresource_filter_safe_
browsing_activation_throttle.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
25 | 25 |
26 namespace subresource_filter { | 26 namespace subresource_filter { |
27 | 27 |
28 namespace { | 28 namespace { |
29 | 29 |
30 char kURL[] = "http://example.test/"; | 30 char kURL[] = "http://example.test/"; |
31 char kRedirectURL[] = "http://foo.test/"; | 31 char kRedirectURL[] = "http://foo.test/"; |
32 | 32 |
33 // Names of navigation chain patterns histogram. | 33 // Names of navigation chain patterns histogram. |
34 const char kMatchesPatternHistogramNameSubresourceFilterSuffix[] = | 34 const char kMatchesPatternHistogramName[] = "SubresourceFilter.PageLoad.Match."; |
35 "SubresourceFilter.PageLoad.RedirectChainMatchPattern." | 35 const char kNavigationChainSize[] = |
36 "SubresourceFilterOnly"; | 36 "SubresourceFilter.PageLoad.RedirectChainLength."; |
37 const char kNavigationChainSizeSubresourceFilterSuffix[] = | |
38 "SubresourceFilter.PageLoad.RedirectChainLength.SubresourceFilterOnly"; | |
39 | |
40 // Human readable representation of expected redirect chain match patterns. | |
41 // The explanations for the buckets given for the following redirect chain: | |
42 // A->B->C->D, where A is initial URL and D is a final URL. | |
43 enum RedirectChainMatchPattern { | |
44 EMPTY, // No histograms were recorded. | |
45 F0M0L1, // D is a Safe Browsing match. | |
46 F0M1L0, // B or C, or both are Safe Browsing matches. | |
47 F0M1L1, // B or C, or both and D are Safe Browsing matches. | |
48 F1M0L0, // A is Safe Browsing match | |
49 F1M0L1, // A and D are Safe Browsing matches. | |
50 F1M1L0, // B and/or C and A are Safe Browsing matches. | |
51 F1M1L1, // B and/or C and A and D are Safe Browsing matches. | |
52 NO_REDIRECTS_HIT, // Redirect chain consists of single URL, aka no redirects | |
53 // has happened, and this URL was a Safe Browsing hit. | |
54 NUM_HIT_PATTERNS, | |
55 }; | |
56 | 37 |
57 // Database manager that allows any URL to be configured as blacklisted for | 38 // Database manager that allows any URL to be configured as blacklisted for |
58 // testing. | 39 // testing. |
59 class FakeSafeBrowsingDatabaseManager | 40 class FakeSafeBrowsingDatabaseManager |
60 : public safe_browsing::TestSafeBrowsingDatabaseManager { | 41 : public safe_browsing::TestSafeBrowsingDatabaseManager { |
61 public: | 42 public: |
62 FakeSafeBrowsingDatabaseManager() : simulate_timeout_(false) {} | 43 FakeSafeBrowsingDatabaseManager() : simulate_timeout_(false) {} |
63 | 44 |
64 void AddBlacklistedUrl(const GURL& url, | 45 void AddBlacklistedUrl(const GURL& url, |
65 safe_browsing::SBThreatType threat_type) { | 46 safe_browsing::SBThreatType threat_type, |
66 url_to_threat_type_[url] = threat_type; | 47 safe_browsing::ThreatPatternType pattern_type) { |
| 48 url_to_threat_type_[url] = std::make_pair(threat_type, pattern_type); |
67 } | 49 } |
68 | 50 |
69 void SimulateTimeout() { simulate_timeout_ = true; } | 51 void SimulateTimeout() { simulate_timeout_ = true; } |
70 | 52 |
71 protected: | 53 protected: |
72 ~FakeSafeBrowsingDatabaseManager() override {} | 54 ~FakeSafeBrowsingDatabaseManager() override {} |
73 | 55 |
74 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override { | 56 bool CheckUrlForSubresourceFilter(const GURL& url, Client* client) override { |
75 if (simulate_timeout_) | 57 if (simulate_timeout_) |
76 return false; | 58 return false; |
77 if (!url_to_threat_type_.count(url)) | 59 if (!url_to_threat_type_.count(url)) |
78 return true; | 60 return true; |
79 | 61 |
| 62 safe_browsing::ThreatMetadata metadata; |
| 63 metadata.threat_pattern_type = url_to_threat_type_[url].second; |
80 content::BrowserThread::PostTask( | 64 content::BrowserThread::PostTask( |
81 content::BrowserThread::IO, FROM_HERE, | 65 content::BrowserThread::IO, FROM_HERE, |
82 base::Bind(&Client::OnCheckBrowseUrlResult, base::Unretained(client), | 66 base::Bind(&Client::OnCheckBrowseUrlResult, base::Unretained(client), |
83 url, url_to_threat_type_[url], | 67 url, url_to_threat_type_[url].first, metadata)); |
84 safe_browsing::ThreatMetadata())); | |
85 return false; | 68 return false; |
86 } | 69 } |
87 | 70 |
88 bool CheckResourceUrl(const GURL& url, Client* client) override { | 71 bool CheckResourceUrl(const GURL& url, Client* client) override { |
89 return true; | 72 return true; |
90 } | 73 } |
91 | 74 |
92 bool IsSupported() const override { return true; } | 75 bool IsSupported() const override { return true; } |
93 bool ChecksAreAlwaysAsync() const override { return false; } | 76 bool ChecksAreAlwaysAsync() const override { return false; } |
94 bool CanCheckResourceType( | 77 bool CanCheckResourceType( |
95 content::ResourceType /* resource_type */) const override { | 78 content::ResourceType /* resource_type */) const override { |
96 return true; | 79 return true; |
97 } | 80 } |
98 | 81 |
99 safe_browsing::ThreatSource GetThreatSource() const override { | 82 safe_browsing::ThreatSource GetThreatSource() const override { |
100 return safe_browsing::ThreatSource::LOCAL_PVER4; | 83 return safe_browsing::ThreatSource::LOCAL_PVER4; |
101 } | 84 } |
102 | 85 |
103 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, | 86 bool CheckExtensionIDs(const std::set<std::string>& extension_ids, |
104 Client* client) override { | 87 Client* client) override { |
105 return true; | 88 return true; |
106 } | 89 } |
107 | 90 |
108 private: | 91 private: |
109 std::map<GURL, safe_browsing::SBThreatType> url_to_threat_type_; | 92 std::map< |
| 93 GURL, |
| 94 std::pair<safe_browsing::SBThreatType, safe_browsing::ThreatPatternType>> |
| 95 url_to_threat_type_; |
110 bool simulate_timeout_; | 96 bool simulate_timeout_; |
111 | 97 |
112 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); | 98 DISALLOW_COPY_AND_ASSIGN(FakeSafeBrowsingDatabaseManager); |
113 }; | 99 }; |
114 | 100 |
115 class MockSubresourceFilterClient | 101 class MockSubresourceFilterClient |
116 : public subresource_filter::SubresourceFilterClient { | 102 : public subresource_filter::SubresourceFilterClient { |
117 public: | 103 public: |
118 MockSubresourceFilterClient() {} | 104 MockSubresourceFilterClient() {} |
119 | 105 |
(...skipping 23 matching lines...) Expand all Loading... |
143 ContentSubresourceFilterDriverFactory* factory = | 129 ContentSubresourceFilterDriverFactory* factory = |
144 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); | 130 ContentSubresourceFilterDriverFactory::FromWebContents(web_contents); |
145 factory->WillProcessResponse(navigation_handle()); | 131 factory->WillProcessResponse(navigation_handle()); |
146 return content::NavigationThrottle::PROCEED; | 132 return content::NavigationThrottle::PROCEED; |
147 } | 133 } |
148 | 134 |
149 private: | 135 private: |
150 DISALLOW_COPY_AND_ASSIGN(TestForwardingNavigationThrottle); | 136 DISALLOW_COPY_AND_ASSIGN(TestForwardingNavigationThrottle); |
151 }; | 137 }; |
152 | 138 |
| 139 std::string GetSuffixForList(const ActivationList& type) { |
| 140 switch (type) { |
| 141 case ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL: |
| 142 return "SocialEngineeringAdsInterstitial"; |
| 143 case ActivationList::PHISHING_INTERSTITIAL: |
| 144 return "PhishingInterstital"; |
| 145 case ActivationList::SUBRESOURCE_FILTER: |
| 146 return "SubresourceFilterOnly"; |
| 147 case ActivationList::NONE: |
| 148 return std::string(); |
| 149 } |
| 150 return std::string(); |
| 151 } |
| 152 |
| 153 struct ActivationListTestData { |
| 154 const char* const activation_list; |
| 155 ActivationList activation_list_type; |
| 156 safe_browsing::SBThreatType threat_type; |
| 157 safe_browsing::ThreatPatternType threat_type_metadata; |
| 158 }; |
| 159 |
| 160 const ActivationListTestData kActivationListTestData[] = { |
| 161 {subresource_filter::kActivationListSocialEngineeringAdsInterstitial, |
| 162 ActivationList::SOCIAL_ENG_ADS_INTERSTITIAL, |
| 163 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 164 safe_browsing::ThreatPatternType::SOCIAL_ENGINEERING_ADS}, |
| 165 {subresource_filter::kActivationListPhishingInterstitial, |
| 166 ActivationList::PHISHING_INTERSTITIAL, |
| 167 safe_browsing::SB_THREAT_TYPE_URL_PHISHING, |
| 168 safe_browsing::ThreatPatternType::NONE}, |
| 169 {subresource_filter::kActivationListSubresourceFilter, |
| 170 ActivationList::SUBRESOURCE_FILTER, |
| 171 safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER, |
| 172 safe_browsing::ThreatPatternType::NONE}, |
| 173 }; |
| 174 |
153 } // namespace | 175 } // namespace |
154 | 176 |
155 class SubresourceFilterSafeBrowsingActivationThrottleTest | 177 class SubresourceFilterSafeBrowsingActivationThrottleTest |
156 : public content::RenderViewHostTestHarness, | 178 : public content::RenderViewHostTestHarness, |
157 public content::WebContentsObserver { | 179 public content::WebContentsObserver, |
| 180 public ::testing::WithParamInterface<ActivationListTestData> { |
158 public: | 181 public: |
159 SubresourceFilterSafeBrowsingActivationThrottleTest() | 182 SubresourceFilterSafeBrowsingActivationThrottleTest() |
160 : field_trial_list_(nullptr) {} | 183 : field_trial_list_(nullptr) {} |
161 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} | 184 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} |
162 | 185 |
163 void SetUp() override { | 186 void SetUp() override { |
164 content::RenderViewHostTestHarness::SetUp(); | 187 content::RenderViewHostTestHarness::SetUp(); |
| 188 const ActivationListTestData& test_data = GetParam(); |
165 scoped_feature_toggle_.reset( | 189 scoped_feature_toggle_.reset( |
166 new testing::ScopedSubresourceFilterFeatureToggle( | 190 new testing::ScopedSubresourceFilterFeatureToggle( |
167 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 191 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, |
168 kActivationScopeActivationList, kActivationListSubresourceFilter)); | 192 kActivationScopeActivationList, test_data.activation_list)); |
169 auto client = base::MakeUnique<MockSubresourceFilterClient>(); | 193 auto client = base::MakeUnique<MockSubresourceFilterClient>(); |
170 ContentSubresourceFilterDriverFactory::CreateForWebContents( | 194 ContentSubresourceFilterDriverFactory::CreateForWebContents( |
171 RenderViewHostTestHarness::web_contents(), std::move(client)); | 195 RenderViewHostTestHarness::web_contents(), std::move(client)); |
172 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); | 196 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); |
173 NavigateAndCommit(GURL("https://test.com")); | 197 NavigateAndCommit(GURL("https://test.com")); |
174 Observe(RenderViewHostTestHarness::web_contents()); | 198 Observe(RenderViewHostTestHarness::web_contents()); |
175 } | 199 } |
176 | 200 |
177 ContentSubresourceFilterDriverFactory* factory() { | 201 ContentSubresourceFilterDriverFactory* factory() { |
178 return ContentSubresourceFilterDriverFactory::FromWebContents( | 202 return ContentSubresourceFilterDriverFactory::FromWebContents( |
(...skipping 29 matching lines...) Expand all Loading... |
208 EXPECT_EQ(content::NavigationThrottle::PROCEED, | 232 EXPECT_EQ(content::NavigationThrottle::PROCEED, |
209 navigation_simulator_->GetLastThrottleCheckResult()); | 233 navigation_simulator_->GetLastThrottleCheckResult()); |
210 } | 234 } |
211 | 235 |
212 void CreateTestNavigationForMainFrame(const GURL& first_url) { | 236 void CreateTestNavigationForMainFrame(const GURL& first_url) { |
213 navigation_simulator_ = | 237 navigation_simulator_ = |
214 content::NavigationSimulator::CreateRendererInitiated(first_url, | 238 content::NavigationSimulator::CreateRendererInitiated(first_url, |
215 main_rfh()); | 239 main_rfh()); |
216 } | 240 } |
217 | 241 |
218 void ConfigureAsSubresourceFilterOnlyURL(const GURL& url) { | 242 void ConfigureForMatch(const GURL& url) { |
| 243 const ActivationListTestData& test_data = GetParam(); |
219 fake_safe_browsing_database_->AddBlacklistedUrl( | 244 fake_safe_browsing_database_->AddBlacklistedUrl( |
220 url, safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER); | 245 url, test_data.threat_type, test_data.threat_type_metadata); |
221 } | 246 } |
222 | 247 |
223 void SimulateTimeout() { fake_safe_browsing_database_->SimulateTimeout(); } | 248 void SimulateTimeout() { fake_safe_browsing_database_->SimulateTimeout(); } |
224 | 249 |
225 const base::HistogramTester& tester() const { return tester_; } | 250 const base::HistogramTester& tester() const { return tester_; } |
226 | 251 |
227 private: | 252 private: |
228 base::FieldTrialList field_trial_list_; | 253 base::FieldTrialList field_trial_list_; |
229 std::unique_ptr<testing::ScopedSubresourceFilterFeatureToggle> | 254 std::unique_ptr<testing::ScopedSubresourceFilterFeatureToggle> |
230 scoped_feature_toggle_; | 255 scoped_feature_toggle_; |
231 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; | 256 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; |
232 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; | 257 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; |
233 base::HistogramTester tester_; | 258 base::HistogramTester tester_; |
234 content::NavigationHandle* navigation_handle_; | 259 content::NavigationHandle* navigation_handle_; |
235 | 260 |
236 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); | 261 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); |
237 }; | 262 }; |
238 | 263 |
239 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 264 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTest, |
240 ListNotMatched_NoActivation) { | 265 ListNotMatched_NoActivation) { |
| 266 const ActivationListTestData& test_data = GetParam(); |
241 const GURL url(kURL); | 267 const GURL url(kURL); |
| 268 const std::string suffix(GetSuffixForList(test_data.activation_list_type)); |
242 CreateTestNavigationForMainFrame(url); | 269 CreateTestNavigationForMainFrame(url); |
243 SimulateStartAndExpectProceed(); | 270 SimulateStartAndExpectProceed(); |
244 SimulateCommitAndExpectProceed(); | 271 SimulateCommitAndExpectProceed(); |
245 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: | 272 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: |
246 ACTIVATION_LIST_NOT_MATCHED, | 273 ACTIVATION_LIST_NOT_MATCHED, |
247 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 274 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
248 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, | 275 tester().ExpectTotalCount(kMatchesPatternHistogramName + suffix, 0); |
249 0); | 276 tester().ExpectTotalCount(kNavigationChainSize + suffix, 0); |
250 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); | |
251 } | 277 } |
252 | 278 |
253 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 279 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTest, |
254 ListMatched_Activation) { | 280 ListMatched_Activation) { |
| 281 const ActivationListTestData& test_data = GetParam(); |
255 const GURL url(kURL); | 282 const GURL url(kURL); |
256 ConfigureAsSubresourceFilterOnlyURL(url); | 283 const std::string suffix(GetSuffixForList(test_data.activation_list_type)); |
| 284 ConfigureForMatch(url); |
257 CreateTestNavigationForMainFrame(url); | 285 CreateTestNavigationForMainFrame(url); |
258 SimulateStartAndExpectProceed(); | 286 SimulateStartAndExpectProceed(); |
259 SimulateCommitAndExpectProceed(); | 287 SimulateCommitAndExpectProceed(); |
260 EXPECT_EQ( | 288 EXPECT_EQ( |
261 ContentSubresourceFilterDriverFactory::ActivationDecision::ACTIVATED, | 289 ContentSubresourceFilterDriverFactory::ActivationDecision::ACTIVATED, |
262 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 290 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
263 tester().ExpectUniqueSample( | 291 tester().ExpectTotalCount(kMatchesPatternHistogramName + suffix, 1); |
264 kMatchesPatternHistogramNameSubresourceFilterSuffix, NO_REDIRECTS_HIT, 1); | 292 tester().ExpectUniqueSample(kNavigationChainSize + suffix, 1, 1); |
265 tester().ExpectUniqueSample(kNavigationChainSizeSubresourceFilterSuffix, 1, | |
266 1); | |
267 } | 293 } |
268 | 294 |
269 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 295 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTest, |
270 ListNotMatchedAfterRedirect_NoActivation) { | 296 ListNotMatchedAfterRedirect_NoActivation) { |
| 297 const ActivationListTestData& test_data = GetParam(); |
271 const GURL url(kURL); | 298 const GURL url(kURL); |
| 299 const std::string suffix(GetSuffixForList(test_data.activation_list_type)); |
272 CreateTestNavigationForMainFrame(url); | 300 CreateTestNavigationForMainFrame(url); |
273 SimulateStartAndExpectProceed(); | 301 SimulateStartAndExpectProceed(); |
274 SimulateRedirectAndExpectProceed(GURL(kRedirectURL)); | 302 SimulateRedirectAndExpectProceed(GURL(kRedirectURL)); |
275 SimulateCommitAndExpectProceed(); | 303 SimulateCommitAndExpectProceed(); |
276 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: | 304 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: |
277 ACTIVATION_LIST_NOT_MATCHED, | 305 ACTIVATION_LIST_NOT_MATCHED, |
278 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 306 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
279 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, | 307 tester().ExpectTotalCount(kMatchesPatternHistogramName + suffix, 0); |
280 0); | 308 tester().ExpectTotalCount(kNavigationChainSize + suffix, 0); |
281 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); | |
282 } | 309 } |
283 | 310 |
284 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 311 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTest, |
285 ListMatchedAfterRedirect_Activation) { | 312 ListMatchedAfterRedirect_Activation) { |
| 313 const ActivationListTestData& test_data = GetParam(); |
286 const GURL url(kURL); | 314 const GURL url(kURL); |
287 ConfigureAsSubresourceFilterOnlyURL(GURL(kRedirectURL)); | 315 const std::string suffix(GetSuffixForList(test_data.activation_list_type)); |
| 316 ConfigureForMatch(GURL(kRedirectURL)); |
288 CreateTestNavigationForMainFrame(url); | 317 CreateTestNavigationForMainFrame(url); |
289 SimulateStartAndExpectProceed(); | 318 SimulateStartAndExpectProceed(); |
290 SimulateRedirectAndExpectProceed(GURL(kRedirectURL)); | 319 SimulateRedirectAndExpectProceed(GURL(kRedirectURL)); |
291 SimulateCommitAndExpectProceed(); | 320 SimulateCommitAndExpectProceed(); |
292 EXPECT_EQ( | 321 EXPECT_EQ( |
293 ContentSubresourceFilterDriverFactory::ActivationDecision::ACTIVATED, | 322 ContentSubresourceFilterDriverFactory::ActivationDecision::ACTIVATED, |
294 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 323 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
295 tester().ExpectUniqueSample( | 324 tester().ExpectTotalCount(kMatchesPatternHistogramName + suffix, 1); |
296 kMatchesPatternHistogramNameSubresourceFilterSuffix, F0M0L1, 1); | 325 tester().ExpectUniqueSample(kNavigationChainSize + suffix, 2, 1); |
297 tester().ExpectUniqueSample(kNavigationChainSizeSubresourceFilterSuffix, 2, | |
298 1); | |
299 } | 326 } |
300 | 327 |
301 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 328 TEST_P(SubresourceFilterSafeBrowsingActivationThrottleTest, |
302 ListNotMatchedAndTimeout_NoActivation) { | 329 ListNotMatchedAndTimeout_NoActivation) { |
| 330 const ActivationListTestData& test_data = GetParam(); |
303 const GURL url(kURL); | 331 const GURL url(kURL); |
| 332 const std::string suffix(GetSuffixForList(test_data.activation_list_type)); |
304 SimulateTimeout(); | 333 SimulateTimeout(); |
305 CreateTestNavigationForMainFrame(url); | 334 CreateTestNavigationForMainFrame(url); |
306 SimulateStartAndExpectProceed(); | 335 SimulateStartAndExpectProceed(); |
307 SimulateCommitAndExpectProceed(); | 336 SimulateCommitAndExpectProceed(); |
308 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: | 337 EXPECT_EQ(ContentSubresourceFilterDriverFactory::ActivationDecision:: |
309 ACTIVATION_LIST_NOT_MATCHED, | 338 ACTIVATION_LIST_NOT_MATCHED, |
310 factory()->GetActivationDecisionForLastCommittedPageLoad()); | 339 factory()->GetActivationDecisionForLastCommittedPageLoad()); |
311 tester().ExpectTotalCount(kMatchesPatternHistogramNameSubresourceFilterSuffix, | 340 tester().ExpectTotalCount(kMatchesPatternHistogramName + suffix, 0); |
312 0); | 341 tester().ExpectTotalCount(kNavigationChainSize + suffix, 0); |
313 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); | |
314 } | 342 } |
315 | 343 |
316 // TODO(melandory): Once non-defering check in WillStart is implemented add one | 344 // TODO(melandory): Once non-defering check in WillStart is implemented add one |
317 // more test that destroys the Navigation along with corresponding throttles | 345 // more test that destroys the Navigation along with corresponding throttles |
318 // while the SB check is pending? (To be run by ASAN bots to ensure | 346 // while the SB check is pending? (To be run by ASAN bots to ensure |
319 // no use-after-free.) | 347 // no use-after-free.) |
320 | 348 |
| 349 INSTANTIATE_TEST_CASE_P(ActivationLevelTest, |
| 350 SubresourceFilterSafeBrowsingActivationThrottleTest, |
| 351 ::testing::ValuesIn(kActivationListTestData)); |
| 352 |
321 } // namespace subresource_filter | 353 } // namespace subresource_filter |
OLD | NEW |