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/activation_state_computi
ng_navigation_throttle.h" | 5 #include "components/subresource_filter/content/browser/activation_state_computi
ng_navigation_throttle.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <utility> | 8 #include <utility> |
| 9 #include <vector> |
9 | 10 |
10 #include "base/callback.h" | 11 #include "base/callback.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
13 #include "base/optional.h" | 14 #include "base/optional.h" |
14 #include "base/run_loop.h" | 15 #include "base/run_loop.h" |
15 #include "base/test/test_simple_task_runner.h" | 16 #include "base/test/test_simple_task_runner.h" |
16 #include "components/subresource_filter/content/browser/async_document_subresour
ce_filter.h" | 17 #include "components/subresource_filter/content/browser/async_document_subresour
ce_filter.h" |
17 #include "components/subresource_filter/content/browser/async_document_subresour
ce_filter_test_utils.h" | 18 #include "components/subresource_filter/content/browser/async_document_subresour
ce_filter_test_utils.h" |
18 #include "components/subresource_filter/core/common/activation_level.h" | 19 #include "components/subresource_filter/core/common/activation_level.h" |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 navigation_simulator_->GetLastThrottleCheckResult()); | 127 navigation_simulator_->GetLastThrottleCheckResult()); |
127 } | 128 } |
128 | 129 |
129 void SimulateCommitAndExpectToProceed() { | 130 void SimulateCommitAndExpectToProceed() { |
130 navigation_simulator_->Commit(); | 131 navigation_simulator_->Commit(); |
131 EXPECT_EQ(content::NavigationThrottle::PROCEED, | 132 EXPECT_EQ(content::NavigationThrottle::PROCEED, |
132 navigation_simulator_->GetLastThrottleCheckResult()); | 133 navigation_simulator_->GetLastThrottleCheckResult()); |
133 } | 134 } |
134 | 135 |
135 void NotifyPageActivation(ActivationState state) { | 136 void NotifyPageActivation(ActivationState state) { |
136 test_throttle_->NotifyPageActivationWithRuleset( | 137 if (state.activation_level == ActivationLevel::DISABLED) { |
137 state.activation_level == ActivationLevel::DISABLED | 138 test_throttle_->NotifyPageActivationWithRuleset( |
138 ? nullptr | 139 nullptr, state, ActivationDecision::ACTIVATION_DISABLED); |
139 : ruleset_handle_.get(), | 140 } else { |
140 state); | 141 test_throttle_->NotifyPageActivationWithRuleset( |
| 142 ruleset_handle_.get(), state, ActivationDecision::ACTIVATED); |
| 143 } |
141 } | 144 } |
142 | 145 |
143 ActivationState last_activation_state() { | 146 ActivationState last_activation_state() { |
144 EXPECT_TRUE(last_activation_state_.has_value()); | 147 EXPECT_TRUE(last_activation_state_.has_value()); |
145 return last_activation_state_.value_or( | 148 return last_activation_state_.value_or( |
146 ActivationState(ActivationLevel::DISABLED)); | 149 ActivationState(ActivationLevel::DISABLED)); |
147 } | 150 } |
148 | 151 |
149 content::RenderFrameHost* last_committed_frame_host() { | 152 content::RenderFrameHost* last_committed_frame_host() { |
150 return last_committed_frame_host_; | 153 return last_committed_frame_host_; |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 SimulateStartAndExpectToProceed(); | 410 SimulateStartAndExpectToProceed(); |
408 SimulateCommitAndExpectToProceed(); | 411 SimulateCommitAndExpectToProceed(); |
409 | 412 |
410 state = last_activation_state(); | 413 state = last_activation_state(); |
411 EXPECT_EQ(ActivationLevel::ENABLED, state.activation_level); | 414 EXPECT_EQ(ActivationLevel::ENABLED, state.activation_level); |
412 EXPECT_TRUE(state.filtering_disabled_for_document); | 415 EXPECT_TRUE(state.filtering_disabled_for_document); |
413 EXPECT_TRUE(state.generic_blocking_rules_disabled); | 416 EXPECT_TRUE(state.generic_blocking_rules_disabled); |
414 } | 417 } |
415 | 418 |
416 } // namespace subresource_filter | 419 } // namespace subresource_filter |
OLD | NEW |