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

Unified Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2847443002: PlzNavigate: make NavigationResourceHandler a LayeredResourceHandler (Closed)
Patch Set: Addressed comments Created 3 years, 8 months 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/resource_dispatcher_host_unittest.cc
diff --git a/content/browser/loader/resource_dispatcher_host_unittest.cc b/content/browser/loader/resource_dispatcher_host_unittest.cc
index a41dfff2e95006f8f4f22b965794302f726692a0..06f8841b02187eb1a099bd2c0fc9feee42014c00 100644
--- a/content/browser/loader/resource_dispatcher_host_unittest.cc
+++ b/content/browser/loader/resource_dispatcher_host_unittest.cc
@@ -2559,6 +2559,9 @@ TEST_F(ResourceDispatcherHostTest, IgnoreCancelForDownloads) {
}
TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
+ if (IsBrowserSideNavigationEnabled())
+ return;
+
EXPECT_EQ(0, host_.pending_requests());
NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
@@ -2577,76 +2580,34 @@ TEST_F(ResourceDispatcherHostTest, CancelRequestsForContext) {
const GURL download_url = GURL("http://example.com/blah");
- if (IsBrowserSideNavigationEnabled()) {
- // Create a NavigationRequest.
- TestNavigationURLLoaderDelegate delegate;
- BeginNavigationParams begin_params(
- std::string(), net::LOAD_NORMAL, false, false,
- REQUEST_CONTEXT_TYPE_LOCATION,
- blink::WebMixedContentContextType::kBlockable,
- false, // is_form_submission
- url::Origin(download_url));
- CommonNavigationParams common_params;
- common_params.url = download_url;
- std::unique_ptr<NavigationRequestInfo> request_info(
- new NavigationRequestInfo(common_params, begin_params, download_url,
- true, false, false, -1, false, false,
- blink::kWebPageVisibilityStateVisible));
- std::unique_ptr<NavigationURLLoader> loader = NavigationURLLoader::Create(
- browser_context_->GetResourceContext(),
- BrowserContext::GetDefaultStoragePartition(browser_context_.get()),
- std::move(request_info), nullptr, nullptr, nullptr, &delegate);
-
- // Wait until a response has been received and proceed with the response.
- KickOffRequest();
-
- // Return some data so that the request is identified as a download
- // and the proper resource handlers are created.
- EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
- content::RunAllBlockingPoolTasksUntilIdle();
-
- // The UI thread will be informed that the navigation failed with an error
- // code of ERR_ABORTED because the navigation turns out to be a download.
- // The navigation is aborted, but the request goes on as a download.
- EXPECT_EQ(delegate.net_error(), net::ERR_ABORTED);
- EXPECT_EQ(1, host_.pending_requests());
-
- // In PlzNavigate, the renderer cannot cancel the request directly.
- // However, cancelling by context should work.
- host_.CancelRequestsForContext(browser_context_->GetResourceContext());
- EXPECT_EQ(0, host_.pending_requests());
-
- content::RunAllBlockingPoolTasksUntilIdle();
- } else {
- MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
- download_url, RESOURCE_TYPE_MAIN_FRAME);
+ MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
+ download_url, RESOURCE_TYPE_MAIN_FRAME);
- // Return some data so that the request is identified as a download
- // and the proper resource handlers are created.
- EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
- content::RunAllBlockingPoolTasksUntilIdle();
+ // Return some data so that the request is identified as a download
+ // and the proper resource handlers are created.
+ EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
+ content::RunAllBlockingPoolTasksUntilIdle();
- // And now simulate a cancellation coming from the renderer.
- ResourceHostMsg_CancelRequest msg(request_id);
- OnMessageReceived(msg, filter_.get());
+ // And now simulate a cancellation coming from the renderer.
+ ResourceHostMsg_CancelRequest msg(request_id);
+ OnMessageReceived(msg, filter_.get());
- // Since the request had already started processing as a download,
- // the cancellation above should have been ignored and the request
- // should still be alive.
- EXPECT_EQ(1, host_.pending_requests());
+ // Since the request had already started processing as a download,
+ // the cancellation above should have been ignored and the request
+ // should still be alive.
+ EXPECT_EQ(1, host_.pending_requests());
- // Cancelling by other methods shouldn't work either.
- host_.CancelRequestsForProcess(render_view_id);
- EXPECT_EQ(1, host_.pending_requests());
+ // Cancelling by other methods shouldn't work either.
+ host_.CancelRequestsForProcess(render_view_id);
+ EXPECT_EQ(1, host_.pending_requests());
- // Cancelling by context should work.
- host_.CancelRequestsForContext(filter_->resource_context());
- EXPECT_EQ(0, host_.pending_requests());
+ // Cancelling by context should work.
+ host_.CancelRequestsForContext(filter_->resource_context());
+ EXPECT_EQ(0, host_.pending_requests());
- while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
- }
- content::RunAllBlockingPoolTasksUntilIdle();
+ while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
}
+ content::RunAllBlockingPoolTasksUntilIdle();
}
TEST_F(ResourceDispatcherHostTest, CancelRequestsForContextDetached) {
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/browser/loader/stream_resource_handler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698