| 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 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 | 381 |
| 382 url_request->Cancel(); | 382 url_request->Cancel(); |
| 383 client.RunUntilComplete(); | 383 client.RunUntilComplete(); |
| 384 | 384 |
| 385 ASSERT_TRUE(client.has_received_completion()); | 385 ASSERT_TRUE(client.has_received_completion()); |
| 386 | 386 |
| 387 EXPECT_EQ(200, client.response_head().headers->response_code()); | 387 EXPECT_EQ(200, client.response_head().headers->response_code()); |
| 388 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); | 388 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| 389 } | 389 } |
| 390 | 390 |
| 391 // Removing the loader in the remote side will cancel the request. |
| 392 TEST_P(URLLoaderFactoryImplTest, CancelFromRenderer) { |
| 393 constexpr int32_t kRoutingId = 81; |
| 394 constexpr int32_t kRequestId = 28; |
| 395 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); |
| 396 mojom::URLLoaderAssociatedPtr loader; |
| 397 base::FilePath root; |
| 398 PathService::Get(DIR_TEST_DATA, &root); |
| 399 net::URLRequestFailedJob::AddUrlHandler(); |
| 400 ResourceRequest request; |
| 401 TestURLLoaderClient client; |
| 402 // Assume the file contents is small enough to be stored in the data pipe. |
| 403 request.url = net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING); |
| 404 request.method = "GET"; |
| 405 request.is_main_frame = true; |
| 406 factory_->CreateLoaderAndStart( |
| 407 mojo::GetProxy(&loader, factory_.associated_group()), kRoutingId, |
| 408 kRequestId, request, |
| 409 client.CreateRemoteAssociatedPtrInfo(factory_.associated_group())); |
| 410 |
| 411 base::RunLoop().RunUntilIdle(); |
| 412 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| 413 ASSERT_FALSE(client.has_received_response()); |
| 414 ASSERT_FALSE(client.response_body().is_valid()); |
| 415 ASSERT_FALSE(client.has_received_completion()); |
| 416 |
| 417 loader = nullptr; |
| 418 base::RunLoop().RunUntilIdle(); |
| 419 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| 420 } |
| 421 |
| 391 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, | 422 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| 392 URLLoaderFactoryImplTest, | 423 URLLoaderFactoryImplTest, |
| 393 ::testing::Values(128, 32 * 1024)); | 424 ::testing::Values(128, 32 * 1024)); |
| 394 | 425 |
| 395 } // namespace | 426 } // namespace |
| 396 | 427 |
| 397 } // namespace content | 428 } // namespace content |
| OLD | NEW |