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

Unified 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 side-by-side diff with in-line comments
Download patch
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 86191fabca5c29379c78c792b167230b2664484f..39eb1dce99a5ef6fd38c5f3cc1ce66590d4e300d 100644
--- a/content/browser/loader/url_loader_factory_impl_unittest.cc
+++ b/content/browser/loader/url_loader_factory_impl_unittest.cc
@@ -388,6 +388,37 @@ TEST_P(URLLoaderFactoryImplTest, DownloadToFileFailure) {
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::URLLoaderAssociatedPtr loader;
+ base::FilePath root;
+ PathService::Get(DIR_TEST_DATA, &root);
+ net::URLRequestFailedJob::AddUrlHandler();
+ ResourceRequest request;
+ TestURLLoaderClient client;
+ // Assume the file contents is small enough to be stored in the data pipe.
+ request.url = net::URLRequestFailedJob::GetMockHttpUrl(net::ERR_IO_PENDING);
+ request.method = "GET";
+ request.is_main_frame = true;
+ factory_->CreateLoaderAndStart(
+ mojo::GetProxy(&loader, factory_.associated_group()), kRoutingId,
+ kRequestId, request,
+ client.CreateRemoteAssociatedPtrInfo(factory_.associated_group()));
+
+ base::RunLoop().RunUntilIdle();
+ ASSERT_TRUE(rdh_.GetURLRequest(GlobalRequestID(kChildId, kRequestId)));
+ ASSERT_FALSE(client.has_received_response());
+ 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));

Powered by Google App Engine
This is Rietveld 408576698