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

Unified Diff: content/browser/storage_partition_impl_unittest.cc

Issue 1844243002: [CookieStore] Upgrading host-based deleting to predicate-based deleting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments, and ios Created 4 years, 9 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
Index: content/browser/storage_partition_impl_unittest.cc
diff --git a/content/browser/storage_partition_impl_unittest.cc b/content/browser/storage_partition_impl_unittest.cc
index e4b790967b284bb02f743cdb696c7123c4fff752..dab5d997cfb991760393e558e55864960c923c20 100644
--- a/content/browser/storage_partition_impl_unittest.cc
+++ b/content/browser/storage_partition_impl_unittest.cc
@@ -23,12 +23,15 @@
#include "content/public/test/test_browser_thread.h"
#include "content/public/test/test_browser_thread_bundle.h"
#include "net/base/test_completion_callback.h"
+#include "net/cookies/canonical_cookie.h"
#include "net/cookies/cookie_store.h"
#include "net/url_request/url_request_context.h"
#include "net/url_request/url_request_context_getter.h"
#include "storage/browser/quota/quota_manager.h"
#include "testing/gtest/include/gtest/gtest.h"
+using net::CanonicalCookie;
+
namespace content {
namespace {
@@ -919,4 +922,34 @@ TEST_F(StoragePartitionImplTest, RemoveLocalStorageForLastWeek) {
EXPECT_TRUE(tester.DOMStorageExistsForOrigin(kOrigin3));
}
+TEST(StoragePartitionImplStaticTest, CreatePredicateForHostCookies) {
+ GURL url("http://www.example.com/");
+ GURL url2("https://www.example.com/");
+ GURL url3("https://www.google.com/");
+
+ net::CookieOptions options;
+ net::CookieStore::CookiePredicate predicate =
+ StoragePartitionImpl::CreatePredicateForHostCookies(url);
+
+ base::Time now = base::Time::Now();
+ std::vector<scoped_ptr<CanonicalCookie>> valid_cookies;
+ valid_cookies.push_back(CanonicalCookie::Create(url, "A=B", now, options));
+ valid_cookies.push_back(CanonicalCookie::Create(url, "C=F", now, options));
+ // We should match a different scheme with the same host.
+ valid_cookies.push_back(CanonicalCookie::Create(url2, "A=B", now, options));
+
+ std::vector<scoped_ptr<CanonicalCookie>> invalid_cookies;
+ // We don't match domain cookies.
+ invalid_cookies.push_back(
+ CanonicalCookie::Create(url2, "A=B;domain=.example.com", now, options));
+ invalid_cookies.push_back(CanonicalCookie::Create(url3, "A=B", now, options));
+
+ for (const auto& cookie : valid_cookies) {
+ EXPECT_TRUE(predicate.Run(*cookie)) << cookie->DebugString();
+ }
Mike West 2016/04/02 05:12:40 Tiny nit: No {} for single-line clauses.
dmurph 2016/04/04 18:28:32 Done.
+ for (const auto& cookie : invalid_cookies) {
+ EXPECT_FALSE(predicate.Run(*cookie)) << cookie->DebugString();
+ }
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698