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 5a5be02809c71afe315a4470df4155cede8cc127..e8e2231ef46727ca5505e4c532f980d1b72f4152 100644 |
| --- a/content/browser/loader/url_loader_factory_impl_unittest.cc |
| +++ b/content/browser/loader/url_loader_factory_impl_unittest.cc |
| @@ -259,6 +259,37 @@ TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { |
| EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| } |
| +// Removing the loader in the remote side will cancel the request. |
| +TEST_P(URLLoaderFactoryImplTest, CancelFromRenderer) { |
| + constexpr int32_t kRoutingId = 81; |
| + constexpr int32_t kRequestId = 28; |
| + NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); |
| + mojom::URLLoaderPtr loader; |
| + base::FilePath root; |
| + PathService::Get(DIR_TEST_DATA, &root); |
| + net::URLRequestMockHTTPJob::AddUrlHandlers(root, |
| + BrowserThread::GetBlockingPool()); |
| + ResourceRequest request; |
| + TestURLLoaderClient client; |
| + // 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; |
| + factory_->CreateLoaderAndStart(mojo::GetProxy(&loader), kRoutingId, |
| + kRequestId, request, |
| + client.CreateInterfacePtrAndBind()); |
| + |
| + base::RunLoop().RunUntilIdle(); |
| + ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| + ASSERT_FALSE(client.has_received_response()); |
|
mmenke
2016/11/03 18:17:41
What guarantee is there that we don't receive the
yhirano
2016/11/08 11:52:23
Done.
|
| + ASSERT_FALSE(client.response_body().is_valid()); |
| + ASSERT_FALSE(client.has_received_completion()); |
| + |
| + loader = nullptr; |
| + base::RunLoop().RunUntilIdle(); |
| + ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); |
| +} |
| + |
| INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| URLLoaderFactoryImplTest, |
| ::testing::Values(128, 32 * 1024)); |