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

Unified Diff: net/url_request/url_request_unittest.cc

Issue 1783813002: SameSite: Strict/Lax behavior. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@strict-lax
Patch Set: WIP. Created 4 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
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 fef773db63c9db0f2b2cdfa998de448ddfaec5a4..243665b91eb7f663bc6bffb677c6435c84d3f419 100644
--- a/net/url_request/url_request_unittest.cc
+++ b/net/url_request/url_request_unittest.cc
@@ -2664,16 +2664,16 @@ TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
{
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
- test_server.GetURL("/set-cookie?SameSiteCookieToSet=1;SameSite=Strict"),
+ test_server.GetURL("/set-cookie?StrictSameSiteCookie=1;SameSite=Strict&LaxSameSiteCookie=1;SameSite=Lax"),
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());
+ EXPECT_EQ(2, network_delegate.set_cookie_count());
}
- // Verify that the cookie is sent for same-site requests.
+ // Verify that both cookies are sent for same-site requests.
{
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
@@ -2683,13 +2683,13 @@ TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=1") !=
- std::string::npos);
+ EXPECT_NE(std::string::npos, d.data_received().find("StrictSameSiteCookie=1"));
+ EXPECT_NE(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
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 cross-site requests.
+ // Verify that neither cookie is not sent for cross-site requests.
{
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
@@ -2699,13 +2699,13 @@ TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=1") ==
- std::string::npos);
+ EXPECT_EQ(std::string::npos, d.data_received().find("StrictSameSiteCookie=1"));
+ EXPECT_EQ(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
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 cross-site initiators when the
+ // Verify that the lax cookie is sent for cross-site initiators when the
// method is "safe".
{
TestDelegate d;
@@ -2716,13 +2716,13 @@ TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_FALSE(d.data_received().find("SameSiteCookieToSet=1") ==
- std::string::npos);
+ EXPECT_EQ(std::string::npos, d.data_received().find("StrictSameSiteCookie=1"));
+ EXPECT_NE(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
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 cross-site initiators when the
+ // Verify that neither cookie is sent for cross-site initiators when the
// method is unsafe (e.g. POST).
{
TestDelegate d;
@@ -2734,8 +2734,8 @@ TEST_F(URLRequestTest, SameSiteCookiesEnabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=1") ==
- std::string::npos);
+ EXPECT_EQ(std::string::npos, d.data_received().find("StrictSameSiteCookie=1"));
+ EXPECT_EQ(std::string::npos, d.data_received().find("LaxSameSiteCookie=1"));
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
}
@@ -2754,13 +2754,13 @@ TEST_F(URLRequestTest, SameSiteCookiesDisabled) {
TestDelegate d;
scoped_ptr<URLRequest> req(default_context_.CreateRequest(
- test_server.GetURL("/set-cookie?SameSiteCookieToSet=1;SameSite"),
+ test_server.GetURL("/set-cookie?StrictSameSiteCookie=1;SameSite=Strict&LaxSameSiteCookie=1;SameSite=Lax"),
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());
+ EXPECT_EQ(2, network_delegate.set_cookie_count());
}
// Verify that the cookie is sent for same-site requests.
@@ -2775,7 +2775,9 @@ TEST_F(URLRequestTest, SameSiteCookiesDisabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_TRUE(d.data_received().find("SameSiteCookieToSet=1") !=
+ EXPECT_TRUE(d.data_received().find("StrictSameSiteCookie=1") !=
+ std::string::npos);
+ EXPECT_TRUE(d.data_received().find("LaxSameSiteCookie=1") !=
std::string::npos);
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
@@ -2793,8 +2795,10 @@ TEST_F(URLRequestTest, SameSiteCookiesDisabled) {
req->Start();
base::RunLoop().Run();
- EXPECT_NE(d.data_received().find("SameSiteCookieToSet=1"),
+ EXPECT_NE(d.data_received().find("StrictSameSiteCookie=1"),
std::string::npos);
+ EXPECT_TRUE(d.data_received().find("LaxSameSiteCookie=1") !=
+ std::string::npos);
EXPECT_EQ(0, network_delegate.blocked_get_cookies_count());
EXPECT_EQ(0, network_delegate.blocked_set_cookie_count());
}
« net/url_request/url_request_http_job.cc ('K') | « net/url_request/url_request_http_job.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698