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

Side by Side Diff: content/child/web_url_loader_impl_unittest.cc

Issue 1905033002: PlzNavigate: Move navigation-level mixed content checks to the browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@console-security-message
Patch Set: Addressed all jam@ latest comments. Created 3 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/child/web_url_loader_impl.h" 5 #include "content/child/web_url_loader_impl.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 #include <string.h> 8 #include <string.h>
9 9
10 #include <utility> 10 #include <utility>
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 class WebURLLoaderImplTest : public testing::Test { 262 class WebURLLoaderImplTest : public testing::Test {
263 public: 263 public:
264 WebURLLoaderImplTest() { 264 WebURLLoaderImplTest() {
265 client_.reset(new TestWebURLLoaderClient(&dispatcher_)); 265 client_.reset(new TestWebURLLoaderClient(&dispatcher_));
266 } 266 }
267 267
268 ~WebURLLoaderImplTest() override {} 268 ~WebURLLoaderImplTest() override {}
269 269
270 void DoStartAsyncRequest() { 270 void DoStartAsyncRequest() {
271 blink::WebURLRequest request{GURL(kTestURL)}; 271 blink::WebURLRequest request{GURL(kTestURL)};
272 request.setRequestContext(blink::WebURLRequest::RequestContextInternal);
272 client()->loader()->loadAsynchronously(request, client()); 273 client()->loader()->loadAsynchronously(request, client());
273 ASSERT_TRUE(peer()); 274 ASSERT_TRUE(peer());
274 } 275 }
275 276
276 void DoStartAsyncRequestWithPriority( 277 void DoStartAsyncRequestWithPriority(
277 blink::WebURLRequest::Priority priority) { 278 blink::WebURLRequest::Priority priority) {
278 blink::WebURLRequest request{GURL(kTestURL)}; 279 blink::WebURLRequest request{GURL(kTestURL)};
280 request.setRequestContext(blink::WebURLRequest::RequestContextInternal);
279 request.setPriority(priority); 281 request.setPriority(priority);
280 client()->loader()->loadAsynchronously(request, client()); 282 client()->loader()->loadAsynchronously(request, client());
281 ASSERT_TRUE(peer()); 283 ASSERT_TRUE(peer());
282 } 284 }
283 285
284 void DoReceiveRedirect() { 286 void DoReceiveRedirect() {
285 EXPECT_FALSE(client()->did_receive_redirect()); 287 EXPECT_FALSE(client()->did_receive_redirect());
286 net::RedirectInfo redirect_info; 288 net::RedirectInfo redirect_info;
287 redirect_info.status_code = 302; 289 redirect_info.status_code = 302;
288 redirect_info.new_method = "GET"; 290 redirect_info.new_method = "GET";
(...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 } 663 }
662 664
663 // Verifies that the lengths used by the PerformanceResourceTiming API are 665 // Verifies that the lengths used by the PerformanceResourceTiming API are
664 // correctly assigned for sync XHR. 666 // correctly assigned for sync XHR.
665 TEST_F(WebURLLoaderImplTest, SyncLengths) { 667 TEST_F(WebURLLoaderImplTest, SyncLengths) {
666 static const char kBodyData[] = "Today is Thursday"; 668 static const char kBodyData[] = "Today is Thursday";
667 const int kEncodedBodyLength = 30; 669 const int kEncodedBodyLength = 30;
668 const int kEncodedDataLength = 130; 670 const int kEncodedDataLength = 130;
669 const GURL url(kTestURL); 671 const GURL url(kTestURL);
670 blink::WebURLRequest request(url); 672 blink::WebURLRequest request(url);
673 request.setRequestContext(blink::WebURLRequest::RequestContextInternal);
671 674
672 // Prepare a mock response 675 // Prepare a mock response
673 SyncLoadResponse sync_load_response; 676 SyncLoadResponse sync_load_response;
674 sync_load_response.error_code = net::OK; 677 sync_load_response.error_code = net::OK;
675 sync_load_response.url = url; 678 sync_load_response.url = url;
676 sync_load_response.data = kBodyData; 679 sync_load_response.data = kBodyData;
677 ASSERT_EQ(17u, sync_load_response.data.size()); 680 ASSERT_EQ(17u, sync_load_response.data.size());
678 sync_load_response.encoded_body_length = kEncodedBodyLength; 681 sync_load_response.encoded_body_length = kEncodedBodyLength;
679 sync_load_response.encoded_data_length = kEncodedDataLength; 682 sync_load_response.encoded_data_length = kEncodedDataLength;
680 dispatcher()->set_sync_load_response(sync_load_response); 683 dispatcher()->set_sync_load_response(sync_load_response);
681 684
682 blink::WebURLResponse response; 685 blink::WebURLResponse response;
683 blink::WebURLError error; 686 blink::WebURLError error;
684 blink::WebData data; 687 blink::WebData data;
685 int64_t encoded_data_length = 0; 688 int64_t encoded_data_length = 0;
686 int64_t encoded_body_length = 0; 689 int64_t encoded_body_length = 0;
687 client()->loader()->loadSynchronously( 690 client()->loader()->loadSynchronously(
688 request, response, error, data, encoded_data_length, encoded_body_length); 691 request, response, error, data, encoded_data_length, encoded_body_length);
689 692
690 EXPECT_EQ(kEncodedBodyLength, encoded_body_length); 693 EXPECT_EQ(kEncodedBodyLength, encoded_body_length);
691 EXPECT_EQ(kEncodedDataLength, encoded_data_length); 694 EXPECT_EQ(kEncodedDataLength, encoded_data_length);
692 } 695 }
693 696
694 } // namespace 697 } // namespace
695 } // namespace content 698 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698