Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(48)

Side by Side Diff: content/browser/loader/url_loader_factory_impl_unittest.cc

Issue 2893233002: Network traffic annotation added to URLLoaderImpl. (Closed)
Patch Set: Comment addressed, Merged. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 TestURLLoaderClient client; 159 TestURLLoaderClient client;
159 // Assume the file contents is small enough to be stored in the data pipe. 160 // Assume the file contents is small enough to be stored in the data pipe.
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(
169 kRequestId, mojom::kURLLoadOptionNone, request, 170 mojo::MakeRequest(&loader), kRoutingId, kRequestId,
170 client.CreateInterfacePtr()); 171 mojom::kURLLoadOptionNone, request, client.CreateInterfacePtr(),
172 net::MutableNetworkTrafficAnnotationTag(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
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(),
249 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
247 250
248 client.RunUntilComplete(); 251 client.RunUntilComplete();
249 ASSERT_FALSE(client.has_received_response()); 252 ASSERT_FALSE(client.has_received_response());
250 ASSERT_FALSE(client.response_body().is_valid()); 253 ASSERT_FALSE(client.response_body().is_valid());
251 254
252 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); 255 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code);
253 EXPECT_EQ(0, client.completion_status().encoded_data_length); 256 EXPECT_EQ(0, client.completion_status().encoded_data_length);
254 EXPECT_EQ(0, client.completion_status().encoded_body_length); 257 EXPECT_EQ(0, client.completion_status().encoded_body_length);
255 } 258 }
256 259
257 // In this case, the loading fails after receiving a response. 260 // In this case, the loading fails after receiving a response.
258 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse2) { 261 TEST_P(URLLoaderFactoryImplTest, GetFailedResponse2) {
259 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 262 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
260 mojom::URLLoaderAssociatedPtr loader; 263 mojom::URLLoaderAssociatedPtr loader;
261 ResourceRequest request; 264 ResourceRequest request;
262 TestURLLoaderClient client; 265 TestURLLoaderClient client;
263 net::URLRequestFailedJob::AddUrlHandler(); 266 net::URLRequestFailedJob::AddUrlHandler();
264 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase( 267 request.url = net::URLRequestFailedJob::GetMockHttpUrlWithFailurePhase(
265 net::URLRequestFailedJob::READ_ASYNC, net::ERR_TIMED_OUT); 268 net::URLRequestFailedJob::READ_ASYNC, net::ERR_TIMED_OUT);
266 request.method = "GET"; 269 request.method = "GET";
267 // |resource_type| can't be a frame type. It is because when PlzNavigate is 270 // |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 271 // enabled, the url scheme of frame type requests from the renderer process
269 // must be blob scheme. 272 // must be blob scheme.
270 request.resource_type = RESOURCE_TYPE_XHR; 273 request.resource_type = RESOURCE_TYPE_XHR;
271 // Need to set |request_initiator| for non main frame type request. 274 // Need to set |request_initiator| for non main frame type request.
272 request.request_initiator = url::Origin(); 275 request.request_initiator = url::Origin();
273 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, 276 factory_->CreateLoaderAndStart(
274 mojom::kURLLoadOptionNone, request, 277 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request,
275 client.CreateInterfacePtr()); 278 client.CreateInterfacePtr(),
279 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
276 280
277 client.RunUntilComplete(); 281 client.RunUntilComplete();
278 ASSERT_FALSE(client.has_received_response()); 282 ASSERT_FALSE(client.has_received_response());
279 ASSERT_FALSE(client.response_body().is_valid()); 283 ASSERT_FALSE(client.response_body().is_valid());
280 284
281 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code); 285 EXPECT_EQ(net::ERR_TIMED_OUT, client.completion_status().error_code);
282 EXPECT_GT(client.completion_status().encoded_data_length, 0); 286 EXPECT_GT(client.completion_status().encoded_data_length, 0);
283 EXPECT_EQ(0, client.completion_status().encoded_body_length); 287 EXPECT_EQ(0, client.completion_status().encoded_body_length);
284 } 288 }
285 289
286 // This test tests a case where resource loading is cancelled before started. 290 // This test tests a case where resource loading is cancelled before started.
287 TEST_P(URLLoaderFactoryImplTest, InvalidURL) { 291 TEST_P(URLLoaderFactoryImplTest, InvalidURL) {
288 mojom::URLLoaderAssociatedPtr loader; 292 mojom::URLLoaderAssociatedPtr loader;
289 ResourceRequest request; 293 ResourceRequest request;
290 TestURLLoaderClient client; 294 TestURLLoaderClient client;
291 request.url = GURL(); 295 request.url = GURL();
292 request.method = "GET"; 296 request.method = "GET";
293 // |resource_type| can't be a frame type. It is because when PlzNavigate is 297 // |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 298 // enabled, the url scheme of frame type requests from the renderer process
295 // must be blob scheme. 299 // must be blob scheme.
296 request.resource_type = RESOURCE_TYPE_XHR; 300 request.resource_type = RESOURCE_TYPE_XHR;
297 // Need to set |request_initiator| for non main frame type request. 301 // Need to set |request_initiator| for non main frame type request.
298 request.request_initiator = url::Origin(); 302 request.request_initiator = url::Origin();
299 ASSERT_FALSE(request.url.is_valid()); 303 ASSERT_FALSE(request.url.is_valid());
300 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, 304 factory_->CreateLoaderAndStart(
301 mojom::kURLLoadOptionNone, request, 305 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request,
302 client.CreateInterfacePtr()); 306 client.CreateInterfacePtr(),
307 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
303 308
304 client.RunUntilComplete(); 309 client.RunUntilComplete();
305 ASSERT_FALSE(client.has_received_response()); 310 ASSERT_FALSE(client.has_received_response());
306 ASSERT_FALSE(client.response_body().is_valid()); 311 ASSERT_FALSE(client.response_body().is_valid());
307 312
308 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); 313 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code);
309 } 314 }
310 315
311 // This test tests a case where resource loading is cancelled before started. 316 // This test tests a case where resource loading is cancelled before started.
312 TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { 317 TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) {
313 mojom::URLLoaderAssociatedPtr loader; 318 mojom::URLLoaderAssociatedPtr loader;
314 RejectingResourceDispatcherHostDelegate rdh_delegate; 319 RejectingResourceDispatcherHostDelegate rdh_delegate;
315 rdh_.SetDelegate(&rdh_delegate); 320 rdh_.SetDelegate(&rdh_delegate);
316 ResourceRequest request; 321 ResourceRequest request;
317 TestURLLoaderClient client; 322 TestURLLoaderClient client;
318 request.url = GURL("http://localhost/"); 323 request.url = GURL("http://localhost/");
319 request.method = "GET"; 324 request.method = "GET";
320 // |resource_type| can't be a frame type. It is because when PlzNavigate is 325 // |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 326 // enabled, the url scheme of frame type requests from the renderer process
322 // must be blob scheme. 327 // must be blob scheme.
323 request.resource_type = RESOURCE_TYPE_XHR; 328 request.resource_type = RESOURCE_TYPE_XHR;
324 // Need to set |request_initiator| for non main frame type request. 329 // Need to set |request_initiator| for non main frame type request.
325 request.request_initiator = url::Origin(); 330 request.request_initiator = url::Origin();
326 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), 2, 1, 331 factory_->CreateLoaderAndStart(
327 mojom::kURLLoadOptionNone, request, 332 mojo::MakeRequest(&loader), 2, 1, mojom::kURLLoadOptionNone, request,
328 client.CreateInterfacePtr()); 333 client.CreateInterfacePtr(),
334 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
329 335
330 client.RunUntilComplete(); 336 client.RunUntilComplete();
331 rdh_.SetDelegate(nullptr); 337 rdh_.SetDelegate(nullptr);
332 338
333 ASSERT_FALSE(client.has_received_response()); 339 ASSERT_FALSE(client.has_received_response());
334 ASSERT_FALSE(client.response_body().is_valid()); 340 ASSERT_FALSE(client.response_body().is_valid());
335 341
336 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); 342 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code);
337 } 343 }
338 344
339 TEST_P(URLLoaderFactoryImplTest, DownloadToFile) { 345 TEST_P(URLLoaderFactoryImplTest, DownloadToFile) {
340 constexpr int32_t kRoutingId = 1; 346 constexpr int32_t kRoutingId = 1;
341 constexpr int32_t kRequestId = 2; 347 constexpr int32_t kRequestId = 2;
342 348
343 mojom::URLLoaderAssociatedPtr loader; 349 mojom::URLLoaderAssociatedPtr loader;
344 base::FilePath root; 350 base::FilePath root;
345 PathService::Get(DIR_TEST_DATA, &root); 351 PathService::Get(DIR_TEST_DATA, &root);
346 net::URLRequestMockHTTPJob::AddUrlHandlers(root, 352 net::URLRequestMockHTTPJob::AddUrlHandlers(root,
347 BrowserThread::GetBlockingPool()); 353 BrowserThread::GetBlockingPool());
348 354
349 ResourceRequest request; 355 ResourceRequest request;
350 TestURLLoaderClient client; 356 TestURLLoaderClient client;
351 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); 357 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html");
352 request.method = "GET"; 358 request.method = "GET";
353 request.resource_type = RESOURCE_TYPE_XHR; 359 request.resource_type = RESOURCE_TYPE_XHR;
354 request.download_to_file = true; 360 request.download_to_file = true;
355 request.request_initiator = url::Origin(); 361 request.request_initiator = url::Origin();
356 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, 362 factory_->CreateLoaderAndStart(
357 kRequestId, 0, request, 363 mojo::MakeRequest(&loader), kRoutingId, kRequestId, 0, request,
358 client.CreateInterfacePtr()); 364 client.CreateInterfacePtr(),
365 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
359 ASSERT_FALSE(client.has_received_response()); 366 ASSERT_FALSE(client.has_received_response());
360 ASSERT_FALSE(client.has_data_downloaded()); 367 ASSERT_FALSE(client.has_data_downloaded());
361 ASSERT_FALSE(client.has_received_completion()); 368 ASSERT_FALSE(client.has_received_completion());
362 369
363 client.RunUntilResponseReceived(); 370 client.RunUntilResponseReceived();
364 371
365 net::URLRequest* url_request = 372 net::URLRequest* url_request =
366 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); 373 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId));
367 ASSERT_TRUE(url_request); 374 ASSERT_TRUE(url_request);
368 ResourceRequestInfoImpl* request_info = 375 ResourceRequestInfoImpl* request_info =
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 PathService::Get(DIR_TEST_DATA, &root); 420 PathService::Get(DIR_TEST_DATA, &root);
414 net::URLRequestSlowDownloadJob::AddUrlHandler(); 421 net::URLRequestSlowDownloadJob::AddUrlHandler();
415 422
416 ResourceRequest request; 423 ResourceRequest request;
417 TestURLLoaderClient client; 424 TestURLLoaderClient client;
418 request.url = GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl); 425 request.url = GURL(net::URLRequestSlowDownloadJob::kKnownSizeUrl);
419 request.method = "GET"; 426 request.method = "GET";
420 request.resource_type = RESOURCE_TYPE_XHR; 427 request.resource_type = RESOURCE_TYPE_XHR;
421 request.download_to_file = true; 428 request.download_to_file = true;
422 request.request_initiator = url::Origin(); 429 request.request_initiator = url::Origin();
423 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, 430 factory_->CreateLoaderAndStart(
424 kRequestId, 0, request, 431 mojo::MakeRequest(&loader), kRoutingId, kRequestId, 0, request,
425 client.CreateInterfacePtr()); 432 client.CreateInterfacePtr(),
433 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
426 ASSERT_FALSE(client.has_received_response()); 434 ASSERT_FALSE(client.has_received_response());
427 ASSERT_FALSE(client.has_data_downloaded()); 435 ASSERT_FALSE(client.has_data_downloaded());
428 ASSERT_FALSE(client.has_received_completion()); 436 ASSERT_FALSE(client.has_received_completion());
429 437
430 client.RunUntilResponseReceived(); 438 client.RunUntilResponseReceived();
431 439
432 net::URLRequest* url_request = 440 net::URLRequest* url_request =
433 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)); 441 rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId));
434 ASSERT_TRUE(url_request); 442 ASSERT_TRUE(url_request);
435 ResourceRequestInfoImpl* request_info = 443 ResourceRequestInfoImpl* request_info =
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // Assume the file contents is small enough to be stored in the data pipe. 484 // Assume the file contents is small enough to be stored in the data pipe.
477 request.url = net::URLRequestMockHTTPJob::GetMockUrl("gzip-content.svgz"); 485 request.url = net::URLRequestMockHTTPJob::GetMockUrl("gzip-content.svgz");
478 request.method = "GET"; 486 request.method = "GET";
479 // |resource_type| can't be a frame type. It is because when PlzNavigate is 487 // |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 488 // enabled, the url scheme of frame type requests from the renderer process
481 // must be blob scheme. 489 // must be blob scheme.
482 request.resource_type = RESOURCE_TYPE_XHR; 490 request.resource_type = RESOURCE_TYPE_XHR;
483 // Need to set |request_initiator| for non main frame type request. 491 // Need to set |request_initiator| for non main frame type request.
484 request.request_initiator = url::Origin(); 492 request.request_initiator = url::Origin();
485 request.report_raw_headers = true; 493 request.report_raw_headers = true;
486 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, 494 factory_->CreateLoaderAndStart(
487 kRequestId, mojom::kURLLoadOptionNone, request, 495 mojo::MakeRequest(&loader), kRoutingId, kRequestId,
488 client.CreateInterfacePtr()); 496 mojom::kURLLoadOptionNone, request, client.CreateInterfacePtr(),
497 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
489 498
490 client.RunUntilComplete(); 499 client.RunUntilComplete();
491 500
492 std::string contents; 501 std::string contents;
493 while (true) { 502 while (true) {
494 char buffer[16]; 503 char buffer[16];
495 uint32_t read_size = sizeof(buffer); 504 uint32_t read_size = sizeof(buffer);
496 MojoResult r = mojo::ReadDataRaw(client.response_body(), buffer, &read_size, 505 MojoResult r = mojo::ReadDataRaw(client.response_body(), buffer, &read_size,
497 MOJO_READ_DATA_FLAG_NONE); 506 MOJO_READ_DATA_FLAG_NONE);
498 if (r == MOJO_RESULT_FAILED_PRECONDITION) 507 if (r == MOJO_RESULT_FAILED_PRECONDITION)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
536 // Assume the file contents is small enough to be stored in the data pipe. 545 // Assume the file contents is small enough to be stored in the data pipe.
537 request.url = net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING); 546 request.url = net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING);
538 request.method = "GET"; 547 request.method = "GET";
539 request.is_main_frame = true; 548 request.is_main_frame = true;
540 // |resource_type| can't be a frame type. It is because when PlzNavigate is 549 // |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 550 // enabled, the url scheme of frame type requests from the renderer process
542 // must be blob scheme. 551 // must be blob scheme.
543 request.resource_type = RESOURCE_TYPE_XHR; 552 request.resource_type = RESOURCE_TYPE_XHR;
544 // Need to set |request_initiator| for non main frame type request. 553 // Need to set |request_initiator| for non main frame type request.
545 request.request_initiator = url::Origin(); 554 request.request_initiator = url::Origin();
546 factory_->CreateLoaderAndStart(mojo::MakeRequest(&loader), kRoutingId, 555 factory_->CreateLoaderAndStart(
547 kRequestId, mojom::kURLLoadOptionNone, request, 556 mojo::MakeRequest(&loader), kRoutingId, kRequestId,
548 client.CreateInterfacePtr()); 557 mojom::kURLLoadOptionNone, request, client.CreateInterfacePtr(),
558 net::MutableNetworkTrafficAnnotationTag(TRAFFIC_ANNOTATION_FOR_TESTS));
549 559
550 base::RunLoop().RunUntilIdle(); 560 base::RunLoop().RunUntilIdle();
551 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); 561 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)));
552 ASSERT_FALSE(client.has_received_response()); 562 ASSERT_FALSE(client.has_received_response());
553 ASSERT_FALSE(client.response_body().is_valid()); 563 ASSERT_FALSE(client.response_body().is_valid());
554 ASSERT_FALSE(client.has_received_completion()); 564 ASSERT_FALSE(client.has_received_completion());
555 565
556 loader = nullptr; 566 loader = nullptr;
557 base::RunLoop().RunUntilIdle(); 567 base::RunLoop().RunUntilIdle();
558 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); 568 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)));
559 } 569 }
560 570
561 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, 571 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest,
562 URLLoaderFactoryImplTest, 572 URLLoaderFactoryImplTest,
563 ::testing::Values(128, 32 * 1024)); 573 ::testing::Values(128, 32 * 1024));
564 574
565 } // namespace 575 } // namespace
566 576
567 } // namespace content 577 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/url_loader_factory_impl.cc ('k') | content/browser/service_worker/service_worker_fetch_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698