Chromium Code Reviews| 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 <memory> | 7 #include <memory> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 252 | 252 |
| 253 client.RunUntilComplete(); | 253 client.RunUntilComplete(); |
| 254 rdh_.SetDelegate(nullptr); | 254 rdh_.SetDelegate(nullptr); |
| 255 | 255 |
| 256 ASSERT_FALSE(client.has_received_response()); | 256 ASSERT_FALSE(client.has_received_response()); |
| 257 ASSERT_FALSE(client.response_body().is_valid()); | 257 ASSERT_FALSE(client.response_body().is_valid()); |
| 258 | 258 |
| 259 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); | 259 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code); |
| 260 } | 260 } |
| 261 | 261 |
| 262 // Removing the loader in the remote side will cancel the request. | |
| 263 TEST_P(URLLoaderFactoryImplTest, CancelFromRenderer) { | |
| 264 constexpr int32_t kRoutingId = 81; | |
| 265 constexpr int32_t kRequestId = 28; | |
| 266 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); | |
| 267 mojom::URLLoaderPtr loader; | |
| 268 base::FilePath root; | |
| 269 PathService::Get(DIR_TEST_DATA, &root); | |
| 270 net::URLRequestMockHTTPJob::AddUrlHandlers(root, | |
| 271 BrowserThread::GetBlockingPool()); | |
| 272 ResourceRequest request; | |
| 273 TestURLLoaderClient client; | |
| 274 // Assume the file contents is small enough to be stored in the data pipe. | |
| 275 request.url = net::URLRequestMockHTTPJob::GetMockUrl("hello.html"); | |
| 276 request.method = "GET"; | |
| 277 request.is_main_frame = true; | |
| 278 factory_->CreateLoaderAndStart(mojo::GetProxy(&loader), kRoutingId, | |
| 279 kRequestId, request, | |
| 280 client.CreateInterfacePtrAndBind()); | |
| 281 | |
| 282 base::RunLoop().RunUntilIdle(); | |
| 283 ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); | |
| 284 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.
| |
| 285 ASSERT_FALSE(client.response_body().is_valid()); | |
| 286 ASSERT_FALSE(client.has_received_completion()); | |
| 287 | |
| 288 loader = nullptr; | |
| 289 base::RunLoop().RunUntilIdle(); | |
| 290 ASSERT_FALSE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId))); | |
| 291 } | |
| 292 | |
| 262 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, | 293 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, |
| 263 URLLoaderFactoryImplTest, | 294 URLLoaderFactoryImplTest, |
| 264 ::testing::Values(128, 32 * 1024)); | 295 ::testing::Values(128, 32 * 1024)); |
| 265 | 296 |
| 266 } // namespace | 297 } // namespace |
| 267 | 298 |
| 268 } // namespace content | 299 } // namespace content |
| OLD | NEW |