| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "content/browser/loader/url_loader_factory_impl.h" | 5 #include "content/browser/loader/url_loader_factory_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 #include "mojo/public/cpp/system/data_pipe.h" | 44 #include "mojo/public/cpp/system/data_pipe.h" |
| 45 #include "net/base/io_buffer.h" | 45 #include "net/base/io_buffer.h" |
| 46 #include "net/base/net_errors.h" | 46 #include "net/base/net_errors.h" |
| 47 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
| 48 #include "net/http/http_response_info.h" | 48 #include "net/http/http_response_info.h" |
| 49 #include "net/http/http_status_code.h" | 49 #include "net/http/http_status_code.h" |
| 50 #include "net/http/http_util.h" | 50 #include "net/http/http_util.h" |
| 51 #include "net/test/url_request/url_request_failed_job.h" | 51 #include "net/test/url_request/url_request_failed_job.h" |
| 52 #include "net/test/url_request/url_request_mock_http_job.h" | 52 #include "net/test/url_request/url_request_mock_http_job.h" |
| 53 #include "net/test/url_request/url_request_slow_download_job.h" | 53 #include "net/test/url_request/url_request_slow_download_job.h" |
| 54 #include "net/traffic_annotation/network_traffic_annotation_test_helper.h" |
| 54 #include "net/url_request/url_request_filter.h" | 55 #include "net/url_request/url_request_filter.h" |
| 55 #include "testing/gtest/include/gtest/gtest.h" | 56 #include "testing/gtest/include/gtest/gtest.h" |
| 56 #include "url/gurl.h" | 57 #include "url/gurl.h" |
| 57 #include "url/origin.h" | 58 #include "url/origin.h" |
| 58 | 59 |
| 59 namespace content { | 60 namespace content { |
| 60 | 61 |
| 61 namespace { | 62 namespace { |
| 62 | 63 |
| 63 constexpr int kChildId = 99; | 64 constexpr int kChildId = 99; |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); | 161 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); |
| 161 request.method = "GET"; | 162 request.method = "GET"; |
| 162 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 163 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 163 // enabled, the url scheme of frame type requests from the renderer process | 164 // enabled, the url scheme of frame type requests from the renderer process |
| 164 // must be blob scheme. | 165 // must be blob scheme. |
| 165 request.resource_type = RESOURCE_TYPE_XHR; | 166 request.resource_type = RESOURCE_TYPE_XHR; |
| 166 // Need to set |request_initiator| for non main frame type request. | 167 // Need to set |request_initiator| for non main frame type request. |
| 167 request.request_initiator = url::Origin(); | 168 request.request_initiator = url::Origin(); |
| 168 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, | 169 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, |
| 169 kRequestId, mojom::kURLLoadOptionNone, request, | 170 kRequestId, mojom::kURLLoadOptionNone, request, |
| 170 client.CreateInterfacePtr()); | 171 client.CreateInterfacePtr(), |
| 172 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 171 | 173 |
| 172 ASSERT_FALSE(client.has_received_response()); | 174 ASSERT_FALSE(client.has_received_response()); |
| 173 ASSERT_FALSE(client.response_body().is_valid()); | 175 ASSERT_FALSE(client.response_body().is_valid()); |
| 174 ASSERT_FALSE(client.has_received_completion()); | 176 ASSERT_FALSE(client.has_received_completion()); |
| 175 | 177 |
| 176 client.RunUntilResponseReceived(); | 178 client.RunUntilResponseReceived(); |
| 177 | 179 |
| 178 net::URLRequest* url_request = | 180 net::URLRequest* url_request = |
| 179 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); | 181 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); |
| 180 ASSERT_TRUE(url_request); | 182 ASSERT_TRUE(url_request); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 net::URLRequestFailedJob::AddUrlHandler(); | 236 net::URLRequestFailedJob::AddUrlHandler(); |
| 235 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( | 237 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( |
| 236 net::URLRequestFailedJob::START, net::ERR_TIMED_OUT); | 238 net::URLRequestFailedJob::START, net::ERR_TIMED_OUT); |
| 237 request.method = "GET"; | 239 request.method = "GET"; |
| 238 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 240 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 239 // enabled, the url scheme of frame type requests from the renderer process | 241 // enabled, the url scheme of frame type requests from the renderer process |
| 240 // must be blob scheme. | 242 // must be blob scheme. |
| 241 request.resource_type = RESOURCE_TYPE_XHR; | 243 request.resource_type = RESOURCE_TYPE_XHR; |
| 242 // Need to set |request_initiator| for non main frame type request. | 244 // Need to set |request_initiator| for non main frame type request. |
| 243 request.request_initiator = url::Origin(); | 245 request.request_initiator = url::Origin(); |
| 244 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, | 246 factory_->CreateLoaderAndStart( |
| 245 mojom::kURLLoadOptionNone, request, | 247 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request, |
| 246 client.CreateInterfacePtr()); | 248 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 247 | 249 |
| 248 client.RunUntilComplete(); | 250 client.RunUntilComplete(); |
| 249 ASSERT_FALSE(client.has_received_response()); | 251 ASSERT_FALSE(client.has_received_response()); |
| 250 ASSERT_FALSE(client.response_body().is_valid()); | 252 ASSERT_FALSE(client.response_body().is_valid()); |
| 251 | 253 |
| 252 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); | 254 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); |
| 253 EXPECT_EQ(0, client.completion_status().encoded_data_length); | 255 EXPECT_EQ(0, client.completion_status().encoded_data_length); |
| 254 EXPECT_EQ(0, client.completion_status().encoded_body_length); | 256 EXPECT_EQ(0, client.completion_status().encoded_body_length); |
| 255 } | 257 } |
| 256 | 258 |
| 257 // In this case, the loading fails after receiving a response. | 259 // In this case, the loading fails after receiving a response. |
| 258 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse2) { | 260 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse2) { |
| 259 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); | 261 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); |
| 260 mojom::URLLoaderPtr loader; | 262 mojom::URLLoaderPtr loader; |
| 261 ResourceRequest request; | 263 ResourceRequest request; |
| 262 TestURLLoaderClient client; | 264 TestURLLoaderClient client; |
| 263 net::URLRequestFailedJob::AddUrlHandler(); | 265 net::URLRequestFailedJob::AddUrlHandler(); |
| 264 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( | 266 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( |
| 265 net::URLRequestFailedJob::READ_ASYNC, net::ERR_TIMED_OUT); | 267 net::URLRequestFailedJob::READ_ASYNC, net::ERR_TIMED_OUT); |
| 266 request.method = "GET"; | 268 request.method = "GET"; |
| 267 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 269 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 268 // enabled, the url scheme of frame type requests from the renderer process | 270 // enabled, the url scheme of frame type requests from the renderer process |
| 269 // must be blob scheme. | 271 // must be blob scheme. |
| 270 request.resource_type = RESOURCE_TYPE_XHR; | 272 request.resource_type = RESOURCE_TYPE_XHR; |
| 271 // Need to set |request_initiator| for non main frame type request. | 273 // Need to set |request_initiator| for non main frame type request. |
| 272 request.request_initiator = url::Origin(); | 274 request.request_initiator = url::Origin(); |
| 273 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, | 275 factory_->CreateLoaderAndStart( |
| 274 mojom::kURLLoadOptionNone, request, | 276 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request, |
| 275 client.CreateInterfacePtr()); | 277 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 276 | 278 |
| 277 client.RunUntilComplete(); | 279 client.RunUntilComplete(); |
| 278 ASSERT_FALSE(client.has_received_response()); | 280 ASSERT_FALSE(client.has_received_response()); |
| 279 ASSERT_FALSE(client.response_body().is_valid()); | 281 ASSERT_FALSE(client.response_body().is_valid()); |
| 280 | 282 |
| 281 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); | 283 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); |
| 282 EXPECT_GT(client.completion_status().encoded_data_length, 0); | 284 EXPECT_GT(client.completion_status().encoded_data_length, 0); |
| 283 EXPECT_EQ(0, client.completion_status().encoded_body_length); | 285 EXPECT_EQ(0, client.completion_status().encoded_body_length); |
| 284 } | 286 } |
| 285 | 287 |
| 286 // This test tests a case where resource loading is cancelled before started. | 288 // This test tests a case where resource loading is cancelled before started. |
| 287 TEST_P(URLLoaderFactoryImplTest, InvalidURL) { | 289 TEST_P(URLLoaderFactoryImplTest, InvalidURL) { |
| 288 mojom::URLLoaderPtr loader; | 290 mojom::URLLoaderPtr loader; |
| 289 ResourceRequest request; | 291 ResourceRequest request; |
| 290 TestURLLoaderClient client; | 292 TestURLLoaderClient client; |
| 291 request.url = GURL(); | 293 request.url = GURL(); |
| 292 request.method = "GET"; | 294 request.method = "GET"; |
| 293 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 295 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 294 // enabled, the url scheme of frame type requests from the renderer process | 296 // enabled, the url scheme of frame type requests from the renderer process |
| 295 // must be blob scheme. | 297 // must be blob scheme. |
| 296 request.resource_type = RESOURCE_TYPE_XHR; | 298 request.resource_type = RESOURCE_TYPE_XHR; |
| 297 // Need to set |request_initiator| for non main frame type request. | 299 // Need to set |request_initiator| for non main frame type request. |
| 298 request.request_initiator = url::Origin(); | 300 request.request_initiator = url::Origin(); |
| 299 ASSERT_FALSE(request.url.is_valid()); | 301 ASSERT_FALSE(request.url.is_valid()); |
| 300 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, | 302 factory_->CreateLoaderAndStart( |
| 301 mojom::kURLLoadOptionNone, request, | 303 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request, |
| 302 client.CreateInterfacePtr()); | 304 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 303 | 305 |
| 304 client.RunUntilComplete(); | 306 client.RunUntilComplete(); |
| 305 ASSERT_FALSE(client.has_received_response()); | 307 ASSERT_FALSE(client.has_received_response()); |
| 306 ASSERT_FALSE(client.response_body().is_valid()); | 308 ASSERT_FALSE(client.response_body().is_valid()); |
| 307 | 309 |
| 308 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); | 310 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| 309 } | 311 } |
| 310 | 312 |
| 311 // This test tests a case where resource loading is cancelled before started. | 313 // This test tests a case where resource loading is cancelled before started. |
| 312 TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { | 314 TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { |
| 313 mojom::URLLoaderPtr loader; | 315 mojom::URLLoaderPtr loader; |
| 314 RejectingResourceDispatcherHostDelegate rdh_delegate; | 316 RejectingResourceDispatcherHostDelegate rdh_delegate; |
| 315 rdh_.SetDelegate(&rdh_delegate); | 317 rdh_.SetDelegate(&rdh_delegate); |
| 316 ResourceRequest request; | 318 ResourceRequest request; |
| 317 TestURLLoaderClient client; | 319 TestURLLoaderClient client; |
| 318 request.url = GURL("http://localhost/"); | 320 request.url = GURL("http://localhost/"); |
| 319 request.method = "GET"; | 321 request.method = "GET"; |
| 320 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 322 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 321 // enabled, the url scheme of frame type requests from the renderer process | 323 // enabled, the url scheme of frame type requests from the renderer process |
| 322 // must be blob scheme. | 324 // must be blob scheme. |
| 323 request.resource_type = RESOURCE_TYPE_XHR; | 325 request.resource_type = RESOURCE_TYPE_XHR; |
| 324 // Need to set |request_initiator| for non main frame type request. | 326 // Need to set |request_initiator| for non main frame type request. |
| 325 request.request_initiator = url::Origin(); | 327 request.request_initiator = url::Origin(); |
| 326 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, | 328 factory_->CreateLoaderAndStart( |
| 327 mojom::kURLLoadOptionNone, request, | 329 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request, |
| 328 client.CreateInterfacePtr()); | 330 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 329 | 331 |
| 330 client.RunUntilComplete(); | 332 client.RunUntilComplete(); |
| 331 rdh_.SetDelegate(nullptr); | 333 rdh_.SetDelegate(nullptr); |
| 332 | 334 |
| 333 ASSERT_FALSE(client.has_received_response()); | 335 ASSERT_FALSE(client.has_received_response()); |
| 334 ASSERT_FALSE(client.response_body().is_valid()); | 336 ASSERT_FALSE(client.response_body().is_valid()); |
| 335 | 337 |
| 336 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); | 338 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| 337 } | 339 } |
| 338 | 340 |
| 339 TEST_P(URLLoaderFactoryImplTest, DownloadToFile) { | 341 TEST_P(URLLoaderFactoryImplTest, DownloadToFile) { |
| 340 constexpr int32_t kRoutingId = 1; | 342 constexpr int32_t kRoutingId = 1; |
| 341 constexpr int32_t kRequestId = 2; | 343 constexpr int32_t kRequestId = 2; |
| 342 | 344 |
| 343 mojom::URLLoaderPtr loader; | 345 mojom::URLLoaderPtr loader; |
| 344 base::FilePath root; | 346 base::FilePath root; |
| 345 PathService::Get(DIR_TEST_DATA, &root); | 347 PathService::Get(DIR_TEST_DATA, &root); |
| 346 net::URLRequestMockHTTPJob::AddUrlHandlers(root, | 348 net::URLRequestMockHTTPJob::AddUrlHandlers(root, |
| 347 BrowserThread::GetBlockingPool()); | 349 BrowserThread::GetBlockingPool()); |
| 348 | 350 |
| 349 ResourceRequest request; | 351 ResourceRequest request; |
| 350 TestURLLoaderClient client; | 352 TestURLLoaderClient client; |
| 351 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); | 353 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); |
| 352 request.method = "GET"; | 354 request.method = "GET"; |
| 353 request.resource_type = RESOURCE_TYPE_XHR; | 355 request.resource_type = RESOURCE_TYPE_XHR; |
| 354 request.download_to_file = true; | 356 request.download_to_file = true; |
| 355 request.request_initiator = url::Origin(); | 357 request.request_initiator = url::Origin(); |
| 356 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, | 358 factory_->CreateLoaderAndStart( |
| 357 kRequestId, 0, request, | 359 mojo::MakeRequest(&loader), kRoutingId, kRequestId, 0, request, |
| 358 client.CreateInterfacePtr()); | 360 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 359 ASSERT_FALSE(client.has_received_response()); | 361 ASSERT_FALSE(client.has_received_response()); |
| 360 ASSERT_FALSE(client.has_data_downloaded()); | 362 ASSERT_FALSE(client.has_data_downloaded()); |
| 361 ASSERT_FALSE(client.has_received_completion()); | 363 ASSERT_FALSE(client.has_received_completion()); |
| 362 | 364 |
| 363 client.RunUntilResponseReceived(); | 365 client.RunUntilResponseReceived(); |
| 364 | 366 |
| 365 net::URLRequest* url_request = | 367 net::URLRequest* url_request = |
| 366 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); | 368 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); |
| 367 ASSERT_TRUE(url_request); | 369 ASSERT_TRUE(url_request); |
| 368 ResourceRequestInfoImpl* request_info = | 370 ResourceRequestInfoImpl* request_info = |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 PathService::Get(DIR_TEST_DATA, &root); | 415 PathService::Get(DIR_TEST_DATA, &root); |
| 414 net::URLRequestSlowDownloadJob::AddUrlHandler(); | 416 net::URLRequestSlowDownloadJob::AddUrlHandler(); |
| 415 | 417 |
| 416 ResourceRequest request; | 418 ResourceRequest request; |
| 417 TestURLLoaderClient client; | 419 TestURLLoaderClient client; |
| 418 request.url = GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl); | 420 request.url = GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl); |
| 419 request.method = "GET"; | 421 request.method = "GET"; |
| 420 request.resource_type = RESOURCE_TYPE_XHR; | 422 request.resource_type = RESOURCE_TYPE_XHR; |
| 421 request.download_to_file = true; | 423 request.download_to_file = true; |
| 422 request.request_initiator = url::Origin(); | 424 request.request_initiator = url::Origin(); |
| 423 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, | 425 factory_->CreateLoaderAndStart( |
| 424 kRequestId, 0, request, | 426 mojo::MakeRequest(&loader), kRoutingId, kRequestId, 0, request, |
| 425 client.CreateInterfacePtr()); | 427 client.CreateInterfacePtr(), TRAFFIC_ANNOTATION_FOR_TESTS); |
| 426 ASSERT_FALSE(client.has_received_response()); | 428 ASSERT_FALSE(client.has_received_response()); |
| 427 ASSERT_FALSE(client.has_data_downloaded()); | 429 ASSERT_FALSE(client.has_data_downloaded()); |
| 428 ASSERT_FALSE(client.has_received_completion()); | 430 ASSERT_FALSE(client.has_received_completion()); |
| 429 | 431 |
| 430 client.RunUntilResponseReceived(); | 432 client.RunUntilResponseReceived(); |
| 431 | 433 |
| 432 net::URLRequest* url_request = | 434 net::URLRequest* url_request = |
| 433 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); | 435 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); |
| 434 ASSERT_TRUE(url_request); | 436 ASSERT_TRUE(url_request); |
| 435 ResourceRequestInfoImpl* request_info = | 437 ResourceRequestInfoImpl* request_info = |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 478 request.method = "GET"; | 480 request.method = "GET"; |
| 479 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 481 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 480 // enabled, the url scheme of frame type requests from the renderer process | 482 // enabled, the url scheme of frame type requests from the renderer process |
| 481 // must be blob scheme. | 483 // must be blob scheme. |
| 482 request.resource_type = RESOURCE_TYPE_XHR; | 484 request.resource_type = RESOURCE_TYPE_XHR; |
| 483 // Need to set |request_initiator| for non main frame type request. | 485 // Need to set |request_initiator| for non main frame type request. |
| 484 request.request_initiator = url::Origin(); | 486 request.request_initiator = url::Origin(); |
| 485 request.report_raw_headers = true; | 487 request.report_raw_headers = true; |
| 486 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, | 488 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, |
| 487 kRequestId, mojom::kURLLoadOptionNone, request, | 489 kRequestId, mojom::kURLLoadOptionNone, request, |
| 488 client.CreateInterfacePtr()); | 490 client.CreateInterfacePtr(), |
| 491 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 489 | 492 |
| 490 client.RunUntilComplete(); | 493 client.RunUntilComplete(); |
| 491 | 494 |
| 492 std::string contents; | 495 std::string contents; |
| 493 while (true) { | 496 while (true) { |
| 494 char buffer[16]; | 497 char buffer[16]; |
| 495 uint32_t read_size = sizeof(buffer); | 498 uint32_t read_size = sizeof(buffer); |
| 496 MojoResult r = mojo::ReadDataRaw(client.response_body(), buffer, &read_size, | 499 MojoResult r = mojo::ReadDataRaw(client.response_body(), buffer, &read_size, |
| 497 MOJO_READ_DATA_FLAG_NONE); | 500 MOJO_READ_DATA_FLAG_NONE); |
| 498 if (r == MOJO_RESULT_FAILED_PRECONDITION) | 501 if (r == MOJO_RESULT_FAILED_PRECONDITION) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 request.method = "GET"; | 541 request.method = "GET"; |
| 539 request.is_main_frame = true; | 542 request.is_main_frame = true; |
| 540 // |resource_type| can't be a frame type. It is because when PlzNavigate is | 543 // |resource_type| can't be a frame type. It is because when PlzNavigate is |
| 541 // enabled, the url scheme of frame type requests from the renderer process | 544 // enabled, the url scheme of frame type requests from the renderer process |
| 542 // must be blob scheme. | 545 // must be blob scheme. |
| 543 request.resource_type = RESOURCE_TYPE_XHR; | 546 request.resource_type = RESOURCE_TYPE_XHR; |
| 544 // Need to set |request_initiator| for non main frame type request. | 547 // Need to set |request_initiator| for non main frame type request. |
| 545 request.request_initiator = url::Origin(); | 548 request.request_initiator = url::Origin(); |
| 546 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, | 549 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, |
| 547 kRequestId, mojom::kURLLoadOptionNone, request, | 550 kRequestId, mojom::kURLLoadOptionNone, request, |
| 548 client.CreateInterfacePtr()); | 551 client.CreateInterfacePtr(), |
| 552 TRAFFIC_ANNOTATION_FOR_TESTS); |
| 549 | 553 |
| 550 base::RunLoop().RunUntilIdle(); | 554 base::RunLoop().RunUntilIdle(); |
| 551 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); | 555 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| 552 ASSERT_FALSE(client.has_received_response()); | 556 ASSERT_FALSE(client.has_received_response()); |
| 553 ASSERT_FALSE(client.response_body().is_valid()); | 557 ASSERT_FALSE(client.response_body().is_valid()); |
| 554 ASSERT_FALSE(client.has_received_completion()); | 558 ASSERT_FALSE(client.has_received_completion()); |
| 555 | 559 |
| 556 loader = nullptr; | 560 loader = nullptr; |
| 557 base::RunLoop().RunUntilIdle(); | 561 base::RunLoop().RunUntilIdle(); |
| 558 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); | 562 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| 559 } | 563 } |
| 560 | 564 |
| 561 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, | 565 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| 562 URLLoaderFactoryImplTest, | 566 URLLoaderFactoryImplTest, |
| 563 ::testing::Values(128, 32 * 1024)); | 567 ::testing::Values(128, 32 * 1024)); |
| 564 | 568 |
| 565 } // namespace | 569 } // namespace |
| 566 | 570 |
| 567 } // namespace content | 571 } // namespace content |
| OLD | NEW |