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

Unified Diff: net/cookies/cookie_store_unittest.h

Issue 2898953008: Implement and test CanonicalCookie::IsCanonical() (Closed)
Patch Set: Add test param to Android Webview cookie test. Created 3 years, 6 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/cookies/cookie_store_unittest.h
diff --git a/net/cookies/cookie_store_unittest.h b/net/cookies/cookie_store_unittest.h
index e8ac988290c4e75984e17bc212b8249bf74ae6ca..cf694b0f801c4f03a8f4b93a67e05bebb763566d 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -1278,6 +1278,38 @@ TYPED_TEST_P(CookieStoreTest, OverwritePersistentCookie) {
"a=val99", this->GetCookies(cs, GURL("http://chromium.org/path1")));
}
+// Note that accepting an empty name is contrary to spec; see
+// https://tools.ietf.org/html/rfc6265#section-4.1.1. However, we do it
+// for web compatibility; see http://inikulin.github.io/cookie-compat/
+// (specifically the "foo" and "=a" tests). This test is present in Chromium
+// so that a flag is raised if this behavior is changed.
+// On IOS we use the system cookie store which has Safari's behavior, so
+// the test is skipped.
+TYPED_TEST_P(CookieStoreTest, EmptyName) {
+ if (TypeParam::forbids_setting_empty_name)
+ return;
+
+ GURL url_google("http://www.google.com/");
+ CookieStore* cs = this->GetCookieStore();
+
+ CookieOptions options;
+ if (!TypeParam::supports_http_only)
+ options.set_include_httponly();
+ EXPECT_TRUE(this->SetCookieWithOptions(cs, url_google, "a", options));
+ CookieList list = this->GetAllCookiesForURL(cs, url_google);
+ EXPECT_EQ(1u, list.size());
+ EXPECT_EQ("", list[0].Name());
+ EXPECT_EQ("a", list[0].Value());
+ EXPECT_EQ(1, this->DeleteAll(cs));
+
+ EXPECT_TRUE(this->SetCookieWithOptions(cs, url_google, "=b", options));
+ list = this->GetAllCookiesForURL(cs, url_google);
+ EXPECT_EQ(1u, list.size());
+ EXPECT_EQ("", list[0].Name());
+ EXPECT_EQ("b", list[0].Value());
+ EXPECT_EQ(1, this->DeleteAll(cs));
+}
+
TYPED_TEST_P(CookieStoreTest, CookieOrdering) {
// Put a random set of cookies into a store and make sure they're returned in
// the right order.
@@ -1483,6 +1515,7 @@ REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
TestSecure,
NetUtilCookieTest,
OverwritePersistentCookie,
+ EmptyName,
CookieOrdering,
GetAllCookiesAsync,
DeleteCookieAsync,
« net/cookies/canonical_cookie_unittest.cc ('K') | « net/cookies/cookie_monster_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698