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

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

Issue 2466843002: Cancel the request when URLLoader is gone (Closed)
Patch Set: fix Created 4 years, 1 month 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 <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
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 // Cancel the request via URLLoader.
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 ASSERT_FALSE(client.has_received_response());
283 ASSERT_FALSE(client.response_body().is_valid());
284 ASSERT_FALSE(client.has_received_completion());
285
286 loader->Cancel();
287 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
288
289 EXPECT_EQ(net::ERR_ABORTED, client.completion_status().error_code);
290 }
291
262 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest, 292 INSTANTIATE_TEST_CASE_P(URLLoaderFactoryImplTest,
263 URLLoaderFactoryImplTest, 293 URLLoaderFactoryImplTest,
264 ::testing::Values(128, 32 * 1024)); 294 ::testing::Values(128, 32 * 1024));
265 295
266 } // namespace 296 } // namespace
267 297
268 } // namespace content 298 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698