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

Unified Diff: net/base/cookie_monster_unittest.cc

Issue 8533013: SessionRestore: Store session cookies and restore them if chrome crashes or auto-restarts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Code review. Created 9 years 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/base/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/base/cookie_monster_unittest.cc
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc
index ce8d9ae29c5d4095e413c0149af5a019d2a8132e..0ae6e9d07ae98b16ee57a0bab0150a13b855c0fe 100644
--- a/net/base/cookie_monster_unittest.cc
+++ b/net/base/cookie_monster_unittest.cc
@@ -3579,4 +3579,42 @@ TEST_F(CookieMonsterTest, InvalidExpiryTime) {
ASSERT_FALSE(cookie->DoesExpire());
}
+// Test that CookieMonster writes session cookies into the underlying
+// CookieStore if the "persist session cookies" option is on.
+TEST_F(CookieMonsterTest, PersistSessionCookies) {
+ scoped_refptr<MockPersistentCookieStore> store(
+ new MockPersistentCookieStore);
+ scoped_refptr<CookieMonster> cm(new CookieMonster(store, NULL));
+ cm->SetPersistSessionCookies(true);
+
+ // All cookies set with SetCookie are session cookies.
+ EXPECT_TRUE(SetCookie(cm, url_google_, "A=B"));
+ EXPECT_EQ("A=B", GetCookies(cm, url_google_));
+
+ // The cookie was written to the backing store.
+ EXPECT_EQ(1u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[0].type);
+ EXPECT_EQ("A", store->commands()[0].cookie.Name());
+ EXPECT_EQ("B", store->commands()[0].cookie.Value());
+
+ // Modify the cookie.
+ EXPECT_TRUE(SetCookie(cm, url_google_, "A=C"));
+ EXPECT_EQ("A=C", GetCookies(cm, url_google_));
+ EXPECT_EQ(3u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[1].type);
+ EXPECT_EQ("A", store->commands()[1].cookie.Name());
+ EXPECT_EQ("B", store->commands()[1].cookie.Value());
+ EXPECT_EQ(CookieStoreCommand::ADD, store->commands()[2].type);
+ EXPECT_EQ("A", store->commands()[2].cookie.Name());
+ EXPECT_EQ("C", store->commands()[2].cookie.Value());
+
+ // Delete the cookie.
+ DeleteCookie(cm, url_google_, "A");
+ EXPECT_EQ("", GetCookies(cm, url_google_));
+ EXPECT_EQ(4u, store->commands().size());
+ EXPECT_EQ(CookieStoreCommand::REMOVE, store->commands()[3].type);
+ EXPECT_EQ("A", store->commands()[3].cookie.Name());
+ EXPECT_EQ("C", store->commands()[3].cookie.Value());
+}
+
} // namespace net
« no previous file with comments | « net/base/cookie_monster.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698