| Index: content/browser/loader/resource_dispatcher_host_unittest.cc
|
| diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| index c99ff6d70321ff4fdf9a3bd6126167fc13db6e35..ae6c4b7577ec486f761f737b79b678de76f137d9 100644
|
| --- a/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| +++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
|
| @@ -27,8 +27,8 @@
|
| #include "content/browser/download/download_manager_impl.h"
|
| #include "content/browser/download/download_resource_handler.h"
|
| #include "content/browser/frame_host/navigation_request_info.h"
|
| -#include "content/browser/loader/cross_site_resource_handler.h"
|
| #include "content/browser/loader/detachable_resource_handler.h"
|
| +#include "content/browser/loader/navigation_resource_throttle.h"
|
| #include "content/browser/loader/navigation_url_loader.h"
|
| #include "content/browser/loader/resource_dispatcher_host_impl.h"
|
| #include "content/browser/loader/resource_loader.h"
|
| @@ -623,16 +623,6 @@ class TestUserData : public base::SupportsUserData::Data {
|
| bool* was_deleted_;
|
| };
|
|
|
| -class TransfersAllNavigationsContentBrowserClient
|
| - : public TestContentBrowserClient {
|
| - public:
|
| - bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
|
| - const GURL& current_url,
|
| - const GURL& new_url) override {
|
| - return true;
|
| - }
|
| -};
|
| -
|
| enum GenericResourceThrottleFlags {
|
| NONE = 0,
|
| DEFER_STARTING_REQUEST = 1 << 0,
|
| @@ -2462,6 +2452,7 @@ TEST_P(ResourceDispatcherHostTest, MimeSniffEmpty) {
|
|
|
| // Tests for crbug.com/31266 (Non-2xx + application/octet-stream).
|
| TEST_P(ResourceDispatcherHostTest, ForbiddenDownload) {
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| std::string raw_headers("HTTP/1.1 403 Forbidden\n"
|
| "Content-disposition: attachment; filename=blah\n"
|
| "Content-type: application/octet-stream\n\n");
|
| @@ -2489,6 +2480,8 @@ TEST_P(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
|
| return;
|
| }
|
|
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| +
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| int render_view_id = 0;
|
| @@ -2532,6 +2525,7 @@ TEST_P(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
|
|
|
| TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) {
|
| EXPECT_EQ(0, host_.pending_requests());
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
|
|
| int render_view_id = 0;
|
| int request_id = 1;
|
| @@ -2647,6 +2641,8 @@ TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
|
| if (IsBrowserSideNavigationEnabled())
|
| return;
|
|
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| +
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| int request_id = 1;
|
| @@ -2663,7 +2659,7 @@ TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextTransferred) {
|
|
|
| GlobalRequestID global_request_id(web_contents_filter_->child_id(),
|
| request_id);
|
| - host_.MarkAsTransferredNavigation(global_request_id, nullptr);
|
| + host_.MarkAsTransferredNavigation(global_request_id, base::Closure());
|
|
|
| // And now simulate a cancellation coming from the renderer.
|
| ResourceHostMsg_CancelRequest msg(request_id);
|
| @@ -2690,12 +2686,12 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) {
|
| SUCCEED() << "Test is not applicable with browser side navigation enabled";
|
| return;
|
| }
|
| - // This test expects the cross site request to be leaked, so it can transfer
|
| - // the request directly.
|
| - CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
|
|
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(true);
|
| +
|
| int render_view_id = 0;
|
| int request_id = 1;
|
|
|
| @@ -2705,11 +2701,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) {
|
|
|
| HandleScheme("http");
|
|
|
| - // Temporarily replace ContentBrowserClient with one that will trigger the
|
| - // transfer navigation code paths.
|
| - TransfersAllNavigationsContentBrowserClient new_client;
|
| - ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
| -
|
| MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| GURL("http://example.com/blah"),
|
| RESOURCE_TYPE_MAIN_FRAME);
|
| @@ -2728,9 +2719,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) {
|
| // MimeTypeResourceHandler.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
|
|
| - // Restore, now that we've set up a transfer.
|
| - SetBrowserClientForTesting(old_client);
|
| -
|
| // This second filter is used to emulate a second process.
|
| scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
|
|
|
| @@ -2763,9 +2751,9 @@ TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
|
| SUCCEED() << "Test is not applicable with browser side navigation enabled";
|
| return;
|
| }
|
| - // This test expects the cross site request to be leaked, so it can transfer
|
| - // the request directly.
|
| - CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
|
| +
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(true);
|
|
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| @@ -2780,11 +2768,6 @@ TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
|
|
|
| HandleScheme("http");
|
|
|
| - // Temporarily replace ContentBrowserClient with one that will trigger the
|
| - // transfer navigation code paths.
|
| - TransfersAllNavigationsContentBrowserClient new_client;
|
| - ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
| -
|
| // Make the first request.
|
| MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| GURL("http://example.com/blah"),
|
| @@ -2801,8 +2784,7 @@ TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
|
| // MimeTypeResourceHandler.
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
|
|
| - // Restore, now that we've set up a transfer.
|
| - SetBrowserClientForTesting(old_client);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(false);
|
|
|
| // This second filter is used to emulate a second process.
|
| scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
|
| @@ -2848,9 +2830,9 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
|
| SUCCEED() << "Test is not applicable with browser side navigation enabled";
|
| return;
|
| }
|
| - // This test expects the cross site request to be leaked, so it can transfer
|
| - // the request directly.
|
| - CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
|
| +
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(true);
|
|
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| @@ -2863,11 +2845,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
|
|
|
| HandleScheme("http");
|
|
|
| - // Temporarily replace ContentBrowserClient with one that will trigger the
|
| - // transfer navigation code paths.
|
| - TransfersAllNavigationsContentBrowserClient new_client;
|
| - ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
| -
|
| MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| GURL("http://example.com/blah"),
|
| RESOURCE_TYPE_MAIN_FRAME);
|
| @@ -2889,9 +2866,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| base::RunLoop().RunUntilIdle();
|
|
|
| - // Restore, now that we've set up a transfer.
|
| - SetBrowserClientForTesting(old_client);
|
| -
|
| // This second filter is used to emulate a second process.
|
| scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
|
|
|
| @@ -2922,9 +2896,9 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
|
| SUCCEED() << "Test is not applicable with browser side navigation enabled";
|
| return;
|
| }
|
| - // This test expects the cross site request to be leaked, so it can transfer
|
| - // the request directly.
|
| - CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
|
| +
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(true);
|
|
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| @@ -2939,11 +2913,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
|
|
|
| HandleScheme("http");
|
|
|
| - // Temporarily replace ContentBrowserClient with one that will trigger the
|
| - // transfer navigation code paths.
|
| - TransfersAllNavigationsContentBrowserClient new_client;
|
| - ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
| -
|
| // Create a first filter that can be deleted before the second one starts.
|
| {
|
| scoped_refptr<ForwardingFilter> first_filter = MakeForwardingFilter();
|
| @@ -2972,9 +2941,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
|
| }
|
| // The first filter is now deleted, as if the child process died.
|
|
|
| - // Restore.
|
| - SetBrowserClientForTesting(old_client);
|
| -
|
| // Make sure we don't hold onto the ResourceMessageFilter after it is deleted.
|
| GlobalRequestID first_global_request_id(first_child_id, request_id);
|
|
|
| @@ -3010,9 +2976,9 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| SUCCEED() << "Test is not applicable with browser side navigation enabled";
|
| return;
|
| }
|
| - // This test expects the cross site request to be leaked, so it can transfer
|
| - // the request directly.
|
| - CrossSiteResourceHandler::SetLeakRequestsForTesting(true);
|
| +
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| + NavigationResourceThrottle::SetForceTransferForTesting(true);
|
|
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| @@ -3025,11 +2991,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
|
|
| HandleScheme("http");
|
|
|
| - // Temporarily replace ContentBrowserClient with one that will trigger the
|
| - // transfer navigation code paths.
|
| - TransfersAllNavigationsContentBrowserClient new_client;
|
| - ContentBrowserClient* old_client = SetBrowserClientForTesting(&new_client);
|
| -
|
| MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
|
| GURL("http://example.com/blah"),
|
| RESOURCE_TYPE_MAIN_FRAME);
|
| @@ -3058,9 +3019,6 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
|
| base::RunLoop().RunUntilIdle();
|
|
|
| - // Restore.
|
| - SetBrowserClientForTesting(old_client);
|
| -
|
| // This second filter is used to emulate a second process.
|
| scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
|
|
|
| @@ -3100,6 +3058,7 @@ TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
|
| }
|
|
|
| TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) {
|
| + NavigationResourceThrottle::SetUIChecksAlwaysSuccedForTesting(true);
|
| EXPECT_EQ(0, host_.pending_requests());
|
|
|
| HandleScheme("http");
|
|
|