| 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 d0e5d2556e882b14849cfb8d145e03496a1be4f0..71fb60ea804ad955b8e57dfce0ea785019e061dc 100644
|
| --- a/net/url_request/url_request_unittest.cc
|
| +++ b/net/url_request/url_request_unittest.cc
|
| @@ -2646,7 +2646,7 @@ TEST_F(URLRequestTest, DoNotSaveCookies_ViaPolicy_Async) {
|
| }
|
| }
|
|
|
| -TEST_F(URLRequestTest, FirstPartyOnlyCookiesEnabled) {
|
| +TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
|
| LocalHttpTestServer test_server;
|
| ASSERT_TRUE(test_server.Start());
|
|
|
| @@ -2654,13 +2654,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();
|
| @@ -2669,7 +2668,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(
|
| @@ -2679,69 +2678,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;
|
| @@ -2750,8 +2749,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();
|
| @@ -2760,7 +2758,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);
|
| @@ -2772,13 +2770,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);
|
| @@ -2786,11 +2784,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());
|
|
|