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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 1043403003: Revert of Enable 'First-Party-Only' cookies by default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/url_request/url_request_unittest.cc
diff --git a/net/url_request/url_request_unittest.cc b/net/url_request/url_request_unittest.cc
index f19cc01f18fa742b3670cf8fca68ebc702a12c12..37a5cb529d1c466d2097200a9706a585224c775d 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2551,6 +2551,7 @@
// LocalHttpTestServer points).
{
TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(true);
default_context_.set_network_delegate(&network_delegate);
TestDelegate d;
@@ -2568,6 +2569,7 @@
// Verify that the cookie is sent for first-party requests.
{
TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(true);
default_context_.set_network_delegate(&network_delegate);
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
@@ -2585,6 +2587,7 @@
// Verify that the cookie is not-sent for non-first-party requests.
{
TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(true);
default_context_.set_network_delegate(&network_delegate);
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
@@ -2594,6 +2597,66 @@
base::RunLoop().Run();
EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") ==
+ std::string::npos);
+ EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
+ EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
+ }
+}
+
+TEST_F(URLRequestTest, FirstPartyOnlyCookiesDisabled) {
+ LocalHttpTestServer test_server;
+ ASSERT_TRUE(test_server.Start());
+
+ // Set up a 'First-Party-Only' cookie (on '127.0.0.1', as that's where
+ // LocalHttpTestServer points).
+ {
+ TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(false);
+ default_context_.set_network_delegate(&network_delegate);
+
+ TestDelegate d;
+ scoped_ptr<URLRequest> req(default_context_.CreateRequest(
+ test_server.GetURL(
+ "set-cookie?FirstPartyCookieToSet=1;First-Party-Only"),
+ DEFAULT_PRIORITY, &d));
+ req->Start();
+ base::RunLoop().Run();
+ EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
+ EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
+ EXPECT_EQ(1, network_delegate.set_cookie_count());
+ }
+
+ // Verify that the cookie is sent for first-party requests.
+ {
+ TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(false);
+ default_context_.set_network_delegate(&network_delegate);
+ TestDelegate d;
+ scoped_ptr<URLRequest> req(default_context_.CreateRequest(
+ test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
+ req->set_first_party_for_cookies(test_server.GetURL(""));
+ req->Start();
+ base::RunLoop().Run();
+
+ EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") !=
+ std::string::npos);
+ EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
+ EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
+ }
+
+ // Verify that the cookie is also sent for non-first-party requests.
+ {
+ TestNetworkDelegate network_delegate;
+ network_delegate.set_first_party_only_cookies_enabled(false);
+ default_context_.set_network_delegate(&network_delegate);
+ TestDelegate d;
+ scoped_ptr<URLRequest> req(default_context_.CreateRequest(
+ test_server.GetURL("echoheader?Cookie"), DEFAULT_PRIORITY, &d));
+ req->set_first_party_for_cookies(GURL("http://third-party.test/"));
+ req->Start();
+ base::RunLoop().Run();
+
+ EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") !=
std::string::npos);
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
« no previous file with comments | « net/url_request/url_request_test_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698