summaryrefslogtreecommitdiffstats
path: root/net/base/static_cookie_policy_unittest.cc
diff options
context:
space:
mode:
authordarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 08:24:12 +0000
committerdarin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-30 08:24:12 +0000
commitcb370a06391bd8cd1d3c52e4722645962366dd42 (patch)
tree9ca36ba10363365401bd1a816962f4679fda8467 /net/base/static_cookie_policy_unittest.cc
parentdbefae2c2db09a90c2b9ee4d3ea1a40e580e532e (diff)
downloadchromium_src-cb370a06391bd8cd1d3c52e4722645962366dd42.zip
chromium_src-cb370a06391bd8cd1d3c52e4722645962366dd42.tar.gz
chromium_src-cb370a06391bd8cd1d3c52e4722645962366dd42.tar.bz2
Changes to support new cookie policy.
Changes: 1- net::CookiePolicy becomes an interface. 2- Old implementaiton of CookiePolicy copied to StaticCookiePolicy. 3- ChromeULRRequestContext implements CookiePolicy. 4- HostContentSettingsMap gets a global "BlockThirdPartyCookies" pref. R=pkasting Review URL: http://codereview.chromium.org/556095 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37624 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/static_cookie_policy_unittest.cc')
-rw-r--r--net/base/static_cookie_policy_unittest.cc87
1 files changed, 87 insertions, 0 deletions
diff --git a/net/base/static_cookie_policy_unittest.cc b/net/base/static_cookie_policy_unittest.cc
new file mode 100644
index 0000000..35af0fc
--- /dev/null
+++ b/net/base/static_cookie_policy_unittest.cc
@@ -0,0 +1,87 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/base/static_cookie_policy.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "googleurl/src/gurl.h"
+
+class StaticCookiePolicyTest : public testing::Test {
+ public:
+ StaticCookiePolicyTest()
+ : url_google_("http://www.google.izzle"),
+ url_google_secure_("https://www.google.izzle"),
+ url_google_mail_("http://mail.google.izzle"),
+ url_google_analytics_("http://www.googleanalytics.izzle") { }
+ protected:
+ GURL url_google_;
+ GURL url_google_secure_;
+ GURL url_google_mail_;
+ GURL url_google_analytics_;
+};
+
+TEST_F(StaticCookiePolicyTest, DefaultPolicyTest) {
+ net::StaticCookiePolicy cp;
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_mail_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, GURL()));
+
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_mail_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, GURL()));
+}
+
+TEST_F(StaticCookiePolicyTest, AllowAllCookiesTest) {
+ net::StaticCookiePolicy cp;
+ cp.set_type(net::StaticCookiePolicy::ALLOW_ALL_COOKIES);
+
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_mail_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, GURL()));
+
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_mail_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, GURL()));
+}
+
+TEST_F(StaticCookiePolicyTest, BlockThirdPartyCookiesTest) {
+ net::StaticCookiePolicy cp;
+ cp.set_type(net::StaticCookiePolicy::BLOCK_THIRD_PARTY_COOKIES);
+
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_mail_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanGetCookies(url_google_, GURL()));
+
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_secure_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, url_google_mail_));
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, url_google_analytics_));
+ EXPECT_TRUE(cp.CanSetCookie(url_google_, GURL()));
+}
+
+TEST_F(StaticCookiePolicyTest, BlockAllCookiesTest) {
+ net::StaticCookiePolicy cp;
+ cp.set_type(net::StaticCookiePolicy::BLOCK_ALL_COOKIES);
+
+ EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_));
+ EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_secure_));
+ EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_mail_));
+ EXPECT_FALSE(cp.CanGetCookies(url_google_, url_google_analytics_));
+ EXPECT_FALSE(cp.CanGetCookies(url_google_, GURL()));
+
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, url_google_));
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, url_google_secure_));
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, url_google_mail_));
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, url_google_analytics_));
+ EXPECT_FALSE(cp.CanSetCookie(url_google_, GURL()));
+}