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

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

Issue 2099243002: PlzNavigate: properly set the initiator of the navigation (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 1120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 // Creates and drives a main resource request until completion. Then asserts 1131 // Creates and drives a main resource request until completion. Then asserts
1132 // that the expected_error_code has been emitted for the request. 1132 // that the expected_error_code has been emitted for the request.
1133 void CompleteFailingMainResourceRequest(const GURL& url, 1133 void CompleteFailingMainResourceRequest(const GURL& url,
1134 int expected_error_code) { 1134 int expected_error_code) {
1135 if (IsBrowserSideNavigationEnabled()) { 1135 if (IsBrowserSideNavigationEnabled()) {
1136 auto_advance_ = true; 1136 auto_advance_ = true;
1137 1137
1138 // Make a navigation request. 1138 // Make a navigation request.
1139 TestNavigationURLLoaderDelegate delegate; 1139 TestNavigationURLLoaderDelegate delegate;
1140 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false, 1140 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
1141 false, REQUEST_CONTEXT_TYPE_LOCATION); 1141 false, REQUEST_CONTEXT_TYPE_LOCATION,
1142 url::Origin(url));
1142 CommonNavigationParams common_params; 1143 CommonNavigationParams common_params;
1143 common_params.url = url; 1144 common_params.url = url;
1144 std::unique_ptr<NavigationRequestInfo> request_info( 1145 std::unique_ptr<NavigationRequestInfo> request_info(
1145 new NavigationRequestInfo(common_params, begin_params, url, 1146 new NavigationRequestInfo(common_params, begin_params, url, true,
1146 url::Origin(url), true, false, -1)); 1147 false, -1));
1147 std::unique_ptr<NavigationURLLoader> test_loader = 1148 std::unique_ptr<NavigationURLLoader> test_loader =
1148 NavigationURLLoader::Create(browser_context_.get(), 1149 NavigationURLLoader::Create(browser_context_.get(),
1149 std::move(request_info), nullptr, 1150 std::move(request_info), nullptr,
1150 &delegate); 1151 &delegate);
1151 1152
1152 // The navigation should fail with the expected error code. 1153 // The navigation should fail with the expected error code.
1153 delegate.WaitForRequestFailed(); 1154 delegate.WaitForRequestFailed();
1154 ASSERT_EQ(expected_error_code, delegate.net_error()); 1155 ASSERT_EQ(expected_error_code, delegate.net_error());
1155 return; 1156 return;
1156 } 1157 }
(...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after
2597 SetResponse(raw_headers, response_data); 2598 SetResponse(raw_headers, response_data);
2598 job_factory_->SetDelayedCompleteJobGeneration(true); 2599 job_factory_->SetDelayedCompleteJobGeneration(true);
2599 HandleScheme("http"); 2600 HandleScheme("http");
2600 2601
2601 const GURL download_url = GURL("http://example.com/blah"); 2602 const GURL download_url = GURL("http://example.com/blah");
2602 2603
2603 if (IsBrowserSideNavigationEnabled()) { 2604 if (IsBrowserSideNavigationEnabled()) {
2604 // Create a NavigationRequest. 2605 // Create a NavigationRequest.
2605 TestNavigationURLLoaderDelegate delegate; 2606 TestNavigationURLLoaderDelegate delegate;
2606 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false, 2607 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
2607 false, REQUEST_CONTEXT_TYPE_LOCATION); 2608 false, REQUEST_CONTEXT_TYPE_LOCATION,
2609 url::Origin(download_url));
2608 CommonNavigationParams common_params; 2610 CommonNavigationParams common_params;
2609 common_params.url = download_url; 2611 common_params.url = download_url;
2610 std::unique_ptr<NavigationRequestInfo> request_info( 2612 std::unique_ptr<NavigationRequestInfo> request_info(
2611 new NavigationRequestInfo(common_params, begin_params, download_url, 2613 new NavigationRequestInfo(common_params, begin_params, download_url,
2612 url::Origin(download_url), true, false, -1)); 2614 true, false, -1));
2613 std::unique_ptr<NavigationURLLoader> loader = NavigationURLLoader::Create( 2615 std::unique_ptr<NavigationURLLoader> loader = NavigationURLLoader::Create(
2614 browser_context_.get(), std::move(request_info), nullptr, &delegate); 2616 browser_context_.get(), std::move(request_info), nullptr, &delegate);
2615 2617
2616 // Wait until a response has been received and proceed with the response. 2618 // Wait until a response has been received and proceed with the response.
2617 KickOffRequest(); 2619 KickOffRequest();
2618 2620
2619 // Return some data so that the request is identified as a download 2621 // Return some data so that the request is identified as a download
2620 // and the proper resource handlers are created. 2622 // and the proper resource handlers are created.
2621 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2623 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2622 base::RunLoop().RunUntilIdle(); 2624 base::RunLoop().RunUntilIdle();
(...skipping 1273 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 return nullptr; 3898 return nullptr;
3897 } 3899 }
3898 3900
3899 INSTANTIATE_TEST_CASE_P( 3901 INSTANTIATE_TEST_CASE_P(
3900 ResourceDispatcherHostTests, 3902 ResourceDispatcherHostTests,
3901 ResourceDispatcherHostTest, 3903 ResourceDispatcherHostTest,
3902 testing::Values(TestConfig::kDefault, 3904 testing::Values(TestConfig::kDefault,
3903 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3905 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3904 3906
3905 } // namespace content 3907 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698