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

Unified Diff: net/cookies/cookie_store_unittest.h

Issue 2246613003: Update cookie value and attribute setting behavior to match other UAs (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Simplification Created 4 years, 4 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 | « chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc ('k') | net/cookies/parsed_cookie.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_store_unittest.h
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
index 3f8b037cef84c7e61ccd3acb8f2cb93b3cbf6d33..7bef37fbf5a5e6144125a3da51cd99a32061debb 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -465,6 +465,46 @@ TYPED_TEST_P(CookieStoreTest, SetCookieWithDetailsAsync) {
EXPECT_TRUE(++it == cookies.end());
}
+// The iOS networking stack uses the iOS cookie parser, which we do not
+// control. While it is spec-compliant, that does not match the practical
+// behavior of most UAs in some cases, which we try to replicate. See
+// https://crbug.com/638389 for more information.
+TYPED_TEST_P(CookieStoreTest, EmptyKeyTest) {
+#if !defined(OS_IOS)
+ CookieStore* cs = this->GetCookieStore();
+
+ GURL url1("http://foo1.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url1, "foo"));
+ EXPECT_EQ("foo", this->GetCookies(cs, url1));
+
+ // Regression tests for https://crbug.com/601786
+ GURL url2("http://foo2.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url2, "foo"));
+ EXPECT_TRUE(this->SetCookie(cs, url2, "\t"));
+ EXPECT_EQ("", this->GetCookies(cs, url2));
+
+ GURL url3("http://foo3.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url3, "foo"));
+ EXPECT_TRUE(this->SetCookie(cs, url3, "="));
+ EXPECT_EQ("", this->GetCookies(cs, url3));
+
+ GURL url4("http://foo4.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url4, "foo"));
+ EXPECT_TRUE(this->SetCookie(cs, url4, ""));
+ EXPECT_EQ("", this->GetCookies(cs, url4));
+
+ GURL url5("http://foo5.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url5, "foo"));
+ EXPECT_TRUE(this->SetCookie(cs, url5, "; bar"));
+ EXPECT_EQ("", this->GetCookies(cs, url5));
+
+ GURL url6("http://foo6.bar.com");
+ EXPECT_TRUE(this->SetCookie(cs, url6, "foo"));
+ EXPECT_TRUE(this->SetCookie(cs, url6, " "));
+ EXPECT_EQ("", this->GetCookies(cs, url6));
+#endif
+}
+
TYPED_TEST_P(CookieStoreTest, DomainTest) {
CookieStore* cs = this->GetCookieStore();
EXPECT_TRUE(this->SetCookie(cs, this->http_www_google_.url(), "A=B"));
@@ -562,6 +602,9 @@ TYPED_TEST_P(CookieStoreTest, InvalidDomainTest) {
// More specific sub-domain than allowed.
EXPECT_FALSE(this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com"));
+ // Regression test for https://crbug.com/601786
+ EXPECT_FALSE(
+ this->SetCookie(cs, url_foobar, "a=1; domain=.yo.foo.bar.com; domain="));
EXPECT_FALSE(this->SetCookie(cs, url_foobar, "b=2; domain=.foo.com"));
EXPECT_FALSE(this->SetCookie(cs, url_foobar, "c=3; domain=.bar.foo.com"));
@@ -1374,6 +1417,7 @@ TYPED_TEST_P(CookieStoreTest, DeleteSessionCookie) {
REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
SetCookieWithDetailsAsync,
+ EmptyKeyTest,
DomainTest,
DomainWithTrailingDotTest,
ValidSubdomainTest,
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_cookie_helper_unittest.cc ('k') | net/cookies/parsed_cookie.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698