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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
102 class SubresourceFilterSafeBrowsingActivationThrottleTest | 102 class SubresourceFilterSafeBrowsingActivationThrottleTest |
103 : public content::RenderViewHostTestHarness, | 103 : public content::RenderViewHostTestHarness, |
104 public content::WebContentsObserver { | 104 public content::WebContentsObserver { |
105 public: | 105 public: |
106 SubresourceFilterSafeBrowsingActivationThrottleTest() | 106 SubresourceFilterSafeBrowsingActivationThrottleTest() |
107 : field_trial_list_(nullptr) {} | 107 : field_trial_list_(nullptr) {} |
108 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} | 108 ~SubresourceFilterSafeBrowsingActivationThrottleTest() override {} |
109 | 109 |
110 void SetUp() override { | 110 void SetUp() override { |
111 content::RenderViewHostTestHarness::SetUp(); | 111 content::RenderViewHostTestHarness::SetUp(); |
112 scoped_feature_toggle_.reset( | 112 scoped_configuration_.ResetConfiguration(Configuration( |
113 new testing::ScopedSubresourceFilterFeatureToggle( | 113 ActivationLevel::ENABLED, ActivationScope::ACTIVATION_LIST, |
Charlie Harrison
2017/04/25 19:36:21
#include activation_list, activation_scope, and ac
engedy
2017/04/25 20:13:24
Done.
| |
114 base::FeatureList::OVERRIDE_ENABLE_FEATURE, kActivationLevelEnabled, | 114 ActivationList::SUBRESOURCE_FILTER)); |
115 kActivationScopeActivationList, kActivationListSubresourceFilter)); | |
116 // Note: Using NiceMock to allow uninteresting calls and suppress warnings. | 115 // Note: Using NiceMock to allow uninteresting calls and suppress warnings. |
117 auto client = | 116 auto client = |
118 base::MakeUnique<::testing::NiceMock<MockSubresourceFilterClient>>(); | 117 base::MakeUnique<::testing::NiceMock<MockSubresourceFilterClient>>(); |
119 ContentSubresourceFilterDriverFactory::CreateForWebContents( | 118 ContentSubresourceFilterDriverFactory::CreateForWebContents( |
120 RenderViewHostTestHarness::web_contents(), std::move(client)); | 119 RenderViewHostTestHarness::web_contents(), std::move(client)); |
121 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); | 120 fake_safe_browsing_database_ = new FakeSafeBrowsingDatabaseManager(); |
122 NavigateAndCommit(GURL("https://test.com")); | 121 NavigateAndCommit(GURL("https://test.com")); |
123 Observe(RenderViewHostTestHarness::web_contents()); | 122 Observe(RenderViewHostTestHarness::web_contents()); |
124 } | 123 } |
125 | 124 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
168 fake_safe_browsing_database_->AddBlacklistedUrl( | 167 fake_safe_browsing_database_->AddBlacklistedUrl( |
169 url, safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER); | 168 url, safe_browsing::SB_THREAT_TYPE_SUBRESOURCE_FILTER); |
170 } | 169 } |
171 | 170 |
172 void SimulateTimeout() { fake_safe_browsing_database_->SimulateTimeout(); } | 171 void SimulateTimeout() { fake_safe_browsing_database_->SimulateTimeout(); } |
173 | 172 |
174 const base::HistogramTester& tester() const { return tester_; } | 173 const base::HistogramTester& tester() const { return tester_; } |
175 | 174 |
176 private: | 175 private: |
177 base::FieldTrialList field_trial_list_; | 176 base::FieldTrialList field_trial_list_; |
178 std::unique_ptr<testing::ScopedSubresourceFilterFeatureToggle> | 177 testing::ScopedSubresourceFilterConfigurator scoped_configuration_; |
179 scoped_feature_toggle_; | |
180 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; | 178 std::unique_ptr<content::NavigationSimulator> navigation_simulator_; |
181 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; | 179 scoped_refptr<FakeSafeBrowsingDatabaseManager> fake_safe_browsing_database_; |
182 base::HistogramTester tester_; | 180 base::HistogramTester tester_; |
183 content::NavigationHandle* navigation_handle_; | 181 content::NavigationHandle* navigation_handle_; |
184 | 182 |
185 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); | 183 DISALLOW_COPY_AND_ASSIGN(SubresourceFilterSafeBrowsingActivationThrottleTest); |
186 }; | 184 }; |
187 | 185 |
188 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, | 186 TEST_F(SubresourceFilterSafeBrowsingActivationThrottleTest, |
189 ListNotMatched_NoActivation) { | 187 ListNotMatched_NoActivation) { |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
261 0); | 259 0); |
262 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); | 260 tester().ExpectTotalCount(kNavigationChainSizeSubresourceFilterSuffix, 0); |
263 } | 261 } |
264 | 262 |
265 // TODO(melandory): Once non-defering check in WillStart is implemented add one | 263 // TODO(melandory): Once non-defering check in WillStart is implemented add one |
266 // more test that destroys the Navigation along with corresponding throttles | 264 // more test that destroys the Navigation along with corresponding throttles |
267 // while the SB check is pending? (To be run by ASAN bots to ensure | 265 // while the SB check is pending? (To be run by ASAN bots to ensure |
268 // no use-after-free.) | 266 // no use-after-free.) |
269 | 267 |
270 } // namespace subresource_filter | 268 } // namespace subresource_filter |
OLD | NEW |