| 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 60669a10d9e6996e414381d620c22e772953aa66..772c32ca52feae8fa664fe7eb0c16dbed7e03def 100644
|
| --- a/content/browser/frame_host/navigation_handle_impl_unittest.cc
|
| +++ b/content/browser/frame_host/navigation_handle_impl_unittest.cc
|
| @@ -2,10 +2,11 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "base/macros.h"
|
| #include "content/browser/frame_host/navigation_handle_impl.h"
|
| +#include "base/macros.h"
|
| #include "content/public/browser/navigation_throttle.h"
|
| #include "content/public/browser/ssl_status.h"
|
| +#include "content/public/common/browser_side_navigation_policy.h"
|
| #include "content/public/common/request_context_type.h"
|
| #include "content/test/test_render_frame_host.h"
|
| #include "content/test/test_web_contents.h"
|
| @@ -736,4 +737,90 @@ TEST_F(NavigationHandleImplTest, BlockResponseThenProceedWillProcessResponse) {
|
| EXPECT_EQ(0, proceed_throttle->will_process_response_calls());
|
| }
|
|
|
| +TEST_F(NavigationHandleImplTest, BlockRequestCustomNetError) {
|
| + TestNavigationThrottle* blocked_throttle = CreateTestNavigationThrottle(
|
| + {NavigationThrottle::BLOCK_REQUEST, net::ERR_BLOCKED_BY_ADMINISTRATOR});
|
| +
|
| + EXPECT_EQ(0, blocked_throttle->will_start_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_redirect_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_process_response_calls());
|
| +
|
| + // Simulate WillRedirectRequest. The request should not be deferred. The
|
| + // callback should have been called. The second throttle should not have
|
| + // been notified.
|
| + SimulateWillStartRequest();
|
| + EXPECT_FALSE(IsDeferringStart());
|
| + EXPECT_FALSE(IsDeferringRedirect());
|
| + EXPECT_FALSE(IsDeferringResponse());
|
| + EXPECT_TRUE(was_callback_called());
|
| + EXPECT_TRUE(IsCanceling());
|
| + EXPECT_NE(NavigationThrottle::ThrottleCheckResult(
|
| + NavigationThrottle::BLOCK_REQUEST),
|
| + callback_result());
|
| + EXPECT_EQ(NavigationThrottle::BLOCK_REQUEST, callback_result().action());
|
| + EXPECT_EQ(net::ERR_BLOCKED_BY_ADMINISTRATOR,
|
| + callback_result().net_error_code());
|
| + EXPECT_EQ(1, blocked_throttle->will_start_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_redirect_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_process_response_calls());
|
| +}
|
| +
|
| +TEST_F(NavigationHandleImplTest, BlockRequestCustomNetErrorInRedirect) {
|
| + // BLOCK_REQUEST on redirect requires PlzNavigate.
|
| + if (!IsBrowserSideNavigationEnabled())
|
| + return;
|
| +
|
| + TestNavigationThrottle* blocked_throttle = CreateTestNavigationThrottle(
|
| + {NavigationThrottle::BLOCK_REQUEST, net::ERR_FILE_NOT_FOUND});
|
| +
|
| + EXPECT_EQ(0, blocked_throttle->will_start_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_redirect_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_process_response_calls());
|
| +
|
| + // Simulate WillRedirectRequest. The request should not be deferred. The
|
| + // callback should have been called. The second throttle should not have
|
| + // been notified.
|
| + SimulateWillRedirectRequest();
|
| + EXPECT_FALSE(IsDeferringStart());
|
| + EXPECT_FALSE(IsDeferringRedirect());
|
| + EXPECT_FALSE(IsDeferringResponse());
|
| + EXPECT_TRUE(was_callback_called());
|
| + EXPECT_TRUE(IsCanceling());
|
| + EXPECT_NE(NavigationThrottle::ThrottleCheckResult(
|
| + NavigationThrottle::BLOCK_REQUEST),
|
| + callback_result());
|
| + EXPECT_EQ(NavigationThrottle::BLOCK_REQUEST, callback_result().action());
|
| + EXPECT_EQ(net::ERR_FILE_NOT_FOUND, callback_result().net_error_code());
|
| + EXPECT_EQ(0, blocked_throttle->will_start_calls());
|
| + EXPECT_EQ(1, blocked_throttle->will_redirect_calls());
|
| + EXPECT_EQ(0, blocked_throttle->will_process_response_calls());
|
| +}
|
| +
|
| +TEST_F(NavigationHandleImplTest, BlockResponseCustomNetError) {
|
| + TestNavigationThrottle* block_throttle = CreateTestNavigationThrottle(
|
| + {NavigationThrottle::BLOCK_RESPONSE, net::ERR_FILE_VIRUS_INFECTED});
|
| +
|
| + EXPECT_EQ(0, block_throttle->will_start_calls());
|
| + EXPECT_EQ(0, block_throttle->will_redirect_calls());
|
| + EXPECT_EQ(0, block_throttle->will_process_response_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_FALSE(IsDeferringResponse());
|
| + EXPECT_TRUE(was_callback_called());
|
| + EXPECT_TRUE(IsCanceling());
|
| + EXPECT_NE(NavigationThrottle::ThrottleCheckResult(
|
| + NavigationThrottle::BLOCK_RESPONSE),
|
| + callback_result());
|
| + EXPECT_EQ(NavigationThrottle::BLOCK_RESPONSE, callback_result().action());
|
| + EXPECT_EQ(net::ERR_FILE_VIRUS_INFECTED, callback_result().net_error_code());
|
| + EXPECT_EQ(0, block_throttle->will_start_calls());
|
| + EXPECT_EQ(0, block_throttle->will_redirect_calls());
|
| + EXPECT_EQ(1, block_throttle->will_process_response_calls());
|
| +}
|
| +
|
| } // namespace content
|
|
|