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

Unified Diff: net/cookies/cookie_store_unittest.h

Issue 1414603010: Treat exact domain match cookies on public suffixes as host cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Test. Created 5 years, 1 month 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.cc ('k') | net/cookies/cookie_util.cc » ('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 f62f7ac2f67078d9642d3eb8e4e36ac76fdfa29b..f4f473906142316f87bea341ade4c9a7c14bb2eb 100644
--- a/net/cookies/cookie_store_unittest.h
+++ b/net/cookies/cookie_store_unittest.h
@@ -515,7 +515,26 @@ TYPED_TEST_P(CookieStoreTest, TestNonDottedAndTLD) {
// Allow setting on "com", (but only as a host cookie).
EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1"));
EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.com"));
- EXPECT_FALSE(this->SetCookie(cs.get(), url, "c=3; domain=com"));
+
+ this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url));
+ // Make sure it doesn't show up for a normal .com, it should be a host
+ // not a domain cookie.
+ this->MatchCookieLines(
+ std::string(),
+ this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.com/")));
+ if (TypeParam::supports_non_dotted_domains) {
+ this->MatchCookieLines(std::string(),
+ this->GetCookies(cs.get(), GURL("http://.com/")));
+ }
+ }
+
+ {
+ // Exact matches between the domain attribute and the host are treated as
+ // host cookies, not domain cookies.
+ scoped_refptr<CookieStore> cs(this->GetCookieStore());
+ GURL url("http://com/");
+ EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=com"));
+
this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url));
// Make sure it doesn't show up for a normal .com, it should be a host
// not a domain cookie.
@@ -575,9 +594,27 @@ TYPED_TEST_P(CookieStoreTest, TestNonDottedAndTLD) {
GURL url("http://b");
EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1"));
EXPECT_FALSE(this->SetCookie(cs.get(), url, "b=2; domain=.b"));
- EXPECT_FALSE(this->SetCookie(cs.get(), url, "c=3; domain=b"));
this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url));
}
+
+ {
+ // Exact matches between the domain attribute and an intranet host are
+ // treated as host cookies, not domain cookies.
+ scoped_refptr<CookieStore> cs(this->GetCookieStore());
+ GURL url("http://b/");
+ EXPECT_TRUE(this->SetCookie(cs.get(), url, "a=1; domain=b"));
+
+ this->MatchCookieLines("a=1", this->GetCookies(cs.get(), url));
+ // Make sure it doesn't show up for an intranet subdomain, it should be a
+ // host not a domain cookie.
+ this->MatchCookieLines(
+ std::string(),
+ this->GetCookies(cs.get(), GURL("http://hopefully-no-cookies.b/")));
+ if (TypeParam::supports_non_dotted_domains) {
+ this->MatchCookieLines(std::string(),
+ this->GetCookies(cs.get(), GURL("http://.b/")));
+ }
+ }
}
// Test reading/writing cookies when the domain ends with a period,
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698