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

Unified Diff: net/cookies/cookie_store_unittest.cc

Issue 1844243002: [CookieStore] Upgrading host-based deleting to predicate-based deleting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added android changes Created 4 years, 9 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
« net/cookies/cookie_store_unittest.h ('K') | « net/cookies/cookie_store_unittest.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/cookie_store_unittest.cc
diff --git a/net/cookies/cookie_store_unittest.cc b/net/cookies/cookie_store_unittest.cc
index 739336594a7026dc45d8c1aad3e97dd6f2b49af6..f1770a679658eb2a1a04c04fa15f422925f3a4c7 100644
--- a/net/cookies/cookie_store_unittest.cc
+++ b/net/cookies/cookie_store_unittest.cc
@@ -62,4 +62,34 @@ TEST(CookieStoreBaseTest, BuildCookieLine) {
MatchCookieLineToVector("A=B; C; D=E; F=G; D=E", cookies);
}
+TEST(CookieStoreBaseTest, CreatePredicateForHostCookies) {
+ GURL url("http://www.example.com/");
+ GURL url2("https://www.example.com/");
+ GURL url3("https://www.google.com/");
+
+ CookieOptions options;
+ CookieStore::CookiePredicate predicate =
+ CookieStore::CreatePredicateForHostCookies(url);
+
+ base::Time now = base::Time::Now();
+ std::vector<scoped_ptr<CanonicalCookie>> valid_cookies;
+ valid_cookies.push_back(CanonicalCookie::Create(url, "A=B", now, options));
+ valid_cookies.push_back(CanonicalCookie::Create(url, "C=F", now, options));
+ // We should match a different scheme with the same host.
+ valid_cookies.push_back(CanonicalCookie::Create(url2, "A=B", now, options));
+
+ std::vector<scoped_ptr<CanonicalCookie>> invalid_cookies;
+ // We don't match domain cookies.
+ invalid_cookies.push_back(
+ CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options));
+ invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options));
+
+ for (const auto& cookie : valid_cookies) {
+ EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString();
+ }
+ for (const auto& cookie : invalid_cookies) {
+ EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString();
+ }
+}
+
} // namespace net
« net/cookies/cookie_store_unittest.h ('K') | « net/cookies/cookie_store_unittest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698