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

Side by Side Diff: net/url_request/url_request_unittest.cc

Issue 12569007: Remove URL fragment from referrer HTTP header when opening link using "Open Link in New Tab" option. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address pauljensen's review comments Created 7 years, 9 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 | Annotate | Revision Log
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 "build/build_config.h" 5 #include "build/build_config.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windows.h> 8 #include <windows.h>
9 #include <shlobj.h> 9 #include <shlobj.h>
10 #endif 10 #endif
(...skipping 1911 matching lines...) Expand 10 before | Expand all | Expand 10 after
1922 TEST_F(URLRequestTest, DoNotOverrideReferrer) { 1922 TEST_F(URLRequestTest, DoNotOverrideReferrer) {
1923 LocalHttpTestServer test_server; 1923 LocalHttpTestServer test_server;
1924 ASSERT_TRUE(test_server.Start()); 1924 ASSERT_TRUE(test_server.Start());
1925 1925
1926 // If extra headers contain referer and the request contains a referer, 1926 // If extra headers contain referer and the request contains a referer,
1927 // only the latter shall be respected. 1927 // only the latter shall be respected.
1928 { 1928 {
1929 TestDelegate d; 1929 TestDelegate d;
1930 URLRequest req( 1930 URLRequest req(
1931 test_server.GetURL("echoheader?Referer"), &d, &default_context_); 1931 test_server.GetURL("echoheader?Referer"), &d, &default_context_);
1932 req.set_referrer("http://foo.com/"); 1932 req.SetReferrer("http://foo.com/");
1933 1933
1934 HttpRequestHeaders headers; 1934 HttpRequestHeaders headers;
1935 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/"); 1935 headers.SetHeader(HttpRequestHeaders::kReferer, "http://bar.com/");
1936 req.SetExtraRequestHeaders(headers); 1936 req.SetExtraRequestHeaders(headers);
1937 1937
1938 req.Start(); 1938 req.Start();
1939 MessageLoop::current()->Run(); 1939 MessageLoop::current()->Run();
1940 1940
1941 EXPECT_EQ("http://foo.com/", d.data_received()); 1941 EXPECT_EQ("http://foo.com/", d.data_received());
1942 } 1942 }
(...skipping 1011 matching lines...) Expand 10 before | Expand all | Expand 10 after
2954 base::FilePath(FILE_PATH_LITERAL("net/data/ssl"))); 2954 base::FilePath(FILE_PATH_LITERAL("net/data/ssl")));
2955 ASSERT_TRUE(https_test_server.Start()); 2955 ASSERT_TRUE(https_test_server.Start());
2956 2956
2957 // An https server is sent a request with an https referer, 2957 // An https server is sent a request with an https referer,
2958 // and responds with a redirect to an http url. The http 2958 // and responds with a redirect to an http url. The http
2959 // server should not be sent the referer. 2959 // server should not be sent the referer.
2960 GURL http_destination = test_server_.GetURL(""); 2960 GURL http_destination = test_server_.GetURL("");
2961 TestDelegate d; 2961 TestDelegate d;
2962 URLRequest req(https_test_server.GetURL( 2962 URLRequest req(https_test_server.GetURL(
2963 "server-redirect?" + http_destination.spec()), &d, &default_context_); 2963 "server-redirect?" + http_destination.spec()), &d, &default_context_);
2964 req.set_referrer("https://www.referrer.com/"); 2964 req.SetReferrer("https://www.referrer.com/");
2965 req.Start(); 2965 req.Start();
2966 MessageLoop::current()->Run(); 2966 MessageLoop::current()->Run();
2967 2967
2968 EXPECT_EQ(1, d.response_started_count()); 2968 EXPECT_EQ(1, d.response_started_count());
2969 EXPECT_EQ(1, d.received_redirect_count()); 2969 EXPECT_EQ(1, d.received_redirect_count());
2970 EXPECT_EQ(http_destination, req.url()); 2970 EXPECT_EQ(http_destination, req.url());
2971 EXPECT_EQ(std::string(), req.referrer()); 2971 EXPECT_EQ(std::string(), req.referrer());
2972 } 2972 }
2973 2973
2974 TEST_F(URLRequestTestHTTP, RedirectLoadTiming) { 2974 TEST_F(URLRequestTestHTTP, RedirectLoadTiming) {
(...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after
3489 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status()); 3489 EXPECT_EQ(URLRequestStatus::FAILED, req.status().status());
3490 EXPECT_EQ(ERR_INVALID_URL, req.status().error()); 3490 EXPECT_EQ(ERR_INVALID_URL, req.status().error());
3491 } 3491 }
3492 3492
3493 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) { 3493 TEST_F(URLRequestTestHTTP, NoUserPassInReferrer) {
3494 ASSERT_TRUE(test_server_.Start()); 3494 ASSERT_TRUE(test_server_.Start());
3495 3495
3496 TestDelegate d; 3496 TestDelegate d;
3497 URLRequest req( 3497 URLRequest req(
3498 test_server_.GetURL("echoheader?Referer"), &d, &default_context_); 3498 test_server_.GetURL("echoheader?Referer"), &d, &default_context_);
3499 req.set_referrer("http://user:pass@foo.com/"); 3499 req.SetReferrer("http://user:pass@foo.com/");
3500 req.Start(); 3500 req.Start();
3501 MessageLoop::current()->Run(); 3501 MessageLoop::current()->Run();
3502 3502
3503 EXPECT_EQ(std::string("http://foo.com/"), d.data_received()); 3503 EXPECT_EQ(std::string("http://foo.com/"), d.data_received());
3504 } 3504 }
3505 3505
3506 TEST_F(URLRequestTestHTTP, NoFragmentInReferrer) {
3507 ASSERT_TRUE(test_server_.Start());
3508
3509 TestDelegate d;
3510 URLRequest req(
3511 test_server_.GetURL("echoheader?Referer"), &d, &default_context_);
3512 req.SetReferrer("http://foo.com/test#fragment");
3513 req.Start();
3514 MessageLoop::current()->Run();
3515
3516 EXPECT_EQ(std::string("http://foo.com/test"), d.data_received());
3517 }
mmenke 2013/03/19 19:01:09 Suggest one more test: SetReferrer with "" after
mef 2013/03/19 21:40:29 Done.
3518
3506 TEST_F(URLRequestTestHTTP, CancelRedirect) { 3519 TEST_F(URLRequestTestHTTP, CancelRedirect) {
3507 ASSERT_TRUE(test_server_.Start()); 3520 ASSERT_TRUE(test_server_.Start());
3508 3521
3509 TestDelegate d; 3522 TestDelegate d;
3510 { 3523 {
3511 d.set_cancel_in_received_redirect(true); 3524 d.set_cancel_in_received_redirect(true);
3512 URLRequest req( 3525 URLRequest req(
3513 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_); 3526 test_server_.GetURL("files/redirect-test.html"), &d, &default_context_);
3514 req.Start(); 3527 req.Start();
3515 MessageLoop::current()->Run(); 3528 MessageLoop::current()->Run();
(...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
5367 5380
5368 EXPECT_FALSE(r.is_pending()); 5381 EXPECT_FALSE(r.is_pending());
5369 EXPECT_EQ(1, d->response_started_count()); 5382 EXPECT_EQ(1, d->response_started_count());
5370 EXPECT_FALSE(d->received_data_before_response()); 5383 EXPECT_FALSE(d->received_data_before_response());
5371 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size)); 5384 EXPECT_EQ(d->bytes_received(), static_cast<int>(file_size));
5372 } 5385 }
5373 } 5386 }
5374 #endif // !defined(DISABLE_FTP_SUPPORT) 5387 #endif // !defined(DISABLE_FTP_SUPPORT)
5375 5388
5376 } // namespace net 5389 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698