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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 2306393002: Loosen strict 'Secure' checks for non-overlapping paths. (Closed)
Patch Set: oops Created 4 years, 3 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/canonical_cookie_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_monster_unittest.cc
diff --git a/net/cookies/cookie_monster_unittest.cc b/net/cookies/cookie_monster_unittest.cc
index bba8fa401bab9409081d80d76f25ade0afcd0020..6aa9a33613a172e1c4d3475611d0081896fd896a 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -3070,16 +3070,25 @@ TEST_F(CookieMonsterStrictSecureTest, SetSecureCookies) {
EXPECT_TRUE(SetCookie(cm.get(), https_url, "A=C;"));
// If a non-secure cookie is created from a URL with an insecure scheme, and
- // a secure cookie with the same name already exists, no matter what the path
- // is, do not update the cookie.
+ // a secure cookie with the same name already exists, do not update the cookie
+ // if the new cookie's path matches the existing cookie's path.
+ //
+ // With an existing cookie whose path is '/', a cookie with the same name
+ // cannot be set on the same domain, regardless of path:
EXPECT_TRUE(SetCookie(cm.get(), https_url, "A=B; Secure"));
EXPECT_FALSE(SetCookie(cm.get(), http_url, "A=C; path=/"));
EXPECT_FALSE(SetCookie(cm.get(), http_url, "A=C; path=/my/path"));
- EXPECT_TRUE(SetCookie(cm.get(), https_url, "A=B; Secure; path=/my/path"));
- EXPECT_FALSE(SetCookie(cm.get(), http_url, "A=C"));
- EXPECT_FALSE(SetCookie(cm.get(), http_url, "A=C; path=/"));
- EXPECT_FALSE(SetCookie(cm.get(), http_url, "A=C; path=/my/path"));
+ // But if the existing cookie has a path somewhere under the root, cookies
+ // with the same name may be set for paths which don't overlap the existing
+ // cookie.
+ EXPECT_TRUE(
+ SetCookie(cm.get(), https_url, "WITH_PATH=B; Secure; path=/my/path"));
+ EXPECT_TRUE(SetCookie(cm.get(), http_url, "WITH_PATH=C"));
+ EXPECT_TRUE(SetCookie(cm.get(), http_url, "WITH_PATH=C; path=/"));
+ EXPECT_TRUE(SetCookie(cm.get(), http_url, "WITH_PATH=C; path=/your/path"));
+ EXPECT_FALSE(SetCookie(cm.get(), http_url, "WITH_PATH=C; path=/my/path"));
+ EXPECT_FALSE(SetCookie(cm.get(), http_url, "WITH_PATH=C; path=/my/path/sub"));
// If a non-secure cookie is created from a URL with an insecure scheme, and
// a secure cookie with the same name already exists, if the domain strings
« no previous file with comments | « net/cookies/canonical_cookie_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698