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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 2924933002: Fix CookieMonster garbage collection when no insecure cookies. (Closed)
Patch Set: Oops Created 3 years, 6 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/cookie_monster.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 3b958f2703ededa5bf8a5d496e16d9d62af423f2..da46fd99987b820c4a83ed6c71cd5c85ee71b25f 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -2222,6 +2222,25 @@ TEST_F(CookieMonsterTest, MAYBE_GarbageCollectionTriggers) {
}
}
+// Tests garbage collection when there are only secure cookies.
+// See https://crbug/730000
+TEST_F(CookieMonsterTest, GarbageCollectWithSecureCookiesOnly) {
+ // Create a CookieMonster at its cookie limit. A bit confusing, but the second
+ // number is a subset of the first number.
+ std::unique_ptr<CookieMonster> cm = CreateMonsterFromStoreForGC(
+ CookieMonster::kMaxCookies /* num_secure_cookies */,
+ CookieMonster::kMaxCookies /* num_old_secure_cookies */,
+ 0 /* num_non_secure_cookies */, 0 /* num_old_non_secure_cookies */,
+ CookieMonster::kSafeFromGlobalPurgeDays * 2 /* days_old */);
+ EXPECT_EQ(CookieMonster::kMaxCookies, GetAllCookies(cm.get()).size());
+
+ // Trigger purge with a secure cookie (So there are still no insecure
+ // cookies).
+ SetCookie(cm.get(), GURL("https://newdomain.com"), "b=2; Secure");
+ EXPECT_EQ(CookieMonster::kMaxCookies - CookieMonster::kPurgeCookies,
+ GetAllCookies(cm.get()).size());
+}
+
// Tests that if the main load event happens before the loaded event for a
// particular key, the tasks for that key run first.
TEST_F(CookieMonsterTest, WhileLoadingLoadCompletesBeforeKeyLoadCompletes) {
« no previous file with comments | « net/cookies/cookie_monster.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698