diff options
author | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 14:48:15 +0000 |
---|---|---|
committer | pfeldman@chromium.org <pfeldman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-30 14:48:15 +0000 |
commit | 6e2efc0462d72267c5a524411e4771e67da206e1 (patch) | |
tree | 4a04584732416447adae2132ec391c6ea5b8bde1 /net/base/cookie_monster_unittest.cc | |
parent | 08c0f98e3c63880dd0975afa9cd6a10c1f10c94e (diff) | |
download | chromium_src-6e2efc0462d72267c5a524411e4771e67da206e1.zip chromium_src-6e2efc0462d72267c5a524411e4771e67da206e1.tar.gz chromium_src-6e2efc0462d72267c5a524411e4771e67da206e1.tar.bz2 |
DevTools: Allow deleting cookies.
Review URL: http://codereview.chromium.org/350001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@30578 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/cookie_monster_unittest.cc')
-rw-r--r-- | net/base/cookie_monster_unittest.cc | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/net/base/cookie_monster_unittest.cc b/net/base/cookie_monster_unittest.cc index 8fda8db..bb45b68 100644 --- a/net/base/cookie_monster_unittest.cc +++ b/net/base/cookie_monster_unittest.cc @@ -961,4 +961,44 @@ TEST(CookieMonsterTest, SetCookieableSchemes) { EXPECT_FALSE(cm_foo->SetCookie(http_url, "x=1")); } +TEST(CookieMonsterTest, GetRawCookies) { + scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); + GURL url_google(kUrlGoogle); + + net::CookieOptions options; + options.set_include_httponly(); + + // Create a httponly cookie. + EXPECT_TRUE(cm->SetCookieWithOptions(url_google, "A=B; httponly", options)); + + // Get raw cookies. + std::vector<net::CookieMonster::CanonicalCookie> raw_cookies; + cm->GetRawCookies(url_google, &raw_cookies); + EXPECT_TRUE(raw_cookies.begin() != raw_cookies.end()); + net::CookieMonster::CanonicalCookie cookie = *raw_cookies.begin(); + EXPECT_EQ("A", cookie.Name()); +} + +TEST(CookieMonsterTest, DeleteCookieByName) { + scoped_refptr<net::CookieMonster> cm(new net::CookieMonster); + GURL url_google(kUrlGoogle); + + EXPECT_TRUE(cm->SetCookie(url_google, "A=A1; path=/")); + EXPECT_TRUE(cm->SetCookie(url_google, "A=A2; path=/foo")); + EXPECT_TRUE(cm->SetCookie(url_google, "A=A3; path=/bar")); + EXPECT_TRUE(cm->SetCookie(url_google, "B=B1; path=/")); + EXPECT_TRUE(cm->SetCookie(url_google, "B=B2; path=/foo")); + EXPECT_TRUE(cm->SetCookie(url_google, "B=B3; path=/bar")); + + cm->DeleteCookie(GURL(std::string(kUrlGoogle) + "/foo/bar"), "A"); + + net::CookieMonster::CookieList cookies = cm->GetAllCookies(); + EXPECT_EQ(4, cookies.size()); + for (net::CookieMonster::CookieList::iterator it = cookies.begin(); + it != cookies.end(); ++it) { + EXPECT_NE("A1", it->second.Value()); + EXPECT_NE("A2", it->second.Value()); + } +} + // TODO test overwrite cookie |