| Index: chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc
|
| diff --git a/chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc b/chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc
|
| index d7a6431321d8375ed6ec4e2e40a103ef649e7947..1cb262241431e9cdb71341508bb6239e62af57be 100644
|
| --- a/chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc
|
| +++ b/chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc
|
| @@ -67,6 +67,7 @@ class MockExtensionSpecialStoragePolicy;
|
| using content::BrowserThread;
|
| using content::BrowserContext;
|
| using content::BrowsingDataFilterBuilder;
|
| +using content::BrowsingDataType;
|
| using content::StoragePartition;
|
| using testing::_;
|
| using testing::ByRef;
|
| @@ -308,6 +309,21 @@ base::Time AnHourAgo() {
|
| return base::Time::Now() - base::TimeDelta::FromHours(1);
|
| }
|
|
|
| +const std::set<const BrowsingDataType*> kQuotaMask = {
|
| + &content::kBrowsingDataTypeFileSystems,
|
| + &content::kBrowsingDataTypeWebSQL,
|
| + &content::kBrowsingDataTypeAppCache,
|
| + &content::kBrowsingDataTypeServiceWorkers,
|
| + &content::kBrowsingDataTypeCacheStorage,
|
| + &content::kBrowsingDataTypeIndexedDB};
|
| +
|
| +// A wrapper to typecast a const initializer to std::set in ambiguous
|
| +// situations, such as the EXPECT macros.
|
| +inline const std::set<const BrowsingDataType*> Mask(
|
| + const std::set<const BrowsingDataType*> mask) {
|
| + return mask;
|
| +}
|
| +
|
| } // namespace
|
|
|
| // Testers -------------------------------------------------------------------
|
| @@ -563,10 +579,11 @@ class BrowsingDataRemoverImplTest : public testing::Test {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| - void BlockUntilBrowsingDataRemoved(const base::Time& delete_begin,
|
| - const base::Time& delete_end,
|
| - int remove_mask,
|
| - bool include_protected_origins) {
|
| + void BlockUntilBrowsingDataRemoved(
|
| + const base::Time& delete_begin,
|
| + const base::Time& delete_end,
|
| + const std::set<const BrowsingDataType*> remove_mask,
|
| + bool include_protected_origins) {
|
| TestStoragePartition storage_partition;
|
| remover_->OverrideStoragePartitionForTesting(&storage_partition);
|
|
|
| @@ -588,7 +605,7 @@ class BrowsingDataRemoverImplTest : public testing::Test {
|
| void BlockUntilOriginDataRemoved(
|
| const base::Time& delete_begin,
|
| const base::Time& delete_end,
|
| - int remove_mask,
|
| + const std::set<const BrowsingDataType*> remove_mask,
|
| std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) {
|
| TestStoragePartition storage_partition;
|
| remover_->OverrideStoragePartitionForTesting(&storage_partition);
|
| @@ -615,7 +632,7 @@ class BrowsingDataRemoverImplTest : public testing::Test {
|
| return remover_->GetLastUsedBeginTime();
|
| }
|
|
|
| - int GetRemovalMask() {
|
| + const std::set<const content::BrowsingDataType*>& GetRemovalMask() {
|
| return remover_->GetLastUsedRemovalMask();
|
| }
|
|
|
| @@ -675,9 +692,10 @@ class BrowsingDataRemoverImplTest : public testing::Test {
|
|
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveCookieForever) {
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES, false);
|
| + Mask({&content::kBrowsingDataTypeCookies}),
|
| + false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeCookies}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify that storage partition was instructed to remove the cookies.
|
| @@ -691,9 +709,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveCookieForever) {
|
|
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveCookieLastHour) {
|
| BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES, false);
|
| + Mask({&content::kBrowsingDataTypeCookies}),
|
| + false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeCookies}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify that storage partition was instructed to remove the cookies.
|
| @@ -713,10 +732,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveCookiesDomainBlacklist) {
|
| filter->AddRegisterableDomain(kTestRegisterableDomain1);
|
| filter->AddRegisterableDomain(kTestRegisterableDomain3);
|
| BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| + {&content::kBrowsingDataTypeCookies},
|
| std::move(filter));
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeCookies}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify that storage partition was instructed to remove the cookies.
|
| @@ -762,7 +781,7 @@ TEST_F(BrowsingDataRemoverImplTest, ClearHttpAuthCache_RemoveCookies) {
|
| net::HttpAuth::AUTH_SCHEME_BASIC));
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES, false);
|
| + {&content::kBrowsingDataTypeCookies}, false);
|
|
|
| EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
|
| net::HttpAuth::AUTH_SCHEME_BASIC));
|
| @@ -776,9 +795,9 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDForever) {
|
| EXPECT_EQ(1, tester.ChannelIDCount());
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_CHANNEL_IDS, false);
|
| + {&content::kBrowsingDataTypeChannelIDs}, false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeChannelIDs}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
| EXPECT_EQ(1, tester.ssl_config_changed_count());
|
| EXPECT_EQ(0, tester.ChannelIDCount());
|
| @@ -795,9 +814,9 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDLastHour) {
|
| EXPECT_EQ(2, tester.ChannelIDCount());
|
|
|
| BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_CHANNEL_IDS, false);
|
| + {&content::kBrowsingDataTypeChannelIDs}, false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeChannelIDs}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
| EXPECT_EQ(1, tester.ssl_config_changed_count());
|
| ASSERT_EQ(1, tester.ChannelIDCount());
|
| @@ -819,7 +838,7 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDsForServerIdentifiers) {
|
| filter_builder->AddRegisterableDomain(kTestRegisterableDomain1);
|
|
|
| BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_CHANNEL_IDS,
|
| + {&content::kBrowsingDataTypeChannelIDs},
|
| std::move(filter_builder));
|
|
|
| EXPECT_EQ(1, tester.ChannelIDCount());
|
| @@ -836,10 +855,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveUnprotectedLocalStorageForever) {
|
| #endif
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_LOCAL_STORAGE,
|
| + {&content::kBrowsingDataTypeLocalStorage},
|
| false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeLocalStorage}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify that storage partition was instructed to remove the data correctly.
|
| @@ -866,10 +885,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveProtectedLocalStorageForever) {
|
| #endif
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_LOCAL_STORAGE,
|
| + {&content::kBrowsingDataTypeLocalStorage},
|
| true);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeLocalStorage}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB |
|
| BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask());
|
|
|
| @@ -896,9 +915,9 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveLocalStorageForLastWeek) {
|
|
|
| BlockUntilBrowsingDataRemoved(
|
| base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_LOCAL_STORAGE, false);
|
| + {&content::kBrowsingDataTypeLocalStorage}, false);
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
|
| + EXPECT_EQ(Mask({&content::kBrowsingDataTypeLocalStorage}), GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify that storage partition was instructed to remove the data correctly.
|
| @@ -924,8 +943,8 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveMultipleTypes) {
|
| EXPECT_CALL(*downloads_tester.download_manager(),
|
| RemoveDownloadsByURLAndTime(_, _, _));
|
|
|
| - int removal_mask = BrowsingDataRemover::REMOVE_DOWNLOADS |
|
| - BrowsingDataRemover::REMOVE_COOKIES;
|
| + std::set<const BrowsingDataType*> removal_mask = {
|
| + &content::kBrowsingDataTypeDownloads, &content::kBrowsingDataTypeCookies};
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| removal_mask, false);
|
| @@ -943,23 +962,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveMultipleTypes) {
|
| }
|
|
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverBoth) {
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -981,23 +987,10 @@ TEST_F(BrowsingDataRemoverImplTest,
|
| CreateMockPolicy();
|
| #endif
|
|
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1026,23 +1019,10 @@ TEST_F(BrowsingDataRemoverImplTest,
|
| CreateMockPolicy();
|
| #endif
|
|
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1070,23 +1050,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverNeither) {
|
| CreateMockPolicy();
|
| #endif
|
|
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1115,22 +1082,10 @@ TEST_F(BrowsingDataRemoverImplTest,
|
| BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST));
|
| builder->AddRegisterableDomain(kTestRegisterableDomain1);
|
| // Remove Origin 1.
|
| - BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| + BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| std::move(builder));
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - GetRemovalMask());
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1152,23 +1107,10 @@ TEST_F(BrowsingDataRemoverImplTest,
|
| }
|
|
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastHour) {
|
| - BlockUntilBrowsingDataRemoved(
|
| - AnHourAgo(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1194,21 +1136,9 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastHour) {
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastWeek) {
|
| BlockUntilBrowsingDataRemoved(
|
| base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + kQuotaMask, false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1238,23 +1168,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedUnprotectedOrigins) {
|
| policy->AddProtected(kOrigin1.GetOrigin());
|
| #endif
|
|
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_WEBSQL |
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1289,22 +1206,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedSpecificOrigin) {
|
| builder->AddRegisterableDomain(kTestRegisterableDomain1);
|
|
|
| // Try to remove kOrigin1. Expect failure.
|
| - BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| + BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| std::move(builder));
|
|
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - GetRemovalMask());
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1337,23 +1242,10 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedOrigins) {
|
| #endif
|
|
|
| // Try to remove kOrigin1. Expect success.
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - true);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + true);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::PROTECTED_WEB |
|
| BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| @@ -1383,23 +1275,10 @@ TEST_F(BrowsingDataRemoverImplTest,
|
| CreateMockPolicy();
|
| #endif
|
|
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - false);
|
| -
|
| - EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE |
|
| - BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
|
| - BrowsingDataRemover::REMOVE_CACHE_STORAGE |
|
| - BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
|
| - BrowsingDataRemover::REMOVE_INDEXEDDB |
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| - GetRemovalMask());
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), kQuotaMask,
|
| + false);
|
| +
|
| + EXPECT_EQ(kQuotaMask, GetRemovalMask());
|
| EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
|
|
|
| // Verify storage partition related stuffs.
|
| @@ -1448,10 +1327,9 @@ TEST_F(BrowsingDataRemoverImplTest, CompletionInhibition) {
|
| BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>(
|
| BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
|
| InspectableCompletionObserver completion_observer(remover);
|
| - remover->RemoveAndReply(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataHelper::UNPROTECTED_WEB,
|
| - &completion_observer);
|
| + remover->RemoveAndReply(
|
| + base::Time(), base::Time::Max(), {&content::kBrowsingDataTypeCookies},
|
| + BrowsingDataHelper::UNPROTECTED_WEB, &completion_observer);
|
|
|
| // Process messages until the inhibitor is notified, and then some, to make
|
| // sure we do not complete asynchronously before ContinueToCompletion() is
|
| @@ -1478,10 +1356,9 @@ TEST_F(BrowsingDataRemoverImplTest, EarlyShutdown) {
|
| BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
|
| InspectableCompletionObserver completion_observer(remover);
|
| BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
|
| - remover->RemoveAndReply(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataHelper::UNPROTECTED_WEB,
|
| - &completion_observer);
|
| + remover->RemoveAndReply(
|
| + base::Time(), base::Time::Max(), {&content::kBrowsingDataTypeCookies},
|
| + BrowsingDataHelper::UNPROTECTED_WEB, &completion_observer);
|
|
|
| completion_inhibitor.BlockUntilNearCompletion();
|
|
|
| @@ -1510,7 +1387,7 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByTimeOnly) {
|
| RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _));
|
|
|
| BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_DOWNLOADS, false);
|
| + {&content::kBrowsingDataTypeDownloads}, false);
|
| }
|
|
|
| TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByOrigin) {
|
| @@ -1525,7 +1402,7 @@ TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByOrigin) {
|
| RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _));
|
|
|
| BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_DOWNLOADS,
|
| + {&content::kBrowsingDataTypeDownloads},
|
| std::move(builder));
|
| }
|
|
|
| @@ -1599,36 +1476,31 @@ TEST_F(BrowsingDataRemoverImplTest, MultipleTasks) {
|
| // Test several tasks with various configuration of masks, filters, and target
|
| // observers.
|
| std::list<BrowsingDataRemoverImpl::RemovalTask> tasks;
|
| - tasks.emplace_back(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataHelper::UNPROTECTED_WEB,
|
| - BrowsingDataFilterBuilder::Create(
|
| - BrowsingDataFilterBuilder::BLACKLIST),
|
| - observer.target_a());
|
| - tasks.emplace_back(base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataHelper::PROTECTED_WEB,
|
| - BrowsingDataFilterBuilder::Create(
|
| - BrowsingDataFilterBuilder::BLACKLIST),
|
| - nullptr);
|
| tasks.emplace_back(
|
| - base::Time::Now(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL,
|
| - BrowsingDataFilterBuilder::Create(
|
| - BrowsingDataFilterBuilder::BLACKLIST),
|
| - observer.target_b());
|
| - tasks.emplace_back(
|
| - base::Time(), base::Time::UnixEpoch(),
|
| - BrowsingDataRemover::REMOVE_WEBSQL,
|
| + base::Time(), base::Time::Max(),
|
| + Mask({&content::kBrowsingDataTypeCookies}),
|
| BrowsingDataHelper::UNPROTECTED_WEB,
|
| - std::move(filter_builder_1),
|
| - observer.target_b());
|
| + BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST),
|
| + observer.target_a());
|
| tasks.emplace_back(
|
| - base::Time::UnixEpoch(), base::Time::Now(),
|
| - BrowsingDataRemover::REMOVE_CHANNEL_IDS,
|
| - BrowsingDataHelper::ALL,
|
| - std::move(filter_builder_2),
|
| + base::Time(), base::Time::Max(),
|
| + Mask({&content::kBrowsingDataTypeCookies}),
|
| + BrowsingDataHelper::PROTECTED_WEB,
|
| + BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST),
|
| nullptr);
|
| + tasks.emplace_back(
|
| + base::Time::Now(), base::Time::Max(),
|
| + Mask({&content::kBrowsingDataTypeDownloads}), BrowsingDataHelper::ALL,
|
| + BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST),
|
| + observer.target_b());
|
| + tasks.emplace_back(base::Time(), base::Time::UnixEpoch(),
|
| + Mask({&content::kBrowsingDataTypeWebSQL}),
|
| + BrowsingDataHelper::UNPROTECTED_WEB,
|
| + std::move(filter_builder_1), observer.target_b());
|
| + tasks.emplace_back(base::Time::UnixEpoch(), base::Time::Now(),
|
| + Mask({&content::kBrowsingDataTypeChannelIDs}),
|
| + BrowsingDataHelper::ALL, std::move(filter_builder_2),
|
| + nullptr);
|
|
|
| for (BrowsingDataRemoverImpl::RemovalTask& task : tasks) {
|
| // All tasks can be directly translated to a RemoveInternal() call. Since
|
| @@ -1687,25 +1559,27 @@ TEST_F(BrowsingDataRemoverImplTest, MultipleTasksInQuickSuccession) {
|
| BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
|
| EXPECT_FALSE(remover->is_removing());
|
|
|
| - int test_removal_masks[] = {
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataRemover::REMOVE_PASSWORDS,
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY,
|
| - BrowsingDataRemover::REMOVE_COOKIES |
|
| - BrowsingDataRemover::REMOVE_HISTORY |
|
| - BrowsingDataRemover::REMOVE_PASSWORDS,
|
| - BrowsingDataRemover::REMOVE_PASSWORDS,
|
| - BrowsingDataRemover::REMOVE_PASSWORDS,
|
| + std::set<const BrowsingDataType*> test_removal_masks[] = {
|
| + {&content::kBrowsingDataTypeCookies},
|
| + {&content::kBrowsingDataTypeChannelIDs},
|
| + {&content::kBrowsingDataTypeCookies},
|
| + {&content::kBrowsingDataTypeCookies},
|
| + {&content::kBrowsingDataTypeCookies},
|
| + {&content::kBrowsingDataTypeDownloads},
|
| + {&content::kBrowsingDataTypeDownloads},
|
| + {&content::kBrowsingDataTypeDownloads},
|
| + {&content::kBrowsingDataTypeCookies,
|
| + &content::kBrowsingDataTypeDownloads},
|
| + {&content::kBrowsingDataTypeCookies,
|
| + &content::kBrowsingDataTypeDownloads},
|
| + {&content::kBrowsingDataTypeCookies, &content::kBrowsingDataTypeDownloads,
|
| + &content::kBrowsingDataTypeChannelIDs},
|
| + {&content::kBrowsingDataTypeChannelIDs},
|
| + {&content::kBrowsingDataTypeChannelIDs},
|
| };
|
|
|
| - for (int removal_mask : test_removal_masks) {
|
| + for (const std::set<const BrowsingDataType*>& removal_mask :
|
| + test_removal_masks) {
|
| remover->Remove(base::Time(), base::Time::Max(), removal_mask,
|
| BrowsingDataHelper::UNPROTECTED_WEB);
|
| }
|
| @@ -1713,10 +1587,9 @@ TEST_F(BrowsingDataRemoverImplTest, MultipleTasksInQuickSuccession) {
|
| EXPECT_TRUE(remover->is_removing());
|
|
|
| // Add one more deletion and wait for it.
|
| - BlockUntilBrowsingDataRemoved(
|
| - base::Time(), base::Time::Max(),
|
| - BrowsingDataRemover::REMOVE_COOKIES,
|
| - BrowsingDataHelper::UNPROTECTED_WEB);
|
| + BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
|
| + {&content::kBrowsingDataTypeCookies},
|
| + BrowsingDataHelper::UNPROTECTED_WEB);
|
|
|
| EXPECT_FALSE(remover->is_removing());
|
| }
|
|
|