summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net/clear_on_exit_policy_unittest.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 15:48:43 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-05-30 15:48:43 +0000
commiteec733b006c0d5b9358fa0d7ac7b12e69c3efe3a (patch)
treec70add2e6b9a2fb30a1e20c62dde97a599aa263f /chrome/browser/net/clear_on_exit_policy_unittest.cc
parent0259a07689213496d647150550a67687c4361637 (diff)
downloadchromium_src-eec733b006c0d5b9358fa0d7ac7b12e69c3efe3a.zip
chromium_src-eec733b006c0d5b9358fa0d7ac7b12e69c3efe3a.tar.gz
chromium_src-eec733b006c0d5b9358fa0d7ac7b12e69c3efe3a.tar.bz2
Don't force non-session only cookies to be session only cookies, instead delete on shutdown
this is more consistent with how we treat other web site data types All storage backends except for cookies use the SpecialStoragePolicy to decide what data to delete and what to keep. Also, since they commonly don't have a session only notion, they will delete the data on shutdown. This CL unifies the way content settings are applied to storage systems by passing a SpecialStoragePolicy to the cookie store backend, and delete cookies on shutdown. BUG=129349 TEST=SQLitePersistentCookieStoreTest.TestSpecialStoragePolicy Review URL: https://chromiumcodereview.appspot.com/10407124 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139544 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net/clear_on_exit_policy_unittest.cc')
-rw-r--r--chrome/browser/net/clear_on_exit_policy_unittest.cc46
1 files changed, 46 insertions, 0 deletions
diff --git a/chrome/browser/net/clear_on_exit_policy_unittest.cc b/chrome/browser/net/clear_on_exit_policy_unittest.cc
new file mode 100644
index 0000000..d097feb
--- /dev/null
+++ b/chrome/browser/net/clear_on_exit_policy_unittest.cc
@@ -0,0 +1,46 @@
+// Copyright (c) 2012 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 "testing/gtest/include/gtest/gtest.h"
+
+#include "chrome/browser/net/clear_on_exit_policy.h"
+#include "googleurl/src/gurl.h"
+#include "webkit/quota/mock_special_storage_policy.h"
+
+
+TEST(ClearOnExitPolicyTest, HasClearOnExitOrigins) {
+ scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy =
+ new quota::MockSpecialStoragePolicy;
+ scoped_refptr<ClearOnExitPolicy> policy =
+ new ClearOnExitPolicy(storage_policy.get());
+
+ EXPECT_FALSE(policy->HasClearOnExitOrigins());
+
+ storage_policy->AddSessionOnly(GURL("http://test.com/"));
+ EXPECT_TRUE(policy->HasClearOnExitOrigins());
+}
+
+TEST(ClearOnExitPolicyTest, ShouldClearOriginOnExit) {
+ scoped_refptr<quota::MockSpecialStoragePolicy> storage_policy =
+ new quota::MockSpecialStoragePolicy;
+ storage_policy->AddSessionOnly(GURL("http://session.com/"));
+ storage_policy->AddSessionOnly(GURL("https://secure.com/"));
+ storage_policy->AddSessionOnly(GURL("http://protected.com/"));
+ storage_policy->AddProtected(GURL("http://protected.com/"));
+
+ scoped_refptr<ClearOnExitPolicy> policy =
+ new ClearOnExitPolicy(storage_policy.get());
+
+ EXPECT_TRUE(policy->ShouldClearOriginOnExit("session.com", false));
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("session.com", true));
+
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("secure.com", false));
+ EXPECT_TRUE(policy->ShouldClearOriginOnExit("secure.com", true));
+
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("protected.com", false));
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("protected.com", true));
+
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("other.com", false));
+ EXPECT_FALSE(policy->ShouldClearOriginOnExit("other.com", true));
+}