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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 1615773005: Rename first-party-only cookies to same-site cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tests. Created 4 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 side-by-side diff with in-line comments
Download patch
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 78e4eb30f79a551bd290dece245ee35ce7afeafb..7c08b7f8988a3ec8662ba14d03048eacb09143a7 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2650,7 +2650,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
}
}
-TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
+TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
LocalHttpTestServer test_server;
ASSERT_TRUE(test_server.Start());
@@ -2658,13 +2658,12 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
network_delegate.set_experimental_cookie_features_enabled(true);
default_context_.set_network_delegate(&network_delegate);
- // Set up a 'First-Party-Only' cookie (on '127.0.0.1', as that's where
+ // Set up a 'SameSite' cookie (on '127.0.0.1', as that's where
// LocalHttpTestServer points).
{
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
- test_server.GetURL(
- "/set-cookie?FirstPartyCookieToSet=1;First-Party-Only"),
+ test_server.GetURL("/set-cookie?SameSiteCookieToSet=1;SameSite"),
DEFAULT_PRIORITY, &d));
req->Start();
base::RunLoop().Run();
@@ -2673,7 +2672,7 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
EXPECT_EQ(1, network_delegate.set_cookie_count());
}
- // Verify that the cookie is sent for first-party requests.
+ // Verify that the cookie is sent for same-site requests.
{
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
@@ -2683,69 +2682,69 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") !=
+ EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=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 not sent for non-first-party requests.
+ // Verify that the cookie is not sent for cross-site requests.
{
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->set_initiator(url::Origin(GURL("http://third-party.test/")));
+ req->set_first_party_for_cookies(GURL("http://cross-site.test/"));
+ req->set_initiator(url::Origin(GURL("http://cross-site.test/")));
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") ==
+ EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=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 sent for non-first-party initiators when the
+ // Verify that the cookie is sent for cross-site initiators when the
// method is "safe".
{
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->set_initiator(url::Origin(GURL("http://third-party.test/")));
+ req->set_initiator(url::Origin(GURL("http://cross-site.test/")));
req->Start();
base::RunLoop().Run();
- EXPECT_FALSE(d.data_received().find("FirstPartyCookieToSet=1") ==
+ EXPECT_FALSE(d.data_received().find("SameSiteCookieToSet=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 not sent for non-first-party initiators when the
+ // Verify that the cookie is not sent for cross-site initiators when the
// method is unsafe (e.g. POST).
{
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->set_initiator(url::Origin(GURL("http://third-party.test/")));
+ req->set_initiator(url::Origin(GURL("http://cross-site.test/")));
req->set_method("POST");
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") ==
+ EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=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) {
+TEST_F(URLRequestTest, SameSiteCookiesDisabled) {
LocalHttpTestServer test_server;
ASSERT_TRUE(test_server.Start());
- // Set up a 'First-Party-Only' cookie (on '127.0.0.1', as that's where
+ // Set up a 'SameSite' cookie (on '127.0.0.1', as that's where
// LocalHttpTestServer points).
{
TestNetworkDelegate network_delegate;
@@ -2754,8 +2753,7 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesDisabled) {
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
- test_server.GetURL(
- "/set-cookie?FirstPartyCookieToSet=1;First-Party-Only"),
+ test_server.GetURL("/set-cookie?SameSiteCookieToSet=1;SameSite"),
DEFAULT_PRIORITY, &d));
req->Start();
base::RunLoop().Run();
@@ -2764,7 +2762,7 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesDisabled) {
EXPECT_EQ(1, network_delegate.set_cookie_count());
}
- // Verify that the cookie is sent for first-party requests.
+ // Verify that the cookie is sent for same-site requests.
{
TestNetworkDelegate network_delegate;
network_delegate.set_experimental_cookie_features_enabled(false);
@@ -2776,13 +2774,13 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesDisabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("FirstPartyCookieToSet=1") !=
+ EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=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.
+ // Verify that the cookie is also sent for cross-site requests.
{
TestNetworkDelegate network_delegate;
network_delegate.set_experimental_cookie_features_enabled(false);
@@ -2790,11 +2788,11 @@ TEST_F(URLRequestTest, FirstPartyOnlyCookiesDisabled) {
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->set_first_party_for_cookies(GURL("http://cross-site.test/"));
req->Start();
base::RunLoop().Run();
- EXPECT_NE(d.data_received().find("FirstPartyCookieToSet=1"),
+ EXPECT_NE(d.data_received().find("SameSiteCookieToSet=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_http_job.cc ('k') | third_party/WebKit/LayoutTests/inspector/components/cookie-parser.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698