Chromium Code Reviews| Index: content/browser/loader/url_loader_factory_impl_unittest.cc |
| diff --git a/content/browser/loader/url_loader_factory_impl_unittest.cc b/content/browser/loader/url_loader_factory_impl_unittest.cc |
| index 97f81a3f83baffe065a8131a917f5d6bee7944bb..c1265f9100ce0294f91cb2e1f800bafa0afb5c7f 100644 |
| --- a/content/browser/loader/url_loader_factory_impl_unittest.cc |
| +++ b/content/browser/loader/url_loader_factory_impl_unittest.cc |
| @@ -33,7 +33,6 @@ |
| #include "content/public/browser/resource_context.h" |
| #include "content/public/browser/resource_dispatcher_host_delegate.h" |
| #include "content/public/common/content_paths.h" |
| -#include "content/public/common/process_type.h" |
| #include "content/public/test/test_browser_context.h" |
| #include "content/public/test/test_browser_thread_bundle.h" |
| #include "mojo/public/c/system/data_pipe.h" |
| @@ -73,6 +72,8 @@ class RejectingResourceDispatcherHostDelegate final |
| DISALLOW_COPY_AND_ASSIGN(RejectingResourceDispatcherHostDelegate); |
| }; |
| +} // namespace |
| + |
| // The test parameter is the number of bytes allocated for the buffer in the |
| // data pipe, for testing the case where the allocated size is smaller than the |
| // size the mime sniffer *implicitly* requires. |
| @@ -83,22 +84,17 @@ class URLLoaderFactoryImplTest : public ::testing::TestWithParam<size_t> { |
| browser_context_(new TestBrowserContext()), |
| resource_message_filter_(new ResourceMessageFilter( |
| kChildId, |
| - // If browser side navigation is enabled then |
| - // ResourceDispatcherHostImpl prevents main frame URL requests from |
| - // the renderer. Ensure that these checks don't trip us up by |
| - // setting the process type in ResourceMessageFilter as |
| - // PROCESS_TYPE_UNKNOWN. |
| - PROCESS_TYPE_UNKNOWN, |
| nullptr, |
| nullptr, |
| nullptr, |
| nullptr, |
| base::Bind(&URLLoaderFactoryImplTest::GetContexts, |
| base::Unretained(this)))) { |
| + resource_message_filter_->InitializeOnIOThread(); |
| MojoAsyncResourceHandler::SetAllocationSizeForTesting(GetParam()); |
| rdh_.SetLoaderDelegate(&loader_deleate_); |
| - URLLoaderFactoryImpl::Create(resource_message_filter_, |
| + URLLoaderFactoryImpl::Create(resource_message_filter_->requester_info(), |
| mojo::GetProxy(&factory_)); |
| // Calling this function creates a request context. |
| @@ -149,7 +145,12 @@ TEST_P(URLLoaderFactoryImplTest, GetResponse) { |
| // Assume the file contents is small enough to be stored in the data pipe. |
| request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); |
| request.method = "GET"; |
| - request.is_main_frame = true; |
| + // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| + // enabled, the url scheme of frame type requests from the renderer process |
| + // must be blob scheme. |
| + request.resource_type = RESOURCE_TYPE_XHR; |
| + // Need to set |request_initiator| for non main frame type request. |
| + request.request_initiator = url::Origin(); |
|
mmenke
2016/11/21 19:51:56
include url/origin.h
horo
2016/11/22 01:12:08
Done.
|
| factory_->CreateLoaderAndStart( |
| mojo::GetProxy(&loader, factory_.associated_group()), kRoutingId, |
| kRequestId, request, |
| @@ -214,6 +215,12 @@ TEST_P(URLLoaderFactoryImplTest, GetFailedResponse) { |
| request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( |
| net::URLRequestFailedJob::START, net::ERR_TIMED_OUT); |
| request.method = "GET"; |
| + // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| + // enabled, the url scheme of frame type requests from the renderer process |
| + // must be blob scheme. |
| + request.resource_type = RESOURCE_TYPE_XHR; |
| + // Need to set |request_initiator| for non main frame type request. |
| + request.request_initiator = url::Origin(); |
| factory_->CreateLoaderAndStart( |
| mojo::GetProxy(&loader, factory_.associated_group()), 2, 1, request, |
| client.CreateRemoteAssociatedPtrInfo(factory_.associated_group())); |
| @@ -232,6 +239,12 @@ TEST_P(URLLoaderFactoryImplTest, InvalidURL) { |
| TestURLLoaderClient client; |
| request.url = GURL(); |
| request.method = "GET"; |
| + // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| + // enabled, the url scheme of frame type requests from the renderer process |
| + // must be blob scheme. |
| + request.resource_type = RESOURCE_TYPE_XHR; |
| + // Need to set |request_initiator| for non main frame type request. |
| + request.request_initiator = url::Origin(); |
| ASSERT_FALSE(request.url.is_valid()); |
| factory_->CreateLoaderAndStart( |
| mojo::GetProxy(&loader, factory_.associated_group()), 2, 1, request, |
| @@ -253,6 +266,12 @@ TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { |
| TestURLLoaderClient client; |
| request.url = GURL("http://localhost/"); |
| request.method = "GET"; |
| + // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| + // enabled, the url scheme of frame type requests from the renderer process |
| + // must be blob scheme. |
| + request.resource_type = RESOURCE_TYPE_XHR; |
| + // Need to set |request_initiator| for non main frame type request. |
| + request.request_initiator = url::Origin(); |
| factory_->CreateLoaderAndStart( |
| mojo::GetProxy(&loader, factory_.associated_group()), 2, 1, request, |
| client.CreateRemoteAssociatedPtrInfo(factory_.associated_group())); |
| @@ -404,6 +423,12 @@ TEST_P(URLLoaderFactoryImplTest, CancelFromRenderer) { |
| request.url = net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING); |
| request.method = "GET"; |
| request.is_main_frame = true; |
| + // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| + // enabled, the url scheme of frame type requests from the renderer process |
| + // must be blob scheme. |
| + request.resource_type = RESOURCE_TYPE_XHR; |
| + // Need to set |request_initiator| for non main frame type request. |
| + request.request_initiator = url::Origin(); |
| factory_->CreateLoaderAndStart( |
| mojo::GetProxy(&loader, factory_.associated_group()), kRoutingId, |
| kRequestId, request, |
| @@ -424,6 +449,4 @@ INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| URLLoaderFactoryImplTest, |
| ::testing::Values(128, 32 * 1024)); |
| -} // namespace |
| - |
| } // namespace content |