Chromium Code Reviews| Index: content/browser/frame_host/navigation_handle_impl_unittest.cc |
| diff --git a/content/browser/frame_host/navigation_handle_impl_unittest.cc b/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| index ee999cb31b06a0f9fcfb7c50ab0f75e92fe0ef67..e08efeb63b9e6d60b8eac2223e866309dc118f90 100644 |
| --- a/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| +++ b/content/browser/frame_host/navigation_handle_impl_unittest.cc |
| @@ -9,9 +9,10 @@ |
| namespace content { |
| -// Test version of a NavigationThrottle. It will always return the same |
| +// Test version of a NavigationThrottle. It will always return the current |
| // NavigationThrottle::ThrottleCheckResult |result_|, It also monitors the |
| -// number of times WillStartRequest and WillRedirectRequest were called. |
| +// number of times WillStartRequest, WillRedirectRequest, and |
| +// WillProcessResponse were called. |
| class TestNavigationThrottle : public NavigationThrottle { |
| public: |
| TestNavigationThrottle(NavigationHandle* handle, |
| @@ -19,7 +20,8 @@ class TestNavigationThrottle : public NavigationThrottle { |
| : NavigationThrottle(handle), |
| result_(result), |
| will_start_calls_(0), |
| - will_redirect_calls_(0) {} |
| + will_redirect_calls_(0), |
| + will_process_response_calls_(0) {} |
| ~TestNavigationThrottle() override {} |
| @@ -33,16 +35,25 @@ class TestNavigationThrottle : public NavigationThrottle { |
| return result_; |
| } |
| + NavigationThrottle::ThrottleCheckResult WillProcessResponse() override { |
| + ++will_process_response_calls_; |
| + return result_; |
| + } |
| + |
| int will_start_calls() const { return will_start_calls_; } |
| int will_redirect_calls() const { return will_redirect_calls_; } |
| + int will_process_response_calls() const { |
| + return will_process_response_calls_; |
| + } |
| private: |
| // The result returned by the TestNavigationThrottle. |
| NavigationThrottle::ThrottleCheckResult result_; |
| - // The number of times WillStartRequest and WillRedirectRequest were called. |
| + // The number of times each handler was called. |
| int will_start_calls_; |
| int will_redirect_calls_; |
| + int will_process_response_calls_; |
| }; |
| class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
| @@ -72,6 +83,10 @@ class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
| return test_handle_->state() == NavigationHandleImpl::DEFERRING_REDIRECT; |
| } |
| + bool IsDeferringResponse() { |
| + return test_handle_->state() == NavigationHandleImpl::DEFERRING_RESPONSE; |
| + } |
| + |
| bool IsCanceling() { |
| return test_handle_->state() == NavigationHandleImpl::CANCELING; |
| } |
| @@ -108,6 +123,24 @@ class NavigationHandleImplTest : public RenderViewHostImplTestHarness { |
| base::Unretained(this))); |
| } |
| + // Helper function to call WillProcessResponse on |handle|. If this function |
| + // returns DEFER, |callback_result_| will be set to the actual result of the |
| + // throttle checks when they are finished. |
| + // TODO(clamy): this should also simulate that WillStartRequest was called if |
| + // it has not been called before. |
| + void SimulateWillProcessResponse() { |
| + was_callback_called_ = false; |
| + callback_result_ = NavigationThrottle::DEFER; |
| + |
| + // It's safe to use base::Unretained since the NavigationHandle is owned by |
| + // the NavigationHandleImplTest. |
| + test_handle_->WillProcessResponse( |
| + main_test_rfh(), |
|
clamy
2016/01/27 14:13:21
Now that we're adding this, could you add a check
|
| + scoped_refptr<net::HttpResponseHeaders>(), |
| + base::Bind(&NavigationHandleImplTest::UpdateThrottleCheckResult, |
| + base::Unretained(this))); |
| + } |
| + |
| // Returns the handle used in tests. |
| NavigationHandleImpl* test_handle() const { return test_handle_.get(); } |
| @@ -150,46 +183,79 @@ TEST_F(NavigationHandleImplTest, ResumeDeferred) { |
| CreateTestNavigationThrottle(NavigationThrottle::DEFER); |
| EXPECT_FALSE(IsDeferringStart()); |
| EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Simulate WillStartRequest. The request should be deferred. The callback |
| // should not have been called. |
| SimulateWillStartRequest(); |
| EXPECT_TRUE(IsDeferringStart()); |
| EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Resume the request. It should no longer be deferred and the callback |
| // should have been called. |
| test_handle()->Resume(); |
| EXPECT_FALSE(IsDeferringStart()); |
| EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| EXPECT_TRUE(was_callback_called()); |
| EXPECT_EQ(NavigationThrottle::PROCEED, callback_result()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Simulate WillRedirectRequest. The request should be deferred. The callback |
| // should not have been called. |
| SimulateWillRedirectRequest(); |
| EXPECT_FALSE(IsDeferringStart()); |
| EXPECT_TRUE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Resume the request. It should no longer be deferred and the callback |
| // should have been called. |
| test_handle()->Resume(); |
| EXPECT_FALSE(IsDeferringStart()); |
| EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| EXPECT_TRUE(was_callback_called()); |
| EXPECT_EQ(NavigationThrottle::PROCEED, callback_result()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| + |
| + // Simulate WillProcessResponse. It will be deferred. The callback should not |
| + // have been called. |
| + SimulateWillProcessResponse(); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_TRUE(IsDeferringResponse()); |
| + EXPECT_FALSE(was_callback_called()); |
| + EXPECT_EQ(1, test_throttle->will_start_calls()); |
| + EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(1, test_throttle->will_process_response_calls()); |
| + |
| + // Resume the request. It should no longer be deferred and the callback should |
| + // have been called. |
| + test_handle()->Resume(); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_FALSE(IsDeferringResponse()); |
| + EXPECT_TRUE(was_callback_called()); |
| + EXPECT_EQ(NavigationThrottle::PROCEED, callback_result()); |
| + EXPECT_EQ(1, test_throttle->will_start_calls()); |
| + EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(1, test_throttle->will_process_response_calls()); |
| } |
| // Checks that a navigation deferred during WillStartRequest can be properly |
| @@ -201,6 +267,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillStart) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Simulate WillStartRequest. The request should be deferred. The callback |
| // should not have been called. |
| @@ -210,6 +277,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillStart) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Cancel the request. The callback should have been called. |
| test_handle()->CancelDeferredNavigation( |
| @@ -221,6 +289,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillStart) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| } |
| // Checks that a navigation deferred during WillRedirectRequest can be properly |
| @@ -232,6 +301,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillRedirect) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Simulate WillRedirectRequest. The request should be deferred. The callback |
| // should not have been called. |
| @@ -241,6 +311,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillRedirect) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Cancel the request. The callback should have been called. |
| test_handle()->CancelDeferredNavigation( |
| @@ -252,6 +323,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredWillRedirect) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(1, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| } |
| // Checks that a navigation deferred can be canceled and not ignored. |
| @@ -262,6 +334,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredNoIgnore) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Simulate WillRedirectRequest. The request should be deferred. The callback |
| // should not have been called. |
| @@ -271,6 +344,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredNoIgnore) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| // Cancel the request. The callback should have been called with CANCEL, and |
| // not CANCEL_AND_IGNORE. |
| @@ -282,6 +356,7 @@ TEST_F(NavigationHandleImplTest, CancelDeferredNoIgnore) { |
| EXPECT_EQ(NavigationThrottle::CANCEL, callback_result()); |
| EXPECT_EQ(1, test_throttle->will_start_calls()); |
| EXPECT_EQ(0, test_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, test_throttle->will_process_response_calls()); |
| } |
| // Checks that a NavigationThrottle asking to defer followed by a |
| @@ -295,8 +370,10 @@ TEST_F(NavigationHandleImplTest, DeferThenProceed) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| // Simulate WillStartRequest. The request should be deferred. The callback |
| // should not have been called. The second throttle should not have been |
| @@ -307,6 +384,7 @@ TEST_F(NavigationHandleImplTest, DeferThenProceed) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| @@ -319,6 +397,7 @@ TEST_F(NavigationHandleImplTest, DeferThenProceed) { |
| EXPECT_EQ(NavigationThrottle::PROCEED, callback_result()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(1, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| @@ -331,6 +410,7 @@ TEST_F(NavigationHandleImplTest, DeferThenProceed) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(1, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(1, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| @@ -343,6 +423,7 @@ TEST_F(NavigationHandleImplTest, DeferThenProceed) { |
| EXPECT_EQ(NavigationThrottle::PROCEED, callback_result()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(1, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(1, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(1, proceed_throttle->will_redirect_calls()); |
| } |
| @@ -358,6 +439,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillStartRequest) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| @@ -370,6 +452,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillStartRequest) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| @@ -383,6 +466,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillStartRequest) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(1, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(1, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| } |
| @@ -398,6 +482,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillRedirectRequest) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, defer_throttle->will_start_calls()); |
| EXPECT_EQ(0, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| @@ -410,6 +495,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillRedirectRequest) { |
| EXPECT_FALSE(was_callback_called()); |
| EXPECT_EQ(0, defer_throttle->will_start_calls()); |
| EXPECT_EQ(1, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| @@ -423,6 +509,7 @@ TEST_F(NavigationHandleImplTest, DeferThenCancelWillRedirectRequest) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(0, defer_throttle->will_start_calls()); |
| EXPECT_EQ(1, defer_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, defer_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(1, cancel_throttle->will_redirect_calls()); |
| } |
| @@ -440,6 +527,7 @@ TEST_F(NavigationHandleImplTest, CancelThenProceedWillStartRequest) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| @@ -453,6 +541,7 @@ TEST_F(NavigationHandleImplTest, CancelThenProceedWillStartRequest) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(1, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| } |
| @@ -470,6 +559,7 @@ TEST_F(NavigationHandleImplTest, CancelThenProceedWillRedirectRequest) { |
| EXPECT_FALSE(IsDeferringRedirect()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| @@ -483,8 +573,74 @@ TEST_F(NavigationHandleImplTest, CancelThenProceedWillRedirectRequest) { |
| EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| EXPECT_EQ(1, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| +} |
| + |
| +// Checks that a NavigationThrottle asking to proceed followed by a |
| +// NavigationThrottle asking to cancel behave correctly in WillProcessResponse. |
| +// Both throttles will be called, and the request will be cancelled. |
| +TEST_F(NavigationHandleImplTest, ProceedThenCancelWillProcessResponse) { |
| + TestNavigationThrottle* proceed_throttle = |
| + CreateTestNavigationThrottle(NavigationThrottle::PROCEED); |
| + TestNavigationThrottle* cancel_throttle = |
| + CreateTestNavigationThrottle(NavigationThrottle::CANCEL_AND_IGNORE); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| + |
| + // Simulate WillRedirectRequest. The request should not be deferred. The |
| + // callback should have been called. |
| + SimulateWillProcessResponse(); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_TRUE(was_callback_called()); |
| + EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| + EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| + EXPECT_EQ(1, proceed_throttle->will_process_response_calls()); |
| +} |
| + |
| +// Checks that a NavigationThrottle asking to cancel followed by a |
| +// NavigationThrottle asking to proceed behave correctly in WillProcessResponse. |
| +// The navigation will be canceled directly, and the second throttle will not |
| +// be called. |
| +TEST_F(NavigationHandleImplTest, CancelThenProceedWillProcessResponse) { |
| + TestNavigationThrottle* cancel_throttle = |
| + CreateTestNavigationThrottle(NavigationThrottle::CANCEL_AND_IGNORE); |
| + TestNavigationThrottle* proceed_throttle = |
| + CreateTestNavigationThrottle(NavigationThrottle::PROCEED); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_process_response_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| + |
| + // Simulate WillRedirectRequest. The request should not be deferred. The |
| + // callback should have been called. The second throttle should not have |
| + // been notified. |
| + SimulateWillProcessResponse(); |
| + EXPECT_FALSE(IsDeferringStart()); |
| + EXPECT_FALSE(IsDeferringRedirect()); |
| + EXPECT_TRUE(was_callback_called()); |
| + EXPECT_EQ(NavigationThrottle::CANCEL_AND_IGNORE, callback_result()); |
| + EXPECT_EQ(0, cancel_throttle->will_start_calls()); |
| + EXPECT_EQ(0, cancel_throttle->will_redirect_calls()); |
| + EXPECT_EQ(1, cancel_throttle->will_process_response_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_start_calls()); |
| EXPECT_EQ(0, proceed_throttle->will_redirect_calls()); |
| + EXPECT_EQ(0, proceed_throttle->will_process_response_calls()); |
| } |
| } // namespace content |