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

Side by Side Diff: net/cookies/canonical_cookie_unittest.cc

Issue 1253353004: WIP: Teach "First-Party-Only" cookies about the requestor origin. Base URL: https://chromium.googlesource.com/chromium/src.git@cookie-options
Patch Set: Created 5 years, 4 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 unified diff | Download patch
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/cookies/canonical_cookie.h" 5 #include "net/cookies/canonical_cookie.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "net/cookies/cookie_constants.h" 8 #include "net/cookies/cookie_constants.h"
9 #include "net/cookies/cookie_options.h" 9 #include "net/cookies/cookie_options.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 options.set_exclude_httponly(); 358 options.set_exclude_httponly();
359 EXPECT_FALSE(cookie->IncludeForRequestURL(url, options)); 359 EXPECT_FALSE(cookie->IncludeForRequestURL(url, options));
360 } 360 }
361 361
362 TEST(CanonicalCookieTest, IncludeFirstPartyForFirstPartyURL) { 362 TEST(CanonicalCookieTest, IncludeFirstPartyForFirstPartyURL) {
363 GURL insecure_url("http://example.test"); 363 GURL insecure_url("http://example.test");
364 GURL secure_url("https://example.test"); 364 GURL secure_url("https://example.test");
365 GURL secure_url_with_path("https://example.test/foo/bar/index.html"); 365 GURL secure_url_with_path("https://example.test/foo/bar/index.html");
366 GURL third_party_url("https://not-example.test"); 366 GURL third_party_url("https://not-example.test");
367 base::Time creation_time = base::Time::Now(); 367 base::Time creation_time = base::Time::Now();
368 scoped_ptr<CanonicalCookie> cookie;
369
368 CookieOptions options; 370 CookieOptions options;
369 scoped_ptr<CanonicalCookie> cookie; 371 options.set_requestor_origin(url::Origin(secure_url));
370 372
371 // First-party-only cookies are not inlcuded if a top-level URL is unset. 373 // First-party-only cookies are not inlcuded if a top-level URL is unset.
372 cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only", 374 cookie.reset(CanonicalCookie::Create(secure_url, "A=2; First-Party-Only",
373 creation_time, options)); 375 creation_time, options));
374 EXPECT_TRUE(cookie->IsFirstPartyOnly()); 376 EXPECT_TRUE(cookie->IsFirstPartyOnly());
375 options.set_first_party_url(GURL()); 377 options.set_first_party_url(GURL());
376 EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options)); 378 EXPECT_FALSE(cookie->IncludeForRequestURL(secure_url, options));
377 379
378 // First-party-only cookies are included only if the cookie's origin matches 380 // First-party-only cookies are included only if the cookie's origin matches
379 // the 381 // the
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 else if (b.FullCompare(a)) 466 else if (b.FullCompare(a))
465 EXPECT_FALSE(a.PartialCompare(b)); 467 EXPECT_FALSE(a.PartialCompare(b));
466 }; 468 };
467 469
468 check_consistency(*cookie, *cookie_different_path); 470 check_consistency(*cookie, *cookie_different_path);
469 check_consistency(*cookie, *cookie_different_value); 471 check_consistency(*cookie, *cookie_different_value);
470 check_consistency(*cookie_different_path, *cookie_different_value); 472 check_consistency(*cookie_different_path, *cookie_different_value);
471 } 473 }
472 474
473 } // namespace net 475 } // namespace net
OLDNEW
« no previous file with comments | « net/cookies/canonical_cookie.cc ('k') | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698