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

Side by Side Diff: chrome/browser/referrer_policy_browsertest.cc

Issue 9372065: Update clients to use new TestServer constructor. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Remove files that were reviewed and committed separately. Created 8 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/string_number_conversions.h" 6 #include "base/string_number_conversions.h"
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "chrome/browser/ui/browser.h" 8 #include "chrome/browser/ui/browser.h"
9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 9 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
10 #include "chrome/test/base/in_process_browser_test.h" 10 #include "chrome/test/base/in_process_browser_test.h"
(...skipping 29 matching lines...) Expand all
40 ExpectedReferrerIsFull, 40 ExpectedReferrerIsFull,
41 ExpectedReferrerIsOrigin 41 ExpectedReferrerIsOrigin
42 }; 42 };
43 43
44 // Navigates from a page with a given |referrer_policy| (optionally on https) 44 // Navigates from a page with a given |referrer_policy| (optionally on https)
45 // to a page on http that reports the passed referrer and checks that it 45 // to a page on http that reports the passed referrer and checks that it
46 // matches the |expected_referrer|. 46 // matches the |expected_referrer|.
47 void RunReferrerTest(const std::string referrer_policy, 47 void RunReferrerTest(const std::string referrer_policy,
48 bool start_on_https, 48 bool start_on_https,
49 ExpectedReferrer expected_referrer) { 49 ExpectedReferrer expected_referrer) {
50 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); 50 net::TestServer test_server(net::TestServer::TYPE_HTTP,
51 net::TestServer::kLocalhost,
52 FilePath(kDocRoot));
51 ASSERT_TRUE(test_server.Start()); 53 ASSERT_TRUE(test_server.Start());
52 net::TestServer ssl_test_server(net::TestServer::TYPE_HTTPS, 54 net::TestServer ssl_test_server(net::TestServer::TYPE_HTTPS,
55 net::TestServer::kLocalhost,
53 FilePath(kDocRoot)); 56 FilePath(kDocRoot));
54 ASSERT_TRUE(ssl_test_server.Start()); 57 ASSERT_TRUE(ssl_test_server.Start());
55 58
56 GURL start_url = test_server.GetURL( 59 GURL start_url = test_server.GetURL(
57 std::string("files/referrer-policy-start.html?") + referrer_policy + 60 std::string("files/referrer-policy-start.html?") + referrer_policy +
58 "&port=" + base::IntToString(test_server.host_port_pair().port())); 61 "&port=" + base::IntToString(test_server.host_port_pair().port()));
59 if (start_on_https) { 62 if (start_on_https) {
60 start_url = ssl_test_server.GetURL( 63 start_url = ssl_test_server.GetURL(
61 std::string("files/referrer-policy-start.html?") + referrer_policy + 64 std::string("files/referrer-policy-start.html?") + referrer_policy +
62 "&port=" + base::IntToString(test_server.host_port_pair().port())); 65 "&port=" + base::IntToString(test_server.host_port_pair().port()));
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 108
106 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsOrigin) { 109 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsOrigin) {
107 RunReferrerTest("origin", true, ExpectedReferrerIsOrigin); 110 RunReferrerTest("origin", true, ExpectedReferrerIsOrigin);
108 } 111 }
109 112
110 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsNever) { 113 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, HttpsNever) {
111 RunReferrerTest("never", true, ExpectedReferrerIsEmpty); 114 RunReferrerTest("never", true, ExpectedReferrerIsEmpty);
112 } 115 }
113 116
114 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) { 117 IN_PROC_BROWSER_TEST_F(ReferrerPolicyTest, Redirect) {
115 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); 118 net::TestServer test_server(net::TestServer::TYPE_HTTP,
119 net::TestServer::kLocalhost,
120 FilePath(kDocRoot));
116 ASSERT_TRUE(test_server.Start()); 121 ASSERT_TRUE(test_server.Start());
117 net::TestServer ssl_test_server(net::TestServer::TYPE_HTTPS, 122 net::TestServer ssl_test_server(net::TestServer::TYPE_HTTPS,
123 net::TestServer::kLocalhost,
118 FilePath(kDocRoot)); 124 FilePath(kDocRoot));
119 ASSERT_TRUE(ssl_test_server.Start()); 125 ASSERT_TRUE(ssl_test_server.Start());
120 GURL start_url = test_server.GetURL( 126 GURL start_url = test_server.GetURL(
121 std::string("files/referrer-policy-redirect.html?") + 127 std::string("files/referrer-policy-redirect.html?") +
122 "ssl_port=" + base::IntToString(ssl_test_server.host_port_pair().port()) + 128 "ssl_port=" + base::IntToString(ssl_test_server.host_port_pair().port()) +
123 "&port=" + base::IntToString(test_server.host_port_pair().port())); 129 "&port=" + base::IntToString(test_server.host_port_pair().port()));
124 std::string referrer = "Referrer is " + start_url.GetWithEmptyPath().spec(); 130 std::string referrer = "Referrer is " + start_url.GetWithEmptyPath().spec();
125 NavigateToURLAndWaitForTitle(start_url, referrer, 2); 131 NavigateToURLAndWaitForTitle(start_url, referrer, 2);
126 } 132 }
OLDNEW
« no previous file with comments | « chrome/browser/prerender/prerender_browsertest.cc ('k') | chrome/browser/repost_form_warning_uitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698