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..863752fb25024a20b51ff6b16c114e0b8d8d3690 100644 |
| --- a/content/browser/loader/url_loader_factory_impl_unittest.cc |
| +++ b/content/browser/loader/url_loader_factory_impl_unittest.cc |
| @@ -259,6 +259,36 @@ TEST_P(URLLoaderFactoryImplTest, ShouldNotRequestURL) { |
| EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| } |
| +// Cancel the request via URLLoader. |
| +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()); |
| + |
| + ASSERT_FALSE(client.has_received_response()); |
| + ASSERT_FALSE(client.response_body().is_valid()); |
| + ASSERT_FALSE(client.has_received_completion()); |
| + |
| + loader->Cancel(); |
| + client.RunUntilComplete(); |
|
mmenke
2016/11/01 13:52:32
Hrm...I wonder...Do we want to promise an OnComple
yhirano
2016/11/01 14:24:25
Yeah, I'm not particularly interested in receiving
mmenke
2016/11/01 14:27:54
I'm thinking it may be simplest to tear down the l
mmenke
2016/11/01 14:30:05
Also, if we're not going to promise an OnComplete
yhirano
2016/11/02 06:02:56
Done.
yhirano
2016/11/02 06:02:56
Hm, I didn't think about that. PS4 removes Cancel
|
| + |
| + EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| +} |
| + |
| INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| URLLoaderFactoryImplTest, |
| ::testing::Values(128, 32 * 1024)); |