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

Unified Diff: net/cookies/canonical_cookie_unittest.cc

Issue 1411813003: Teach URLRequest about initiator checks for First-Party-Only cookies. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Feedback. Created 5 years, 2 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/canonical_cookie_unittest.cc
diff --git a/net/cookies/canonical_cookie_unittest.cc b/net/cookies/canonical_cookie_unittest.cc
index 58c12ca656d447040152e9bcb9b612918f07d179..bc6a9a997b5a68b69777cd2381b9c734b0411c7e 100644
--- a/net/cookies/canonical_cookie_unittest.cc
+++ b/net/cookies/canonical_cookie_unittest.cc
@@ -84,7 +84,7 @@ TEST(CanonicalCookieTest, Create) {
// Test creating http only cookies.
CookieOptions first_party_options;
- first_party_options.set_first_party(url::Origin(url));
+ first_party_options.set_include_first_party_only();
cookie.reset(CanonicalCookie::Create(url, "A=2; First-Party-Only",
creation_time, httponly_options));
EXPECT_TRUE(cookie.get());
@@ -347,43 +347,37 @@ TEST(CanonicalCookieTest, IncludeFirstPartyForFirstPartyURL) {
CookieOptions options;
scoped_ptr<CanonicalCookie> cookie;
- // First-party-only cookies are not inlcuded if a top-level URL is unset.
+ // First-party-only cookies are not included for non-first-party requests,
+ // even if other properties match:
cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only",
creation_time, options));
EXPECT_TRUE(cookie->IsFirstPartyOnly());
- options.set_first_party(url::Origin());
EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
-
- // First-party-only cookies are included only if the cookie's origin matches
- // the
- // first-party origin.
- options.set_first_party(url::Origin(secure_url));
- EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options));
- options.set_first_party(url::Origin(insecure_url));
+ cookie.reset(CanonicalCookie::Create(
+ secure_url, "A=2; Secure; First-Party-Only", creation_time, options));
+ EXPECT_TRUE(cookie->IsFirstPartyOnly());
EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
- options.set_first_party(url::Origin(third_party_url));
+ cookie.reset(CanonicalCookie::Create(secure_url_with_path,
+ "A=2; First-Party-Only; path=/foo/bar",
+ creation_time, options));
+ EXPECT_TRUE(cookie->IsFirstPartyOnly());
EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
- // "First-Party-Only" doesn't override the 'secure' flag.
+ // First-party-only cookies are included for first-party requests:
+ options.set_include_first_party_only();
+ cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only",
+ creation_time, options));
+ EXPECT_TRUE(cookie->IsFirstPartyOnly());
+ EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options));
cookie.reset(CanonicalCookie::Create(
secure_url, "A=2; Secure; First-Party-Only", creation_time, options));
- options.set_first_party(url::Origin(secure_url));
+ EXPECT_TRUE(cookie->IsFirstPartyOnly());
EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url, options));
- EXPECT_FALSE(cookie->IncludeForRequestURL(insecure_url, options));
- options.set_first_party(url::Origin(insecure_url));
- EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
- EXPECT_FALSE(cookie->IncludeForRequestURL(insecure_url, options));
-
- // "First-Party-Only" doesn't override the 'path' flag.
cookie.reset(CanonicalCookie::Create(secure_url_with_path,
"A=2; First-Party-Only; path=/foo/bar",
creation_time, options));
- options.set_first_party(url::Origin(secure_url_with_path));
- EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url_with_path, options));
- EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
- options.set_first_party(url::Origin(secure_url));
+ EXPECT_TRUE(cookie->IsFirstPartyOnly());
EXPECT_TRUE(cookie->IncludeForRequestURL(secure_url_with_path, options));
- EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
}
TEST(CanonicalCookieTest, PartialCompare) {

Powered by Google App Engine
This is Rietveld 408576698