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

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

Issue 2274953003: Add a WebURLLoaderImplTest for a redirect response with no security info (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 26 matching lines...) Expand all
37 #include "third_party/WebKit/public/platform/WebURLError.h" 37 #include "third_party/WebKit/public/platform/WebURLError.h"
38 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h" 38 #include "third_party/WebKit/public/platform/WebURLLoaderClient.h"
39 #include "third_party/WebKit/public/platform/WebURLRequest.h" 39 #include "third_party/WebKit/public/platform/WebURLRequest.h"
40 #include "third_party/WebKit/public/platform/WebURLResponse.h" 40 #include "third_party/WebKit/public/platform/WebURLResponse.h"
41 #include "url/gurl.h" 41 #include "url/gurl.h"
42 42
43 namespace content { 43 namespace content {
44 namespace { 44 namespace {
45 45
46 const char kTestURL[] = "http://foo"; 46 const char kTestURL[] = "http://foo";
47 const char kTestHTTPSURL[] = "https://foo";
47 const char kTestData[] = "blah!"; 48 const char kTestData[] = "blah!";
48 49
49 const char kFtpDirMimeType[] = "text/vnd.chromium.ftp-dir"; 50 const char kFtpDirMimeType[] = "text/vnd.chromium.ftp-dir";
50 // Simple FTP directory listing. Tests are not concerned with correct parsing, 51 // Simple FTP directory listing. Tests are not concerned with correct parsing,
51 // but rather correct cleanup when deleted while parsing. Important details of 52 // but rather correct cleanup when deleted while parsing. Important details of
52 // this list are that it contains more than one entry that are not "." or "..". 53 // this list are that it contains more than one entry that are not "." or "..".
53 const char kFtpDirListing[] = 54 const char kFtpDirListing[] =
54 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 goat\n" 55 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 goat\n"
55 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 hat"; 56 "drwxr-xr-x 3 ftp ftp 4096 May 15 18:11 hat";
56 57
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 net::RedirectInfo redirect_info; 303 net::RedirectInfo redirect_info;
303 redirect_info.status_code = 302; 304 redirect_info.status_code = 302;
304 redirect_info.new_method = "GET"; 305 redirect_info.new_method = "GET";
305 redirect_info.new_url = GURL(kTestURL); 306 redirect_info.new_url = GURL(kTestURL);
306 redirect_info.new_first_party_for_cookies = GURL(kTestURL); 307 redirect_info.new_first_party_for_cookies = GURL(kTestURL);
307 peer()->OnReceivedRedirect(redirect_info, 308 peer()->OnReceivedRedirect(redirect_info,
308 content::ResourceResponseInfo()); 309 content::ResourceResponseInfo());
309 EXPECT_TRUE(client()->did_receive_redirect()); 310 EXPECT_TRUE(client()->did_receive_redirect());
310 } 311 }
311 312
313 void DoReceiveHTTPSRedirect() {
314 EXPECT_FALSE(client()->did_receive_redirect());
315 net::RedirectInfo redirect_info;
316 redirect_info.status_code = 302;
317 redirect_info.new_method = "GET";
318 redirect_info.new_url = GURL(kTestHTTPSURL);
319 redirect_info.new_first_party_for_cookies = GURL(kTestHTTPSURL);
320 peer()->OnReceivedRedirect(redirect_info,
321 content::ResourceResponseInfo());
322 EXPECT_TRUE(client()->did_receive_redirect());
323 }
324
312 void DoReceiveResponse() { 325 void DoReceiveResponse() {
313 EXPECT_FALSE(client()->did_receive_response()); 326 EXPECT_FALSE(client()->did_receive_response());
314 peer()->OnReceivedResponse(content::ResourceResponseInfo()); 327 peer()->OnReceivedResponse(content::ResourceResponseInfo());
315 EXPECT_TRUE(client()->did_receive_response()); 328 EXPECT_TRUE(client()->did_receive_response());
316 } 329 }
317 330
318 // Assumes it is called only once for a request. 331 // Assumes it is called only once for a request.
319 void DoReceiveData() { 332 void DoReceiveData() {
320 EXPECT_EQ("", client()->received_data()); 333 EXPECT_EQ("", client()->received_data());
321 auto size = strlen(kTestData); 334 auto size = strlen(kTestData);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
382 TEST_F(WebURLLoaderImplTest, Redirect) { 395 TEST_F(WebURLLoaderImplTest, Redirect) {
383 DoStartAsyncRequest(); 396 DoStartAsyncRequest();
384 DoReceiveRedirect(); 397 DoReceiveRedirect();
385 DoReceiveResponse(); 398 DoReceiveResponse();
386 DoReceiveData(); 399 DoReceiveData();
387 DoCompleteRequest(); 400 DoCompleteRequest();
388 EXPECT_FALSE(dispatcher()->canceled()); 401 EXPECT_FALSE(dispatcher()->canceled());
389 EXPECT_EQ(kTestData, client()->received_data()); 402 EXPECT_EQ(kTestData, client()->received_data());
390 } 403 }
391 404
405 // Tests that a redirect to an HTTPS URL with no security info does not
406 // crash. Regression test for https://crbug.com/519120
407 TEST_F(WebURLLoaderImplTest, RedirectToHTTPSWithEmptySecurityInfo) {
408 DoStartAsyncRequest();
409 DoReceiveHTTPSRedirect();
410 DoReceiveResponse();
411 DoReceiveData();
412 DoCompleteRequest();
413 EXPECT_FALSE(dispatcher()->canceled());
414 EXPECT_EQ(kTestData, client()->received_data());
415 }
416
392 TEST_F(WebURLLoaderImplTest, RedirectCorrectPriority) { 417 TEST_F(WebURLLoaderImplTest, RedirectCorrectPriority) {
393 DoStartAsyncRequestWithPriority( 418 DoStartAsyncRequestWithPriority(
394 blink::WebURLRequest::Priority::PriorityVeryHigh); 419 blink::WebURLRequest::Priority::PriorityVeryHigh);
395 client()->set_redirect_request_priority( 420 client()->set_redirect_request_priority(
396 blink::WebURLRequest::Priority::PriorityVeryHigh); 421 blink::WebURLRequest::Priority::PriorityVeryHigh);
397 DoReceiveRedirect(); 422 DoReceiveRedirect();
398 DoReceiveResponse(); 423 DoReceiveResponse();
399 DoReceiveData(); 424 DoReceiveData();
400 DoCompleteRequest(); 425 DoCompleteRequest();
401 EXPECT_FALSE(dispatcher()->canceled()); 426 EXPECT_FALSE(dispatcher()->canceled());
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
698 encoded_data_length); 723 encoded_data_length);
699 724
700 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength()); 725 EXPECT_EQ(kEncodedBodyLength, response.encodedBodyLength());
701 EXPECT_EQ(kEncodedDataLength, encoded_data_length); 726 EXPECT_EQ(kEncodedDataLength, encoded_data_length);
702 int expected_decoded_body_length = strlen(kBodyData); 727 int expected_decoded_body_length = strlen(kBodyData);
703 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength()); 728 EXPECT_EQ(expected_decoded_body_length, response.decodedBodyLength());
704 } 729 }
705 730
706 } // namespace 731 } // namespace
707 } // namespace content 732 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698