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

Unified Diff: net/cookies/cookie_store_unittest.h

Issue 2898953008: Implement and test CanonicalCookie::IsCanonical() (Closed)
Patch Set: Removed vestigial code. 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
« no previous file with comments | « net/cookies/cookie_monster_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 8120bf0db65774f04db02dbf59fc80d8f9d37315..14aa3e9be567afa3c34ca22295ad6fc0444271ce 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -1279,6 +1279,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_foo("http://www.foo.com/");
+ CookieStore* cs = this->GetCookieStore();
+
+ CookieOptions options;
+ if (!TypeParam::supports_http_only)
+ options.set_include_httponly();
+ EXPECT_TRUE(this->SetCookieWithOptions(cs, url_foo, "a", options));
+ CookieList list = this->GetAllCookiesForURL(cs, url_foo);
+ 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_foo, "=b", options));
+ list = this->GetAllCookiesForURL(cs, url_foo);
+ 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.
@@ -1476,6 +1508,7 @@ REGISTER_TYPED_TEST_CASE_P(CookieStoreTest,
TestSecure,
NetUtilCookieTest,
OverwritePersistentCookie,
+ EmptyName,
CookieOrdering,
GetAllCookiesAsync,
DeleteCookieAsync,
« no previous file with comments | « net/cookies/cookie_monster_unittest.cc ('k') | net/cookies/parsed_cookie.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698