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

Unified Diff: net/cookies/cookie_monster_unittest.cc

Issue 859663003: GetEffectiveDomain should handle ws scheme as same as http scheme. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 11 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/base/registry_controlled_domains/test_util.cc ('k') | net/cookies/cookie_store_unittest.h » ('j') | 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 633bca59493b4fff654e8b875cbf1e22446d4e3a..32466ec4bcbe91bd68cb68d63350a05ad1435ff4 100644
--- a/net/cookies/cookie_monster_unittest.cc
+++ b/net/cookies/cookie_monster_unittest.cc
@@ -2611,6 +2611,72 @@ TEST_F(MultiThreadedCookieMonsterTest, ThreadCheckDeleteCanonicalCookie) {
EXPECT_TRUE(callback.result());
}
+TEST_F(MultiThreadedCookieMonsterTest, GetAllCookiesForURLEffectiveDomain) {
+ std::vector<CanonicalCookie*> cookies;
+ // This cookie is freed by the CookieMonster.
Ryan Sleevi 2015/01/22 01:43:41 is? or will be?
yhirano 2015/01/23 03:34:36 Done.
+ cookies.push_back(CanonicalCookie::Create(url_google_, kValidCookieLine,
+ Time::Now(), CookieOptions()));
+ CanonicalCookie cookie = *cookies[0];
Ryan Sleevi 2015/01/22 01:43:41 Did you mean to copy? If so, why?
yhirano 2015/01/23 03:34:36 I want to have a cookie to verify the result below
+ scoped_refptr<NewMockPersistentCookieStore> store(
+ new NewMockPersistentCookieStore);
+ scoped_refptr<CookieMonster> cm(new CookieMonster(store.get(), NULL));
+
+ CookieMonster::PersistentCookieStore::LoadedCallback loaded_callback;
+ ::testing::StrictMock<::testing::MockFunction<void(int)>> checkpoint;
Ryan Sleevi 2015/01/22 01:43:41 This seems unnecessary/overkill. The relation of c
yhirano 2015/01/23 03:34:36 I want to check that all monitored calls happens b
+ const std::string key = "google.izzle";
Ryan Sleevi 2015/01/22 01:43:41 What is this magic string and why are you using it
yhirano 2015/01/23 03:34:36 Done.
+
+ {
+ ::testing::InSequence s;
+ EXPECT_CALL(checkpoint, Call(0));
+ EXPECT_CALL(*store, Load(::testing::_));
+ EXPECT_CALL(*store, LoadCookiesForKey(key, ::testing::_))
+ .WillOnce(::testing::SaveArg<1>(&loaded_callback));
+ EXPECT_CALL(checkpoint, Call(1));
+ // LoadCookiesForKey will never be called, because they share the same key.
+ }
+
+ checkpoint.Call(0);
+ {
+ GetCookieListCallback callback;
+ GetAllCookiesForURLTask(cm.get(), url_google_, &callback);
+ checkpoint.Call(1);
+ EXPECT_FALSE(callback.did_run());
+ loaded_callback.Run(cookies);
Ryan Sleevi 2015/01/22 01:43:41 This is a bit surprising and non-obvious. Needs be
yhirano 2015/01/23 03:34:36 It is necessary. By calling loaded_callback, we no
+ EXPECT_TRUE(callback.did_run());
+ ASSERT_EQ(1u, callback.cookies().size());
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0]));
+ }
+ {
+ GetCookieListCallback callback;
+ GetAllCookiesForURLTask(cm.get(), url_google_, &callback);
+ EXPECT_TRUE(callback.did_run());
+ ASSERT_EQ(1u, callback.cookies().size());
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0]));
+ }
+ {
+ GetCookieListCallback callback;
+ GetAllCookiesForURLTask(cm.get(), url_google_secure_, &callback);
+ EXPECT_TRUE(callback.did_run());
+ ASSERT_EQ(1u, callback.cookies().size());
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0]));
+ }
+ {
+ GetCookieListCallback callback;
+ GetAllCookiesForURLTask(cm.get(), GURL(kUrlGoogleWebSocket), &callback);
+ EXPECT_TRUE(callback.did_run());
+ ASSERT_EQ(1u, callback.cookies().size());
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0]));
+ }
+ {
+ GetCookieListCallback callback;
+ GetAllCookiesForURLTask(cm.get(), GURL(kUrlGoogleWebSocketSecure),
+ &callback);
+ EXPECT_TRUE(callback.did_run());
+ ASSERT_EQ(1u, callback.cookies().size());
+ EXPECT_TRUE(cookie.IsEquivalent(callback.cookies()[0]));
+ }
Ryan Sleevi 2015/01/22 01:43:41 The documentation for each of these assertions is
yhirano 2015/01/23 03:34:36 Done.
+}
+
TEST_F(CookieMonsterTest, InvalidExpiryTime) {
std::string cookie_line =
std::string(kValidCookieLine) + "; expires=Blarg arg arg";
« no previous file with comments | « net/base/registry_controlled_domains/test_util.cc ('k') | net/cookies/cookie_store_unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698