| 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 22f0185fee2e586b6d9ee7dea5cf15c8f7710135..b386109b747238275a83a8da73ed5203fba457d2 100644
|
| --- a/content/browser/storage_partition_impl_unittest.cc
|
| +++ b/content/browser/storage_partition_impl_unittest.cc
|
| @@ -69,6 +69,14 @@ const uint32_t kAllQuotaRemoveMask =
|
| StoragePartition::REMOVE_DATA_MASK_INDEXEDDB |
|
| StoragePartition::REMOVE_DATA_MASK_WEBSQL;
|
|
|
| +bool AlwaysTrueCookiePredicate(const net::CanonicalCookie& cookie) {
|
| + return true;
|
| +}
|
| +
|
| +bool AlwaysFalseCookiePredicate(const net::CanonicalCookie& cookie) {
|
| + return false;
|
| +}
|
| +
|
| class AwaitCompletionHelper {
|
| public:
|
| AwaitCompletionHelper() : start_(false), already_quit_(false) {}
|
| @@ -301,6 +309,19 @@ void ClearCookies(content::StoragePartition* partition,
|
| delete_begin, delete_end, run_loop->QuitClosure());
|
| }
|
|
|
| +void ClearCookiesWithMatcher(
|
| + content::StoragePartition* partition,
|
| + const base::Time delete_begin,
|
| + const base::Time delete_end,
|
| + const StoragePartition::CookieMatcherFunction& cookie_matcher,
|
| + base::RunLoop* run_loop) {
|
| + partition->ClearData(StoragePartition::REMOVE_DATA_MASK_COOKIES,
|
| + StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL,
|
| + StoragePartition::OriginMatcherFunction(),
|
| + cookie_matcher, delete_begin, delete_end,
|
| + run_loop->QuitClosure());
|
| +}
|
| +
|
| void ClearStuff(uint32_t remove_mask,
|
| content::StoragePartition* partition,
|
| const base::Time delete_begin,
|
| @@ -829,6 +850,38 @@ TEST_F(StoragePartitionImplTest, RemoveCookieLastHour) {
|
| EXPECT_FALSE(tester.ContainsCookie());
|
| }
|
|
|
| +TEST_F(StoragePartitionImplTest, RemoveCookieWithMatcher) {
|
| + RemoveCookieTester tester(browser_context());
|
| + StoragePartition::CookieMatcherFunction true_predicate =
|
| + base::Bind(&AlwaysTrueCookiePredicate);
|
| +
|
| + StoragePartition::CookieMatcherFunction false_predicate =
|
| + base::Bind(&AlwaysFalseCookiePredicate);
|
| +
|
| + tester.AddCookie();
|
| + ASSERT_TRUE(tester.ContainsCookie());
|
| +
|
| + StoragePartitionImpl* partition = static_cast<StoragePartitionImpl*>(
|
| + BrowserContext::GetDefaultStoragePartition(browser_context()));
|
| + partition->SetURLRequestContext(browser_context()->GetRequestContext());
|
| +
|
| + // Return false from our predicate, and make sure the cookies is still around.
|
| + base::RunLoop run_loop;
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&ClearCookiesWithMatcher, partition, base::Time(),
|
| + base::Time::Max(), false_predicate, &run_loop));
|
| + run_loop.RunUntilIdle();
|
| + EXPECT_TRUE(tester.ContainsCookie());
|
| +
|
| + // Now we return true from our predicate.
|
| + base::RunLoop run_loop2;
|
| + base::ThreadTaskRunnerHandle::Get()->PostTask(
|
| + FROM_HERE, base::Bind(&ClearCookiesWithMatcher, partition, base::Time(),
|
| + base::Time::Max(), true_predicate, &run_loop2));
|
| + run_loop2.RunUntilIdle();
|
| + EXPECT_FALSE(tester.ContainsCookie());
|
| +}
|
| +
|
| TEST_F(StoragePartitionImplTest, RemoveUnprotectedLocalStorageForever) {
|
| // Protect kOrigin1.
|
| scoped_refptr<MockSpecialStoragePolicy> mock_policy =
|
|
|