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

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 3 years, 12 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 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 // Creates and drives a main resource request until completion. Then asserts 1076 // Creates and drives a main resource request until completion. Then asserts
1077 // that the expected_error_code has been emitted for the request. 1077 // that the expected_error_code has been emitted for the request.
1078 void CompleteFailingMainResourceRequest(const GURL& url, 1078 void CompleteFailingMainResourceRequest(const GURL& url,
1079 int expected_error_code) { 1079 int expected_error_code) {
1080 if (IsBrowserSideNavigationEnabled()) { 1080 if (IsBrowserSideNavigationEnabled()) {
1081 auto_advance_ = true; 1081 auto_advance_ = true;
1082 1082
1083 // Make a navigation request. 1083 // Make a navigation request.
1084 TestNavigationURLLoaderDelegate delegate; 1084 TestNavigationURLLoaderDelegate delegate;
1085 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false, 1085 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
1086 false, REQUEST_CONTEXT_TYPE_LOCATION); 1086 false, REQUEST_CONTEXT_TYPE_LOCATION,
1087 url::Origin(url));
1087 CommonNavigationParams common_params; 1088 CommonNavigationParams common_params;
1088 common_params.url = url; 1089 common_params.url = url;
1089 std::unique_ptr<NavigationRequestInfo> request_info( 1090 std::unique_ptr<NavigationRequestInfo> request_info(
1090 new NavigationRequestInfo( 1091 new NavigationRequestInfo(common_params, begin_params, url, true,
1091 common_params, begin_params, url, url::Origin(url), true, false, 1092 false, false, -1, false, false,
1092 false, -1, false, false, blink::WebPageVisibilityStateVisible)); 1093 blink::WebPageVisibilityStateVisible));
1093 std::unique_ptr<NavigationURLLoader> test_loader = 1094 std::unique_ptr<NavigationURLLoader> test_loader =
1094 NavigationURLLoader::Create(browser_context_.get(), 1095 NavigationURLLoader::Create(browser_context_.get(),
1095 std::move(request_info), nullptr, nullptr, 1096 std::move(request_info), nullptr, nullptr,
1096 nullptr, &delegate); 1097 nullptr, &delegate);
1097 1098
1098 // The navigation should fail with the expected error code. 1099 // The navigation should fail with the expected error code.
1099 delegate.WaitForRequestFailed(); 1100 delegate.WaitForRequestFailed();
1100 ASSERT_EQ(expected_error_code, delegate.net_error()); 1101 ASSERT_EQ(expected_error_code, delegate.net_error());
1101 return; 1102 return;
1102 } 1103 }
(...skipping 1530 matching lines...) Expand 10 before | Expand all | Expand 10 after
2633 SetResponse(raw_headers, response_data); 2634 SetResponse(raw_headers, response_data);
2634 job_factory_->SetDelayedCompleteJobGeneration(true); 2635 job_factory_->SetDelayedCompleteJobGeneration(true);
2635 HandleScheme("http"); 2636 HandleScheme("http");
2636 2637
2637 const GURL download_url = GURL("http://example.com/blah"); 2638 const GURL download_url = GURL("http://example.com/blah");
2638 2639
2639 if (IsBrowserSideNavigationEnabled()) { 2640 if (IsBrowserSideNavigationEnabled()) {
2640 // Create a NavigationRequest. 2641 // Create a NavigationRequest.
2641 TestNavigationURLLoaderDelegate delegate; 2642 TestNavigationURLLoaderDelegate delegate;
2642 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false, 2643 BeginNavigationParams begin_params(std::string(), net::LOAD_NORMAL, false,
2643 false, REQUEST_CONTEXT_TYPE_LOCATION); 2644 false, REQUEST_CONTEXT_TYPE_LOCATION,
2645 url::Origin(download_url));
2644 CommonNavigationParams common_params; 2646 CommonNavigationParams common_params;
2645 common_params.url = download_url; 2647 common_params.url = download_url;
2646 std::unique_ptr<NavigationRequestInfo> request_info( 2648 std::unique_ptr<NavigationRequestInfo> request_info(
2647 new NavigationRequestInfo(common_params, begin_params, download_url, 2649 new NavigationRequestInfo(common_params, begin_params, download_url,
2648 url::Origin(download_url), true, false, false, 2650 true, false, false, -1, false, false,
2649 -1, false, false,
2650 blink::WebPageVisibilityStateVisible)); 2651 blink::WebPageVisibilityStateVisible));
2651 std::unique_ptr<NavigationURLLoader> loader = NavigationURLLoader::Create( 2652 std::unique_ptr<NavigationURLLoader> loader = NavigationURLLoader::Create(
2652 browser_context_.get(), std::move(request_info), nullptr, nullptr, 2653 browser_context_.get(), std::move(request_info), nullptr, nullptr,
2653 nullptr, &delegate); 2654 nullptr, &delegate);
2654 2655
2655 // Wait until a response has been received and proceed with the response. 2656 // Wait until a response has been received and proceed with the response.
2656 KickOffRequest(); 2657 KickOffRequest();
2657 2658
2658 // Return some data so that the request is identified as a download 2659 // Return some data so that the request is identified as a download
2659 // and the proper resource handlers are created. 2660 // and the proper resource handlers are created.
(...skipping 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
3989 return nullptr; 3990 return nullptr;
3990 } 3991 }
3991 3992
3992 INSTANTIATE_TEST_CASE_P( 3993 INSTANTIATE_TEST_CASE_P(
3993 ResourceDispatcherHostTests, 3994 ResourceDispatcherHostTests,
3994 ResourceDispatcherHostTest, 3995 ResourceDispatcherHostTest,
3995 testing::Values(TestConfig::kDefault, 3996 testing::Values(TestConfig::kDefault,
3996 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3997 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3997 3998
3998 } // namespace content 3999 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698