OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
(...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
389 const base::Callback<bool(const GURL&)>& filter) { | 389 const base::Callback<bool(const GURL&)>& filter) { |
390 return MakeMatcher(new ProbablySameFilterMatcher(filter)); | 390 return MakeMatcher(new ProbablySameFilterMatcher(filter)); |
391 } | 391 } |
392 | 392 |
393 bool ProbablySameFilters( | 393 bool ProbablySameFilters( |
394 const base::Callback<bool(const GURL&)>& filter1, | 394 const base::Callback<bool(const GURL&)>& filter1, |
395 const base::Callback<bool(const GURL&)>& filter2) { | 395 const base::Callback<bool(const GURL&)>& filter2) { |
396 return ProbablySameFilter(filter1).MatchAndExplain(filter2, nullptr); | 396 return ProbablySameFilter(filter1).MatchAndExplain(filter2, nullptr); |
397 } | 397 } |
398 | 398 |
399 base::Time HourAgo() { | |
Bernhard Bauer
2016/12/16 17:03:05
Small nit: AnHourAgo()?
msramek
2017/01/03 12:06:53
Done.
| |
400 return base::Time::Now() - base::TimeDelta::FromHours(1); | |
401 } | |
402 | |
399 } // namespace | 403 } // namespace |
400 | 404 |
401 // Testers ------------------------------------------------------------------- | 405 // Testers ------------------------------------------------------------------- |
402 | 406 |
403 class RemoveCookieTester { | 407 class RemoveCookieTester { |
404 public: | 408 public: |
405 RemoveCookieTester() {} | 409 RemoveCookieTester() {} |
406 | 410 |
407 // Returns true, if the given cookie exists in the cookie store. | 411 // Returns true, if the given cookie exists in the cookie store. |
408 bool ContainsCookie() { | 412 bool ContainsCookie() { |
(...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1147 // posts a message to the WEBKIT thread to delete some of its member | 1151 // posts a message to the WEBKIT thread to delete some of its member |
1148 // variables. We need to ensure that the profile is destroyed, and that | 1152 // variables. We need to ensure that the profile is destroyed, and that |
1149 // the message loop is cleared out, before destroying the threads and loop. | 1153 // the message loop is cleared out, before destroying the threads and loop. |
1150 // Otherwise we leak memory. | 1154 // Otherwise we leak memory. |
1151 profile_.reset(); | 1155 profile_.reset(); |
1152 base::RunLoop().RunUntilIdle(); | 1156 base::RunLoop().RunUntilIdle(); |
1153 | 1157 |
1154 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); | 1158 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); |
1155 } | 1159 } |
1156 | 1160 |
1157 void BlockUntilBrowsingDataRemoved(browsing_data::TimePeriod period, | 1161 void BlockUntilBrowsingDataRemoved(const base::Time& delete_begin, |
1162 const base::Time& delete_end, | |
1158 int remove_mask, | 1163 int remove_mask, |
1159 bool include_protected_origins) { | 1164 bool include_protected_origins) { |
1160 BrowsingDataRemover* remover = | 1165 BrowsingDataRemover* remover = |
1161 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1166 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
1162 | 1167 |
1163 TestStoragePartition storage_partition; | 1168 TestStoragePartition storage_partition; |
1164 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1169 remover->OverrideStoragePartitionForTesting(&storage_partition); |
1165 | 1170 |
1166 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB; | 1171 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB; |
1167 if (include_protected_origins) | 1172 if (include_protected_origins) |
1168 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB; | 1173 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB; |
1169 | 1174 |
1170 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1175 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
1171 remover->RemoveAndReply(BrowsingDataRemover::Period(period), remove_mask, | 1176 remover->RemoveAndReply( |
1172 origin_type_mask, &completion_observer); | 1177 delete_begin, delete_end, remove_mask, origin_type_mask, |
1178 &completion_observer); | |
1173 completion_observer.BlockUntilCompletion(); | 1179 completion_observer.BlockUntilCompletion(); |
1174 | 1180 |
1175 // Save so we can verify later. | 1181 // Save so we can verify later. |
1176 storage_partition_removal_data_ = | 1182 storage_partition_removal_data_ = |
1177 storage_partition.GetStoragePartitionRemovalData(); | 1183 storage_partition.GetStoragePartitionRemovalData(); |
1178 } | 1184 } |
1179 | 1185 |
1180 void BlockUntilOriginDataRemoved( | 1186 void BlockUntilOriginDataRemoved( |
1181 browsing_data::TimePeriod period, | 1187 const base::Time& delete_begin, |
1188 const base::Time& delete_end, | |
1182 int remove_mask, | 1189 int remove_mask, |
1183 const BrowsingDataFilterBuilder& filter_builder) { | 1190 const BrowsingDataFilterBuilder& filter_builder) { |
1184 BrowsingDataRemover* remover = | 1191 BrowsingDataRemover* remover = |
1185 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1192 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
1186 TestStoragePartition storage_partition; | 1193 TestStoragePartition storage_partition; |
1187 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1194 remover->OverrideStoragePartitionForTesting(&storage_partition); |
1188 | 1195 |
1189 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 1196 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
1190 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1197 remover->RemoveImpl(delete_begin, delete_end, remove_mask, filter_builder, |
1191 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); | 1198 BrowsingDataHelper::UNPROTECTED_WEB); |
1192 completion_inhibitor.BlockUntilNearCompletion(); | 1199 completion_inhibitor.BlockUntilNearCompletion(); |
1193 completion_inhibitor.ContinueToCompletion(); | 1200 completion_inhibitor.ContinueToCompletion(); |
1194 | 1201 |
1195 // Save so we can verify later. | 1202 // Save so we can verify later. |
1196 storage_partition_removal_data_ = | 1203 storage_partition_removal_data_ = |
1197 storage_partition.GetStoragePartitionRemovalData(); | 1204 storage_partition.GetStoragePartitionRemovalData(); |
1198 } | 1205 } |
1199 | 1206 |
1200 TestingProfile* GetProfile() { | 1207 TestingProfile* GetProfile() { |
1201 return profile_.get(); | 1208 return profile_.get(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1266 | 1273 |
1267 // Needed to mock out DomainReliabilityService, even for unrelated tests. | 1274 // Needed to mock out DomainReliabilityService, even for unrelated tests. |
1268 ClearDomainReliabilityTester clear_domain_reliability_tester_; | 1275 ClearDomainReliabilityTester clear_domain_reliability_tester_; |
1269 | 1276 |
1270 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); | 1277 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); |
1271 }; | 1278 }; |
1272 | 1279 |
1273 // Tests --------------------------------------------------------------------- | 1280 // Tests --------------------------------------------------------------------- |
1274 | 1281 |
1275 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { | 1282 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { |
1276 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1283 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1277 BrowsingDataRemover::REMOVE_COOKIES, false); | 1284 BrowsingDataRemover::REMOVE_COOKIES, false); |
1278 | 1285 |
1279 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1286 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1280 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1287 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1281 | 1288 |
1282 // Verify that storage partition was instructed to remove the cookies. | 1289 // Verify that storage partition was instructed to remove the cookies. |
1283 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1290 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1284 EXPECT_EQ(removal_data.remove_mask, | 1291 EXPECT_EQ(removal_data.remove_mask, |
1285 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1292 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1286 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1293 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1287 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1294 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1288 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1295 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1289 } | 1296 } |
1290 | 1297 |
1291 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1298 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
1292 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1299 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1293 BrowsingDataRemover::REMOVE_COOKIES, false); | 1300 BrowsingDataRemover::REMOVE_COOKIES, false); |
1294 | 1301 |
1295 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1302 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1296 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1303 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1297 | 1304 |
1298 // Verify that storage partition was instructed to remove the cookies. | 1305 // Verify that storage partition was instructed to remove the cookies. |
1299 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1306 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1300 EXPECT_EQ(removal_data.remove_mask, | 1307 EXPECT_EQ(removal_data.remove_mask, |
1301 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1308 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1302 // Removing with time period other than ALL_TIME should not clear | 1309 // Removing with time period other than all time should not clear |
1303 // persistent storage data. | 1310 // persistent storage data. |
1304 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1311 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1305 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1312 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1306 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1313 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1307 } | 1314 } |
1308 | 1315 |
1309 TEST_F(BrowsingDataRemoverTest, RemoveCookiesDomainBlacklist) { | 1316 TEST_F(BrowsingDataRemoverTest, RemoveCookiesDomainBlacklist) { |
1310 RegistrableDomainFilterBuilder filter( | 1317 RegistrableDomainFilterBuilder filter( |
1311 RegistrableDomainFilterBuilder::BLACKLIST); | 1318 RegistrableDomainFilterBuilder::BLACKLIST); |
1312 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 1319 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
1313 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 1320 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
1314 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 1321 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
1315 BrowsingDataRemover::REMOVE_COOKIES, filter); | 1322 BrowsingDataRemover::REMOVE_COOKIES, filter); |
1316 | 1323 |
1317 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1324 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1318 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1325 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1319 | 1326 |
1320 // Verify that storage partition was instructed to remove the cookies. | 1327 // Verify that storage partition was instructed to remove the cookies. |
1321 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1328 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1322 EXPECT_EQ(removal_data.remove_mask, | 1329 EXPECT_EQ(removal_data.remove_mask, |
1323 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1330 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1324 // Removing with time period other than ALL_TIME should not clear | 1331 // Removing with time period other than all time should not clear |
1325 // persistent storage data. | 1332 // persistent storage data. |
1326 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1333 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1327 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1334 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1328 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1335 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1329 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1336 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1330 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1337 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1331 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1338 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1332 // Even though it's a different origin, it's the same domain. | 1339 // Even though it's a different origin, it's the same domain. |
1333 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); | 1340 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
1334 | 1341 |
1335 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); | 1342 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); |
1336 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); | 1343 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); |
1337 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); | 1344 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); |
1338 // This is false, because this is the same domain as 3, just with a different | 1345 // This is false, because this is the same domain as 3, just with a different |
1339 // scheme. | 1346 // scheme. |
1340 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); | 1347 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); |
1341 } | 1348 } |
1342 | 1349 |
1343 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1350 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
1344 RemoveSafeBrowsingCookieTester tester; | 1351 RemoveSafeBrowsingCookieTester tester; |
1345 | 1352 |
1346 tester.AddCookie(); | 1353 tester.AddCookie(); |
1347 ASSERT_TRUE(tester.ContainsCookie()); | 1354 ASSERT_TRUE(tester.ContainsCookie()); |
1348 | 1355 |
1349 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1356 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1350 BrowsingDataRemover::REMOVE_COOKIES, false); | 1357 BrowsingDataRemover::REMOVE_COOKIES, false); |
1351 | 1358 |
1352 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1359 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1353 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1360 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1354 EXPECT_FALSE(tester.ContainsCookie()); | 1361 EXPECT_FALSE(tester.ContainsCookie()); |
1355 } | 1362 } |
1356 | 1363 |
1357 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) { | 1364 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) { |
1358 RemoveSafeBrowsingCookieTester tester; | 1365 RemoveSafeBrowsingCookieTester tester; |
1359 | 1366 |
1360 tester.AddCookie(); | 1367 tester.AddCookie(); |
1361 ASSERT_TRUE(tester.ContainsCookie()); | 1368 ASSERT_TRUE(tester.ContainsCookie()); |
1362 | 1369 |
1363 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1370 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1364 BrowsingDataRemover::REMOVE_COOKIES, false); | 1371 BrowsingDataRemover::REMOVE_COOKIES, false); |
1365 | 1372 |
1366 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1373 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1367 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1374 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1368 // Removing with time period other than ALL_TIME should not clear safe | 1375 // Removing with time period other than all time should not clear safe |
1369 // browsing cookies. | 1376 // browsing cookies. |
1370 EXPECT_TRUE(tester.ContainsCookie()); | 1377 EXPECT_TRUE(tester.ContainsCookie()); |
1371 } | 1378 } |
1372 | 1379 |
1373 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { | 1380 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { |
1374 RemoveSafeBrowsingCookieTester tester; | 1381 RemoveSafeBrowsingCookieTester tester; |
1375 | 1382 |
1376 tester.AddCookie(); | 1383 tester.AddCookie(); |
1377 ASSERT_TRUE(tester.ContainsCookie()); | 1384 ASSERT_TRUE(tester.ContainsCookie()); |
1378 RegistrableDomainFilterBuilder filter( | 1385 RegistrableDomainFilterBuilder filter( |
1379 RegistrableDomainFilterBuilder::BLACKLIST); | 1386 RegistrableDomainFilterBuilder::BLACKLIST); |
1380 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 1387 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
1381 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1388 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1382 BrowsingDataRemover::REMOVE_COOKIES, filter); | 1389 BrowsingDataRemover::REMOVE_COOKIES, filter); |
1383 | 1390 |
1384 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1391 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1385 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1392 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1386 EXPECT_TRUE(tester.ContainsCookie()); | 1393 EXPECT_TRUE(tester.ContainsCookie()); |
1387 | 1394 |
1388 RegistrableDomainFilterBuilder filter2( | 1395 RegistrableDomainFilterBuilder filter2( |
1389 RegistrableDomainFilterBuilder::WHITELIST); | 1396 RegistrableDomainFilterBuilder::WHITELIST); |
1390 filter2.AddRegisterableDomain(kTestRegisterableDomain1); | 1397 filter2.AddRegisterableDomain(kTestRegisterableDomain1); |
1391 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1398 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1392 BrowsingDataRemover::REMOVE_COOKIES, filter2); | 1399 BrowsingDataRemover::REMOVE_COOKIES, filter2); |
1393 EXPECT_FALSE(tester.ContainsCookie()); | 1400 EXPECT_FALSE(tester.ContainsCookie()); |
1394 } | 1401 } |
1395 | 1402 |
1396 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { | 1403 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { |
1397 RemoveChannelIDTester tester(GetProfile()); | 1404 RemoveChannelIDTester tester(GetProfile()); |
1398 | 1405 |
1399 tester.AddChannelID(kTestOrigin1); | 1406 tester.AddChannelID(kTestOrigin1); |
1400 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1407 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
1401 EXPECT_EQ(1, tester.ChannelIDCount()); | 1408 EXPECT_EQ(1, tester.ChannelIDCount()); |
1402 | 1409 |
1403 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1410 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1404 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1411 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
1405 | 1412 |
1406 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); | 1413 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); |
1407 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1414 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1408 EXPECT_EQ(1, tester.ssl_config_changed_count()); | 1415 EXPECT_EQ(1, tester.ssl_config_changed_count()); |
1409 EXPECT_EQ(0, tester.ChannelIDCount()); | 1416 EXPECT_EQ(0, tester.ChannelIDCount()); |
1410 } | 1417 } |
1411 | 1418 |
1412 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) { | 1419 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) { |
1413 RemoveChannelIDTester tester(GetProfile()); | 1420 RemoveChannelIDTester tester(GetProfile()); |
1414 | 1421 |
1415 base::Time now = base::Time::Now(); | 1422 base::Time now = base::Time::Now(); |
1416 tester.AddChannelID(kTestOrigin1); | 1423 tester.AddChannelID(kTestOrigin1); |
1417 tester.AddChannelIDWithTimes(kTestOrigin2, | 1424 tester.AddChannelIDWithTimes(kTestOrigin2, |
1418 now - base::TimeDelta::FromHours(2)); | 1425 now - base::TimeDelta::FromHours(2)); |
1419 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1426 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
1420 EXPECT_EQ(2, tester.ChannelIDCount()); | 1427 EXPECT_EQ(2, tester.ChannelIDCount()); |
1421 | 1428 |
1422 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1429 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1423 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1430 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
1424 | 1431 |
1425 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); | 1432 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); |
1426 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1433 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1427 EXPECT_EQ(1, tester.ssl_config_changed_count()); | 1434 EXPECT_EQ(1, tester.ssl_config_changed_count()); |
1428 ASSERT_EQ(1, tester.ChannelIDCount()); | 1435 ASSERT_EQ(1, tester.ChannelIDCount()); |
1429 net::ChannelIDStore::ChannelIDList channel_ids; | 1436 net::ChannelIDStore::ChannelIDList channel_ids; |
1430 tester.GetChannelIDList(&channel_ids); | 1437 tester.GetChannelIDList(&channel_ids); |
1431 ASSERT_EQ(1U, channel_ids.size()); | 1438 ASSERT_EQ(1U, channel_ids.size()); |
1432 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier()); | 1439 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier()); |
1433 } | 1440 } |
1434 | 1441 |
1435 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDsForServerIdentifiers) { | 1442 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDsForServerIdentifiers) { |
1436 RemoveChannelIDTester tester(GetProfile()); | 1443 RemoveChannelIDTester tester(GetProfile()); |
1437 | 1444 |
1438 tester.AddChannelID(kTestRegisterableDomain1); | 1445 tester.AddChannelID(kTestRegisterableDomain1); |
1439 tester.AddChannelID(kTestRegisterableDomain3); | 1446 tester.AddChannelID(kTestRegisterableDomain3); |
1440 EXPECT_EQ(2, tester.ChannelIDCount()); | 1447 EXPECT_EQ(2, tester.ChannelIDCount()); |
1441 | 1448 |
1442 RegistrableDomainFilterBuilder filter_builder( | 1449 RegistrableDomainFilterBuilder filter_builder( |
1443 RegistrableDomainFilterBuilder::WHITELIST); | 1450 RegistrableDomainFilterBuilder::WHITELIST); |
1444 filter_builder.AddRegisterableDomain(kTestRegisterableDomain1); | 1451 filter_builder.AddRegisterableDomain(kTestRegisterableDomain1); |
1445 | 1452 |
1446 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1453 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1447 BrowsingDataRemover::REMOVE_CHANNEL_IDS, | 1454 BrowsingDataRemover::REMOVE_CHANNEL_IDS, |
1448 filter_builder); | 1455 filter_builder); |
1449 | 1456 |
1450 EXPECT_EQ(1, tester.ChannelIDCount()); | 1457 EXPECT_EQ(1, tester.ChannelIDCount()); |
1451 net::ChannelIDStore::ChannelIDList channel_ids; | 1458 net::ChannelIDStore::ChannelIDList channel_ids; |
1452 tester.GetChannelIDList(&channel_ids); | 1459 tester.GetChannelIDList(&channel_ids); |
1453 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); | 1460 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); |
1454 } | 1461 } |
1455 | 1462 |
1456 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { | 1463 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { |
1457 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1464 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1458 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1465 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1459 // Protect kOrigin1. | 1466 // Protect kOrigin1. |
1460 policy->AddProtected(kOrigin1.GetOrigin()); | 1467 policy->AddProtected(kOrigin1.GetOrigin()); |
1461 #endif | 1468 #endif |
1462 | 1469 |
1463 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1470 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1464 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1471 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
1465 false); | 1472 false); |
1466 | 1473 |
1467 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1474 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1468 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1475 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1469 | 1476 |
1470 // Verify that storage partition was instructed to remove the data correctly. | 1477 // Verify that storage partition was instructed to remove the data correctly. |
1471 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1478 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1472 EXPECT_EQ(removal_data.remove_mask, | 1479 EXPECT_EQ(removal_data.remove_mask, |
1473 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1480 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1474 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1481 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1475 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1482 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1476 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1483 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1477 | 1484 |
1478 // Check origin matcher. | 1485 // Check origin matcher. |
1479 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1486 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
1480 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1487 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1481 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1488 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1482 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1489 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1483 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1490 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1484 } | 1491 } |
1485 | 1492 |
1486 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) { | 1493 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) { |
1487 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1494 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1488 // Protect kOrigin1. | 1495 // Protect kOrigin1. |
1489 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1496 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1490 policy->AddProtected(kOrigin1.GetOrigin()); | 1497 policy->AddProtected(kOrigin1.GetOrigin()); |
1491 #endif | 1498 #endif |
1492 | 1499 |
1493 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1500 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1494 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1501 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
1495 true); | 1502 true); |
1496 | 1503 |
1497 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1504 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1498 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1505 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
1499 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1506 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
1500 | 1507 |
1501 // Verify that storage partition was instructed to remove the data correctly. | 1508 // Verify that storage partition was instructed to remove the data correctly. |
1502 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1509 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1503 EXPECT_EQ(removal_data.remove_mask, | 1510 EXPECT_EQ(removal_data.remove_mask, |
1504 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1511 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1505 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1512 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1506 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1513 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1507 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1514 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1508 | 1515 |
1509 // Check origin matcher all http origin will match since we specified | 1516 // Check origin matcher all http origin will match since we specified |
1510 // both protected and unprotected. | 1517 // both protected and unprotected. |
1511 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1518 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1512 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1519 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1513 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1520 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1514 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1521 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1515 } | 1522 } |
1516 | 1523 |
1517 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1524 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
1518 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1525 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1519 CreateMockPolicy(); | 1526 CreateMockPolicy(); |
1520 #endif | 1527 #endif |
1521 | 1528 |
1522 BlockUntilBrowsingDataRemoved(browsing_data::LAST_WEEK, | 1529 BlockUntilBrowsingDataRemoved( |
1523 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1530 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), |
1524 false); | 1531 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, false); |
1525 | 1532 |
1526 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1533 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1527 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1534 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1528 | 1535 |
1529 // Verify that storage partition was instructed to remove the data correctly. | 1536 // Verify that storage partition was instructed to remove the data correctly. |
1530 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1537 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1531 EXPECT_EQ(removal_data.remove_mask, | 1538 EXPECT_EQ(removal_data.remove_mask, |
1532 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1539 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1533 // Persistent storage won't be deleted. | 1540 // Persistent storage won't be deleted. |
1534 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1541 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1535 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1542 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1536 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1543 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1537 | 1544 |
1538 // Check origin matcher. | 1545 // Check origin matcher. |
1539 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1546 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1540 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1547 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1541 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1548 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1542 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1549 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1543 } | 1550 } |
1544 | 1551 |
1545 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1552 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
1546 RemoveHistoryTester tester; | 1553 RemoveHistoryTester tester; |
1547 ASSERT_TRUE(tester.Init(GetProfile())); | 1554 ASSERT_TRUE(tester.Init(GetProfile())); |
1548 | 1555 |
1549 tester.AddHistory(kOrigin1, base::Time::Now()); | 1556 tester.AddHistory(kOrigin1, base::Time::Now()); |
1550 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1557 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1551 | 1558 |
1552 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1559 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1553 BrowsingDataRemover::REMOVE_HISTORY, false); | 1560 BrowsingDataRemover::REMOVE_HISTORY, false); |
1554 | 1561 |
1555 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1562 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1556 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1563 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1557 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 1564 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
1558 } | 1565 } |
1559 | 1566 |
1560 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { | 1567 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { |
1561 RemoveHistoryTester tester; | 1568 RemoveHistoryTester tester; |
1562 ASSERT_TRUE(tester.Init(GetProfile())); | 1569 ASSERT_TRUE(tester.Init(GetProfile())); |
1563 | 1570 |
1564 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 1571 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
1565 | 1572 |
1566 tester.AddHistory(kOrigin1, base::Time::Now()); | 1573 tester.AddHistory(kOrigin1, base::Time::Now()); |
1567 tester.AddHistory(kOrigin2, two_hours_ago); | 1574 tester.AddHistory(kOrigin2, two_hours_ago); |
1568 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1575 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1569 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1576 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1570 | 1577 |
1571 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1578 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1572 BrowsingDataRemover::REMOVE_HISTORY, false); | 1579 BrowsingDataRemover::REMOVE_HISTORY, false); |
1573 | 1580 |
1574 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1581 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1575 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1582 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1576 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 1583 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
1577 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1584 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1578 } | 1585 } |
1579 | 1586 |
1580 // This should crash (DCHECK) in Debug, but death tests don't work properly | 1587 // This should crash (DCHECK) in Debug, but death tests don't work properly |
1581 // here. | 1588 // here. |
1582 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 1589 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
1583 TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) { | 1590 TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) { |
1584 RemoveHistoryTester tester; | 1591 RemoveHistoryTester tester; |
1585 ASSERT_TRUE(tester.Init(GetProfile())); | 1592 ASSERT_TRUE(tester.Init(GetProfile())); |
1586 PrefService* prefs = GetProfile()->GetPrefs(); | 1593 PrefService* prefs = GetProfile()->GetPrefs(); |
1587 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); | 1594 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); |
1588 | 1595 |
1589 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 1596 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
1590 | 1597 |
1591 tester.AddHistory(kOrigin1, base::Time::Now()); | 1598 tester.AddHistory(kOrigin1, base::Time::Now()); |
1592 tester.AddHistory(kOrigin2, two_hours_ago); | 1599 tester.AddHistory(kOrigin2, two_hours_ago); |
1593 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1600 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1594 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1601 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1595 | 1602 |
1596 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1603 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1597 BrowsingDataRemover::REMOVE_HISTORY, false); | 1604 BrowsingDataRemover::REMOVE_HISTORY, false); |
1598 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1605 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1599 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1606 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1600 | 1607 |
1601 // Nothing should have been deleted. | 1608 // Nothing should have been deleted. |
1602 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1609 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1603 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1610 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1604 } | 1611 } |
1605 #endif | 1612 #endif |
1606 | 1613 |
1607 TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) { | 1614 TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) { |
1608 // Add some history. | 1615 // Add some history. |
1609 RemoveHistoryTester history_tester; | 1616 RemoveHistoryTester history_tester; |
1610 ASSERT_TRUE(history_tester.Init(GetProfile())); | 1617 ASSERT_TRUE(history_tester.Init(GetProfile())); |
1611 history_tester.AddHistory(kOrigin1, base::Time::Now()); | 1618 history_tester.AddHistory(kOrigin1, base::Time::Now()); |
1612 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1619 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1613 | 1620 |
1614 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | | 1621 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | |
1615 BrowsingDataRemover::REMOVE_COOKIES; | 1622 BrowsingDataRemover::REMOVE_COOKIES; |
1616 | 1623 |
1617 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, removal_mask, false); | 1624 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1625 removal_mask, false); | |
1618 | 1626 |
1619 EXPECT_EQ(removal_mask, GetRemovalMask()); | 1627 EXPECT_EQ(removal_mask, GetRemovalMask()); |
1620 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1628 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1621 EXPECT_FALSE(history_tester.HistoryContainsURL(kOrigin1)); | 1629 EXPECT_FALSE(history_tester.HistoryContainsURL(kOrigin1)); |
1622 | 1630 |
1623 // The cookie would be deleted throught the StorageParition, check if the | 1631 // The cookie would be deleted throught the StorageParition, check if the |
1624 // partition was requested to remove cookie. | 1632 // partition was requested to remove cookie. |
1625 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1633 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1626 EXPECT_EQ(removal_data.remove_mask, | 1634 EXPECT_EQ(removal_data.remove_mask, |
1627 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1635 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
(...skipping 10 matching lines...) Expand all Loading... | |
1638 | 1646 |
1639 // Add some history. | 1647 // Add some history. |
1640 RemoveHistoryTester history_tester; | 1648 RemoveHistoryTester history_tester; |
1641 ASSERT_TRUE(history_tester.Init(GetProfile())); | 1649 ASSERT_TRUE(history_tester.Init(GetProfile())); |
1642 history_tester.AddHistory(kOrigin1, base::Time::Now()); | 1650 history_tester.AddHistory(kOrigin1, base::Time::Now()); |
1643 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1651 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1644 | 1652 |
1645 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | | 1653 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | |
1646 BrowsingDataRemover::REMOVE_COOKIES; | 1654 BrowsingDataRemover::REMOVE_COOKIES; |
1647 | 1655 |
1648 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, removal_mask, false); | 1656 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
1657 removal_mask, false); | |
1649 EXPECT_EQ(removal_mask, GetRemovalMask()); | 1658 EXPECT_EQ(removal_mask, GetRemovalMask()); |
1650 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1659 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1651 | 1660 |
1652 // 1/2. History should remain. | 1661 // 1/2. History should remain. |
1653 EXPECT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1662 EXPECT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1654 | 1663 |
1655 // 2/2. The cookie(s) would be deleted throught the StorageParition, check if | 1664 // 2/2. The cookie(s) would be deleted throught the StorageParition, check if |
1656 // the partition was requested to remove cookie. | 1665 // the partition was requested to remove cookie. |
1657 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1666 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1658 EXPECT_EQ(removal_data.remove_mask, | 1667 EXPECT_EQ(removal_data.remove_mask, |
1659 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1668 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1660 // Persistent storage won't be deleted, since ALL_TIME was not specified. | 1669 // Persistent storage won't be deleted, since the time period is not all time. |
1661 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1670 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1662 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1671 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1663 } | 1672 } |
1664 #endif | 1673 #endif |
1665 | 1674 |
1666 // Test that clearing history deletes favicons not associated with bookmarks. | 1675 // Test that clearing history deletes favicons not associated with bookmarks. |
1667 TEST_F(BrowsingDataRemoverTest, RemoveFaviconsForever) { | 1676 TEST_F(BrowsingDataRemoverTest, RemoveFaviconsForever) { |
1668 GURL page_url("http://a"); | 1677 GURL page_url("http://a"); |
1669 | 1678 |
1670 RemoveFaviconTester favicon_tester; | 1679 RemoveFaviconTester favicon_tester; |
1671 ASSERT_TRUE(favicon_tester.Init(GetProfile())); | 1680 ASSERT_TRUE(favicon_tester.Init(GetProfile())); |
1672 favicon_tester.VisitAndAddFavicon(page_url); | 1681 favicon_tester.VisitAndAddFavicon(page_url); |
1673 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(page_url)); | 1682 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(page_url)); |
1674 | 1683 |
1675 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1684 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1676 BrowsingDataRemover::REMOVE_HISTORY, false); | 1685 BrowsingDataRemover::REMOVE_HISTORY, false); |
1677 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1686 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1678 EXPECT_FALSE(favicon_tester.HasFaviconForPageURL(page_url)); | 1687 EXPECT_FALSE(favicon_tester.HasFaviconForPageURL(page_url)); |
1679 } | 1688 } |
1680 | 1689 |
1681 // Test that a bookmark's favicon is expired and not deleted when clearing | 1690 // Test that a bookmark's favicon is expired and not deleted when clearing |
1682 // history. Expiring the favicon causes the bookmark's favicon to be updated | 1691 // history. Expiring the favicon causes the bookmark's favicon to be updated |
1683 // when the user next visits the bookmarked page. Expiring the bookmark's | 1692 // when the user next visits the bookmarked page. Expiring the bookmark's |
1684 // favicon is useful when the bookmark's favicon becomes incorrect (See | 1693 // favicon is useful when the bookmark's favicon becomes incorrect (See |
1685 // crbug.com/474421 for a sample bug which causes this). | 1694 // crbug.com/474421 for a sample bug which causes this). |
1686 TEST_F(BrowsingDataRemoverTest, ExpireBookmarkFavicons) { | 1695 TEST_F(BrowsingDataRemoverTest, ExpireBookmarkFavicons) { |
1687 GURL bookmarked_page("http://a"); | 1696 GURL bookmarked_page("http://a"); |
1688 | 1697 |
1689 TestingProfile* profile = GetProfile(); | 1698 TestingProfile* profile = GetProfile(); |
1690 profile->CreateBookmarkModel(true); | 1699 profile->CreateBookmarkModel(true); |
1691 bookmarks::BookmarkModel* bookmark_model = | 1700 bookmarks::BookmarkModel* bookmark_model = |
1692 BookmarkModelFactory::GetForBrowserContext(profile); | 1701 BookmarkModelFactory::GetForBrowserContext(profile); |
1693 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 1702 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
1694 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, | 1703 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, |
1695 base::ASCIIToUTF16("a"), bookmarked_page); | 1704 base::ASCIIToUTF16("a"), bookmarked_page); |
1696 | 1705 |
1697 RemoveFaviconTester favicon_tester; | 1706 RemoveFaviconTester favicon_tester; |
1698 ASSERT_TRUE(favicon_tester.Init(GetProfile())); | 1707 ASSERT_TRUE(favicon_tester.Init(GetProfile())); |
1699 favicon_tester.VisitAndAddFavicon(bookmarked_page); | 1708 favicon_tester.VisitAndAddFavicon(bookmarked_page); |
1700 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(bookmarked_page)); | 1709 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(bookmarked_page)); |
1701 | 1710 |
1702 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1711 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1703 BrowsingDataRemover::REMOVE_HISTORY, false); | 1712 BrowsingDataRemover::REMOVE_HISTORY, false); |
1704 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1713 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1705 EXPECT_TRUE(favicon_tester.HasExpiredFaviconForPageURL(bookmarked_page)); | 1714 EXPECT_TRUE(favicon_tester.HasExpiredFaviconForPageURL(bookmarked_page)); |
1706 } | 1715 } |
1707 | 1716 |
1708 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { | 1717 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { |
1709 BlockUntilBrowsingDataRemoved( | 1718 BlockUntilBrowsingDataRemoved( |
1710 browsing_data::ALL_TIME, | 1719 base::Time(), base::Time::Max(), |
1711 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1720 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1712 BrowsingDataRemover::REMOVE_WEBSQL | | 1721 BrowsingDataRemover::REMOVE_WEBSQL | |
1713 BrowsingDataRemover::REMOVE_APPCACHE | | 1722 BrowsingDataRemover::REMOVE_APPCACHE | |
1714 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1723 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1715 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1724 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1716 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1725 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1717 false); | 1726 false); |
1718 | 1727 |
1719 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1728 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1720 BrowsingDataRemover::REMOVE_WEBSQL | | 1729 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 16 matching lines...) Expand all Loading... | |
1737 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1746 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1738 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1747 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1739 } | 1748 } |
1740 | 1749 |
1741 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1750 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
1742 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1751 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1743 CreateMockPolicy(); | 1752 CreateMockPolicy(); |
1744 #endif | 1753 #endif |
1745 | 1754 |
1746 BlockUntilBrowsingDataRemoved( | 1755 BlockUntilBrowsingDataRemoved( |
1747 browsing_data::ALL_TIME, | 1756 base::Time(), base::Time::Max(), |
1748 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1757 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1749 BrowsingDataRemover::REMOVE_WEBSQL | | 1758 BrowsingDataRemover::REMOVE_WEBSQL | |
1750 BrowsingDataRemover::REMOVE_APPCACHE | | 1759 BrowsingDataRemover::REMOVE_APPCACHE | |
1751 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1760 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1752 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1761 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1753 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1762 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1754 false); | 1763 false); |
1755 | 1764 |
1756 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1765 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1757 BrowsingDataRemover::REMOVE_WEBSQL | | 1766 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 23 matching lines...) Expand all Loading... | |
1781 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1790 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1782 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1791 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1783 } | 1792 } |
1784 | 1793 |
1785 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1794 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
1786 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1795 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1787 CreateMockPolicy(); | 1796 CreateMockPolicy(); |
1788 #endif | 1797 #endif |
1789 | 1798 |
1790 BlockUntilBrowsingDataRemoved( | 1799 BlockUntilBrowsingDataRemoved( |
1791 browsing_data::ALL_TIME, | 1800 base::Time(), base::Time::Max(), |
1792 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1801 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1793 BrowsingDataRemover::REMOVE_WEBSQL | | 1802 BrowsingDataRemover::REMOVE_WEBSQL | |
1794 BrowsingDataRemover::REMOVE_APPCACHE | | 1803 BrowsingDataRemover::REMOVE_APPCACHE | |
1795 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1804 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1796 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1805 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1797 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1806 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1798 false); | 1807 false); |
1799 | 1808 |
1800 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1809 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1801 BrowsingDataRemover::REMOVE_WEBSQL | | 1810 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 23 matching lines...) Expand all Loading... | |
1825 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1834 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1826 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1835 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1827 } | 1836 } |
1828 | 1837 |
1829 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1838 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
1830 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1839 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1831 CreateMockPolicy(); | 1840 CreateMockPolicy(); |
1832 #endif | 1841 #endif |
1833 | 1842 |
1834 BlockUntilBrowsingDataRemoved( | 1843 BlockUntilBrowsingDataRemoved( |
1835 browsing_data::ALL_TIME, | 1844 base::Time(), base::Time::Max(), |
1836 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1845 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1837 BrowsingDataRemover::REMOVE_WEBSQL | | 1846 BrowsingDataRemover::REMOVE_WEBSQL | |
1838 BrowsingDataRemover::REMOVE_APPCACHE | | 1847 BrowsingDataRemover::REMOVE_APPCACHE | |
1839 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1848 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1840 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1849 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1841 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1850 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1842 false); | 1851 false); |
1843 | 1852 |
1844 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1853 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1845 BrowsingDataRemover::REMOVE_WEBSQL | | 1854 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 22 matching lines...) Expand all Loading... | |
1868 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1877 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1869 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1878 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1870 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1879 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1871 } | 1880 } |
1872 | 1881 |
1873 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1882 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
1874 RegistrableDomainFilterBuilder builder( | 1883 RegistrableDomainFilterBuilder builder( |
1875 RegistrableDomainFilterBuilder::WHITELIST); | 1884 RegistrableDomainFilterBuilder::WHITELIST); |
1876 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 1885 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
1877 // Remove Origin 1. | 1886 // Remove Origin 1. |
1878 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1887 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1879 BrowsingDataRemover::REMOVE_APPCACHE | | 1888 BrowsingDataRemover::REMOVE_APPCACHE | |
1880 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1889 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1881 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1890 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1882 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1891 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1883 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1892 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1884 BrowsingDataRemover::REMOVE_WEBSQL, | 1893 BrowsingDataRemover::REMOVE_WEBSQL, |
1885 builder); | 1894 builder); |
1886 | 1895 |
1887 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 1896 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
1888 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1897 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 17 matching lines...) Expand all Loading... | |
1906 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1915 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1907 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1916 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1908 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1917 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1909 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1918 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1910 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1919 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1911 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); | 1920 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
1912 } | 1921 } |
1913 | 1922 |
1914 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1923 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
1915 BlockUntilBrowsingDataRemoved( | 1924 BlockUntilBrowsingDataRemoved( |
1916 browsing_data::LAST_HOUR, | 1925 HourAgo(), base::Time::Max(), |
1917 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1926 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1918 BrowsingDataRemover::REMOVE_WEBSQL | | 1927 BrowsingDataRemover::REMOVE_WEBSQL | |
1919 BrowsingDataRemover::REMOVE_APPCACHE | | 1928 BrowsingDataRemover::REMOVE_APPCACHE | |
1920 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1929 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1921 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1930 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1922 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1931 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1923 false); | 1932 false); |
1924 | 1933 |
1925 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1934 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1926 BrowsingDataRemover::REMOVE_WEBSQL | | 1935 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 19 matching lines...) Expand all Loading... | |
1946 // beginning of time. | 1955 // beginning of time. |
1947 uint32_t expected_quota_mask = | 1956 uint32_t expected_quota_mask = |
1948 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1957 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1949 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1958 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1950 // Check removal begin time. | 1959 // Check removal begin time. |
1951 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1960 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1952 } | 1961 } |
1953 | 1962 |
1954 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1963 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
1955 BlockUntilBrowsingDataRemoved( | 1964 BlockUntilBrowsingDataRemoved( |
1956 browsing_data::LAST_WEEK, | 1965 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), |
1957 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1966 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1958 BrowsingDataRemover::REMOVE_WEBSQL | | 1967 BrowsingDataRemover::REMOVE_WEBSQL | |
1959 BrowsingDataRemover::REMOVE_APPCACHE | | 1968 BrowsingDataRemover::REMOVE_APPCACHE | |
1960 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1969 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1961 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1970 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1962 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1971 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1963 false); | 1972 false); |
1964 | 1973 |
1965 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1974 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1966 BrowsingDataRemover::REMOVE_WEBSQL | | 1975 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 25 matching lines...) Expand all Loading... | |
1992 } | 2001 } |
1993 | 2002 |
1994 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 2003 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
1995 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2004 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1996 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2005 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1997 // Protect kOrigin1. | 2006 // Protect kOrigin1. |
1998 policy->AddProtected(kOrigin1.GetOrigin()); | 2007 policy->AddProtected(kOrigin1.GetOrigin()); |
1999 #endif | 2008 #endif |
2000 | 2009 |
2001 BlockUntilBrowsingDataRemoved( | 2010 BlockUntilBrowsingDataRemoved( |
2002 browsing_data::ALL_TIME, | 2011 base::Time(), base::Time::Max(), |
2003 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2012 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2004 BrowsingDataRemover::REMOVE_WEBSQL | | 2013 BrowsingDataRemover::REMOVE_WEBSQL | |
2005 BrowsingDataRemover::REMOVE_APPCACHE | | 2014 BrowsingDataRemover::REMOVE_APPCACHE | |
2006 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2015 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2007 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2016 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2008 BrowsingDataRemover::REMOVE_INDEXEDDB, | 2017 BrowsingDataRemover::REMOVE_INDEXEDDB, |
2009 false); | 2018 false); |
2010 | 2019 |
2011 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2020 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2012 BrowsingDataRemover::REMOVE_WEBSQL | | 2021 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 29 matching lines...) Expand all Loading... | |
2042 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2051 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
2043 // Protect kOrigin1. | 2052 // Protect kOrigin1. |
2044 policy->AddProtected(kOrigin1.GetOrigin()); | 2053 policy->AddProtected(kOrigin1.GetOrigin()); |
2045 #endif | 2054 #endif |
2046 | 2055 |
2047 RegistrableDomainFilterBuilder builder( | 2056 RegistrableDomainFilterBuilder builder( |
2048 RegistrableDomainFilterBuilder::WHITELIST); | 2057 RegistrableDomainFilterBuilder::WHITELIST); |
2049 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2058 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2050 | 2059 |
2051 // Try to remove kOrigin1. Expect failure. | 2060 // Try to remove kOrigin1. Expect failure. |
2052 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2061 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2053 BrowsingDataRemover::REMOVE_APPCACHE | | 2062 BrowsingDataRemover::REMOVE_APPCACHE | |
2054 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2063 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2055 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2064 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2056 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2065 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2057 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2066 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2058 BrowsingDataRemover::REMOVE_WEBSQL, | 2067 BrowsingDataRemover::REMOVE_WEBSQL, |
2059 builder); | 2068 builder); |
2060 | 2069 |
2061 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2070 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2062 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2071 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 28 matching lines...) Expand all Loading... | |
2091 | 2100 |
2092 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 2101 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
2093 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2102 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2094 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2103 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
2095 // Protect kOrigin1. | 2104 // Protect kOrigin1. |
2096 policy->AddProtected(kOrigin1.GetOrigin()); | 2105 policy->AddProtected(kOrigin1.GetOrigin()); |
2097 #endif | 2106 #endif |
2098 | 2107 |
2099 // Try to remove kOrigin1. Expect success. | 2108 // Try to remove kOrigin1. Expect success. |
2100 BlockUntilBrowsingDataRemoved( | 2109 BlockUntilBrowsingDataRemoved( |
2101 browsing_data::ALL_TIME, | 2110 base::Time(), base::Time::Max(), |
2102 BrowsingDataRemover::REMOVE_APPCACHE | | 2111 BrowsingDataRemover::REMOVE_APPCACHE | |
2103 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2112 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2104 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2113 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2105 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2114 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2106 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2115 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2107 BrowsingDataRemover::REMOVE_WEBSQL, | 2116 BrowsingDataRemover::REMOVE_WEBSQL, |
2108 true); | 2117 true); |
2109 | 2118 |
2110 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2119 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2111 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2120 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 24 matching lines...) Expand all Loading... | |
2136 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 2145 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
2137 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 2146 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
2138 } | 2147 } |
2139 | 2148 |
2140 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 2149 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
2141 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2150 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2142 CreateMockPolicy(); | 2151 CreateMockPolicy(); |
2143 #endif | 2152 #endif |
2144 | 2153 |
2145 BlockUntilBrowsingDataRemoved( | 2154 BlockUntilBrowsingDataRemoved( |
2146 browsing_data::ALL_TIME, | 2155 base::Time(), base::Time::Max(), |
2147 BrowsingDataRemover::REMOVE_APPCACHE | | 2156 BrowsingDataRemover::REMOVE_APPCACHE | |
2148 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2157 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2149 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2158 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2150 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2159 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2151 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2160 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2152 BrowsingDataRemover::REMOVE_WEBSQL, | 2161 BrowsingDataRemover::REMOVE_WEBSQL, |
2153 false); | 2162 false); |
2154 | 2163 |
2155 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2164 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2156 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2165 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 29 matching lines...) Expand all Loading... | |
2186 | 2195 |
2187 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 2196 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
2188 | 2197 |
2189 tester.AddHistory(kOrigin1, base::Time::Now()); | 2198 tester.AddHistory(kOrigin1, base::Time::Now()); |
2190 tester.AddHistory(kOrigin2, two_hours_ago); | 2199 tester.AddHistory(kOrigin2, two_hours_ago); |
2191 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2200 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
2192 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2201 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
2193 | 2202 |
2194 RegistrableDomainFilterBuilder builder( | 2203 RegistrableDomainFilterBuilder builder( |
2195 RegistrableDomainFilterBuilder::BLACKLIST); | 2204 RegistrableDomainFilterBuilder::BLACKLIST); |
2196 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2205 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
2197 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2206 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2198 | 2207 |
2199 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2208 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
2200 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2209 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2201 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 2210 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
2202 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2211 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
2203 } | 2212 } |
2204 | 2213 |
2205 // Verify that clearing autofill form data works. | 2214 // Verify that clearing autofill form data works. |
2206 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2215 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
2207 GetProfile()->CreateWebDataService(); | 2216 GetProfile()->CreateWebDataService(); |
2208 RemoveAutofillTester tester(GetProfile()); | 2217 RemoveAutofillTester tester(GetProfile()); |
2209 | 2218 |
2210 ASSERT_FALSE(tester.HasProfile()); | 2219 ASSERT_FALSE(tester.HasProfile()); |
2211 tester.AddProfilesAndCards(); | 2220 tester.AddProfilesAndCards(); |
2212 ASSERT_TRUE(tester.HasProfile()); | 2221 ASSERT_TRUE(tester.HasProfile()); |
2213 | 2222 |
2214 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2223 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
2215 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 2224 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
2216 | 2225 |
2217 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 2226 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
2218 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2227 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2219 ASSERT_FALSE(tester.HasProfile()); | 2228 ASSERT_FALSE(tester.HasProfile()); |
2220 } | 2229 } |
2221 | 2230 |
2222 TEST_F(BrowsingDataRemoverTest, AutofillRemovalEverything) { | 2231 TEST_F(BrowsingDataRemoverTest, AutofillRemovalEverything) { |
2223 GetProfile()->CreateWebDataService(); | 2232 GetProfile()->CreateWebDataService(); |
2224 RemoveAutofillTester tester(GetProfile()); | 2233 RemoveAutofillTester tester(GetProfile()); |
2225 | 2234 |
2226 ASSERT_FALSE(tester.HasProfile()); | 2235 ASSERT_FALSE(tester.HasProfile()); |
2227 tester.AddProfilesAndCards(); | 2236 tester.AddProfilesAndCards(); |
2228 ASSERT_TRUE(tester.HasProfile()); | 2237 ASSERT_TRUE(tester.HasProfile()); |
2229 | 2238 |
2230 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2239 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2231 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 2240 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
2232 | 2241 |
2233 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 2242 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
2234 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2243 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2235 ASSERT_FALSE(tester.HasProfile()); | 2244 ASSERT_FALSE(tester.HasProfile()); |
2236 } | 2245 } |
2237 | 2246 |
2238 // Verify that clearing autofill form data works. | 2247 // Verify that clearing autofill form data works. |
2239 TEST_F(BrowsingDataRemoverTest, AutofillOriginsRemovedWithHistory) { | 2248 TEST_F(BrowsingDataRemoverTest, AutofillOriginsRemovedWithHistory) { |
2240 GetProfile()->CreateWebDataService(); | 2249 GetProfile()->CreateWebDataService(); |
2241 RemoveAutofillTester tester(GetProfile()); | 2250 RemoveAutofillTester tester(GetProfile()); |
2242 | 2251 |
2243 tester.AddProfilesAndCards(); | 2252 tester.AddProfilesAndCards(); |
2244 EXPECT_FALSE(tester.HasOrigin(std::string())); | 2253 EXPECT_FALSE(tester.HasOrigin(std::string())); |
2245 EXPECT_TRUE(tester.HasOrigin(kWebOrigin)); | 2254 EXPECT_TRUE(tester.HasOrigin(kWebOrigin)); |
2246 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); | 2255 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); |
2247 | 2256 |
2248 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2257 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
2249 BrowsingDataRemover::REMOVE_HISTORY, false); | 2258 BrowsingDataRemover::REMOVE_HISTORY, false); |
2250 | 2259 |
2251 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2260 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
2252 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2261 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2253 EXPECT_TRUE(tester.HasOrigin(std::string())); | 2262 EXPECT_TRUE(tester.HasOrigin(std::string())); |
2254 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); | 2263 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); |
2255 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); | 2264 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); |
2256 } | 2265 } |
2257 | 2266 |
2258 class InspectableCompletionObserver | 2267 class InspectableCompletionObserver |
(...skipping 16 matching lines...) Expand all Loading... | |
2275 }; | 2284 }; |
2276 | 2285 |
2277 TEST_F(BrowsingDataRemoverTest, CompletionInhibition) { | 2286 TEST_F(BrowsingDataRemoverTest, CompletionInhibition) { |
2278 // The |completion_inhibitor| on the stack should prevent removal sessions | 2287 // The |completion_inhibitor| on the stack should prevent removal sessions |
2279 // from completing until after ContinueToCompletion() is called. | 2288 // from completing until after ContinueToCompletion() is called. |
2280 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2289 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2281 | 2290 |
2282 BrowsingDataRemover* remover = | 2291 BrowsingDataRemover* remover = |
2283 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 2292 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
2284 InspectableCompletionObserver completion_observer(remover); | 2293 InspectableCompletionObserver completion_observer(remover); |
2285 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 2294 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
2286 BrowsingDataRemover::REMOVE_HISTORY, | 2295 BrowsingDataRemover::REMOVE_HISTORY, |
2287 BrowsingDataHelper::UNPROTECTED_WEB, | 2296 BrowsingDataHelper::UNPROTECTED_WEB, |
2288 &completion_observer); | 2297 &completion_observer); |
2289 | 2298 |
2290 // Process messages until the inhibitor is notified, and then some, to make | 2299 // Process messages until the inhibitor is notified, and then some, to make |
2291 // sure we do not complete asynchronously before ContinueToCompletion() is | 2300 // sure we do not complete asynchronously before ContinueToCompletion() is |
2292 // called. | 2301 // called. |
2293 completion_inhibitor.BlockUntilNearCompletion(); | 2302 completion_inhibitor.BlockUntilNearCompletion(); |
2294 base::RunLoop().RunUntilIdle(); | 2303 base::RunLoop().RunUntilIdle(); |
2295 | 2304 |
2296 // Verify that the removal has not yet been completed and the observer has | 2305 // Verify that the removal has not yet been completed and the observer has |
2297 // not been called. | 2306 // not been called. |
2298 EXPECT_TRUE(remover->is_removing()); | 2307 EXPECT_TRUE(remover->is_removing()); |
2299 EXPECT_FALSE(completion_observer.called()); | 2308 EXPECT_FALSE(completion_observer.called()); |
2300 | 2309 |
2301 // Now run the removal process until completion, and verify that observers are | 2310 // Now run the removal process until completion, and verify that observers are |
2302 // now notified, and the notifications is sent out. | 2311 // now notified, and the notifications is sent out. |
2303 completion_inhibitor.ContinueToCompletion(); | 2312 completion_inhibitor.ContinueToCompletion(); |
2304 completion_observer.BlockUntilCompletion(); | 2313 completion_observer.BlockUntilCompletion(); |
2305 | 2314 |
2306 EXPECT_FALSE(remover->is_removing()); | 2315 EXPECT_FALSE(remover->is_removing()); |
2307 EXPECT_TRUE(completion_observer.called()); | 2316 EXPECT_TRUE(completion_observer.called()); |
2308 } | 2317 } |
2309 | 2318 |
2310 TEST_F(BrowsingDataRemoverTest, EarlyShutdown) { | 2319 TEST_F(BrowsingDataRemoverTest, EarlyShutdown) { |
2311 BrowsingDataRemover* remover = | 2320 BrowsingDataRemover* remover = |
2312 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 2321 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
2313 InspectableCompletionObserver completion_observer(remover); | 2322 InspectableCompletionObserver completion_observer(remover); |
2314 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2323 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2315 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 2324 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
2316 BrowsingDataRemover::REMOVE_HISTORY, | 2325 BrowsingDataRemover::REMOVE_HISTORY, |
2317 BrowsingDataHelper::UNPROTECTED_WEB, | 2326 BrowsingDataHelper::UNPROTECTED_WEB, |
2318 &completion_observer); | 2327 &completion_observer); |
2319 | 2328 |
2320 completion_inhibitor.BlockUntilNearCompletion(); | 2329 completion_inhibitor.BlockUntilNearCompletion(); |
2321 | 2330 |
2322 // Verify that the deletion has not yet been completed and the observer has | 2331 // Verify that the deletion has not yet been completed and the observer has |
2323 // not been called. | 2332 // not been called. |
2324 EXPECT_TRUE(remover->is_removing()); | 2333 EXPECT_TRUE(remover->is_removing()); |
2325 EXPECT_FALSE(completion_observer.called()); | 2334 EXPECT_FALSE(completion_observer.called()); |
2326 | 2335 |
2327 // Destroying the profile should trigger the notification. | 2336 // Destroying the profile should trigger the notification. |
2328 DestroyProfile(); | 2337 DestroyProfile(); |
2329 | 2338 |
2330 EXPECT_TRUE(completion_observer.called()); | 2339 EXPECT_TRUE(completion_observer.called()); |
2331 | 2340 |
2332 // Finishing after shutdown shouldn't break anything. | 2341 // Finishing after shutdown shouldn't break anything. |
2333 completion_inhibitor.ContinueToCompletion(); | 2342 completion_inhibitor.ContinueToCompletion(); |
2334 completion_observer.BlockUntilCompletion(); | 2343 completion_observer.BlockUntilCompletion(); |
2335 } | 2344 } |
2336 | 2345 |
2337 TEST_F(BrowsingDataRemoverTest, ZeroSuggestCacheClear) { | 2346 TEST_F(BrowsingDataRemoverTest, ZeroSuggestCacheClear) { |
2338 PrefService* prefs = GetProfile()->GetPrefs(); | 2347 PrefService* prefs = GetProfile()->GetPrefs(); |
2339 prefs->SetString(omnibox::kZeroSuggestCachedResults, | 2348 prefs->SetString(omnibox::kZeroSuggestCachedResults, |
2340 "[\"\", [\"foo\", \"bar\"]]"); | 2349 "[\"\", [\"foo\", \"bar\"]]"); |
2341 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2350 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2342 BrowsingDataRemover::REMOVE_COOKIES, false); | 2351 BrowsingDataRemover::REMOVE_COOKIES, false); |
2343 | 2352 |
2344 // Expect the prefs to be cleared when cookies are removed. | 2353 // Expect the prefs to be cleared when cookies are removed. |
2345 EXPECT_TRUE(prefs->GetString(omnibox::kZeroSuggestCachedResults).empty()); | 2354 EXPECT_TRUE(prefs->GetString(omnibox::kZeroSuggestCachedResults).empty()); |
2346 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 2355 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
2347 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2356 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2348 } | 2357 } |
2349 | 2358 |
2350 #if defined(OS_CHROMEOS) | 2359 #if defined(OS_CHROMEOS) |
2351 TEST_F(BrowsingDataRemoverTest, ContentProtectionPlatformKeysRemoval) { | 2360 TEST_F(BrowsingDataRemoverTest, ContentProtectionPlatformKeysRemoval) { |
(...skipping 10 matching lines...) Expand all Loading... | |
2362 chromeos::MockCryptohomeClient* cryptohome_client = | 2371 chromeos::MockCryptohomeClient* cryptohome_client = |
2363 new chromeos::MockCryptohomeClient; | 2372 new chromeos::MockCryptohomeClient; |
2364 dbus_setter->SetCryptohomeClient( | 2373 dbus_setter->SetCryptohomeClient( |
2365 std::unique_ptr<chromeos::CryptohomeClient>(cryptohome_client)); | 2374 std::unique_ptr<chromeos::CryptohomeClient>(cryptohome_client)); |
2366 | 2375 |
2367 // Expect exactly one call. No calls means no attempt to delete keys and more | 2376 // Expect exactly one call. No calls means no attempt to delete keys and more |
2368 // than one call means a significant performance problem. | 2377 // than one call means a significant performance problem. |
2369 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) | 2378 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) |
2370 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); | 2379 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); |
2371 | 2380 |
2372 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2381 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2373 BrowsingDataRemover::REMOVE_MEDIA_LICENSES, | 2382 BrowsingDataRemover::REMOVE_MEDIA_LICENSES, |
2374 false); | 2383 false); |
2375 | 2384 |
2376 chromeos::DBusThreadManager::Shutdown(); | 2385 chromeos::DBusThreadManager::Shutdown(); |
2377 } | 2386 } |
2378 #endif | 2387 #endif |
2379 | 2388 |
2380 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) { | 2389 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) { |
2381 const ClearDomainReliabilityTester& tester = | 2390 const ClearDomainReliabilityTester& tester = |
2382 clear_domain_reliability_tester(); | 2391 clear_domain_reliability_tester(); |
2383 | 2392 |
2384 EXPECT_EQ(0u, tester.clear_count()); | 2393 EXPECT_EQ(0u, tester.clear_count()); |
2385 } | 2394 } |
2386 | 2395 |
2387 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) { | 2396 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) { |
2388 const ClearDomainReliabilityTester& tester = | 2397 const ClearDomainReliabilityTester& tester = |
2389 clear_domain_reliability_tester(); | 2398 clear_domain_reliability_tester(); |
2390 | 2399 |
2391 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2400 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2392 BrowsingDataRemover::REMOVE_HISTORY, false); | 2401 BrowsingDataRemover::REMOVE_HISTORY, false); |
2393 EXPECT_EQ(1u, tester.clear_count()); | 2402 EXPECT_EQ(1u, tester.clear_count()); |
2394 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); | 2403 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); |
2395 EXPECT_TRUE(ProbablySameFilters( | 2404 EXPECT_TRUE(ProbablySameFilters( |
2396 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); | 2405 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); |
2397 } | 2406 } |
2398 | 2407 |
2399 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons_WithFilter) { | 2408 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons_WithFilter) { |
2400 const ClearDomainReliabilityTester& tester = | 2409 const ClearDomainReliabilityTester& tester = |
2401 clear_domain_reliability_tester(); | 2410 clear_domain_reliability_tester(); |
2402 | 2411 |
2403 RegistrableDomainFilterBuilder builder( | 2412 RegistrableDomainFilterBuilder builder( |
2404 RegistrableDomainFilterBuilder::WHITELIST); | 2413 RegistrableDomainFilterBuilder::WHITELIST); |
2405 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2414 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2406 | 2415 |
2407 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2416 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2408 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2417 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2409 EXPECT_EQ(1u, tester.clear_count()); | 2418 EXPECT_EQ(1u, tester.clear_count()); |
2410 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); | 2419 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); |
2411 EXPECT_TRUE(ProbablySameFilters( | 2420 EXPECT_TRUE(ProbablySameFilters( |
2412 builder.BuildGeneralFilter(), tester.last_filter())); | 2421 builder.BuildGeneralFilter(), tester.last_filter())); |
2413 } | 2422 } |
2414 | 2423 |
2415 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) { | 2424 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) { |
2416 const ClearDomainReliabilityTester& tester = | 2425 const ClearDomainReliabilityTester& tester = |
2417 clear_domain_reliability_tester(); | 2426 clear_domain_reliability_tester(); |
2418 | 2427 |
2419 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2428 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2420 BrowsingDataRemover::REMOVE_COOKIES, false); | 2429 BrowsingDataRemover::REMOVE_COOKIES, false); |
2421 EXPECT_EQ(1u, tester.clear_count()); | 2430 EXPECT_EQ(1u, tester.clear_count()); |
2422 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2431 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2423 EXPECT_TRUE(ProbablySameFilters( | 2432 EXPECT_TRUE(ProbablySameFilters( |
2424 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); | 2433 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); |
2425 } | 2434 } |
2426 | 2435 |
2427 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_WithFilter) { | 2436 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_WithFilter) { |
2428 const ClearDomainReliabilityTester& tester = | 2437 const ClearDomainReliabilityTester& tester = |
2429 clear_domain_reliability_tester(); | 2438 clear_domain_reliability_tester(); |
2430 | 2439 |
2431 RegistrableDomainFilterBuilder builder( | 2440 RegistrableDomainFilterBuilder builder( |
2432 RegistrableDomainFilterBuilder::WHITELIST); | 2441 RegistrableDomainFilterBuilder::WHITELIST); |
2433 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2442 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2434 | 2443 |
2435 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2444 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2436 BrowsingDataRemover::REMOVE_COOKIES, builder); | 2445 BrowsingDataRemover::REMOVE_COOKIES, builder); |
2437 EXPECT_EQ(1u, tester.clear_count()); | 2446 EXPECT_EQ(1u, tester.clear_count()); |
2438 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2447 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2439 EXPECT_TRUE(ProbablySameFilters( | 2448 EXPECT_TRUE(ProbablySameFilters( |
2440 builder.BuildGeneralFilter(), tester.last_filter())); | 2449 builder.BuildGeneralFilter(), tester.last_filter())); |
2441 } | 2450 } |
2442 | 2451 |
2443 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) { | 2452 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) { |
2444 const ClearDomainReliabilityTester& tester = | 2453 const ClearDomainReliabilityTester& tester = |
2445 clear_domain_reliability_tester(); | 2454 clear_domain_reliability_tester(); |
2446 | 2455 |
2447 BlockUntilBrowsingDataRemoved( | 2456 BlockUntilBrowsingDataRemoved( |
2448 browsing_data::ALL_TIME, | 2457 base::Time(), base::Time::Max(), |
2449 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, | 2458 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, |
2450 false); | 2459 false); |
2451 EXPECT_EQ(1u, tester.clear_count()); | 2460 EXPECT_EQ(1u, tester.clear_count()); |
2452 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2461 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2453 } | 2462 } |
2454 | 2463 |
2455 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) { | 2464 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) { |
2456 const ClearDomainReliabilityTester& tester = | 2465 const ClearDomainReliabilityTester& tester = |
2457 clear_domain_reliability_tester(); | 2466 clear_domain_reliability_tester(); |
2458 | 2467 |
2459 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2468 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2460 BrowsingDataRemover::REMOVE_COOKIES, true); | 2469 BrowsingDataRemover::REMOVE_COOKIES, true); |
2461 EXPECT_EQ(1u, tester.clear_count()); | 2470 EXPECT_EQ(1u, tester.clear_count()); |
2462 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2471 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2463 } | 2472 } |
2464 | 2473 |
2465 // TODO(juliatuttle): This isn't actually testing the no-monitor case, since | 2474 // TODO(juliatuttle): This isn't actually testing the no-monitor case, since |
2466 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed | 2475 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed |
2467 // for some unrelated test cases. This should be fixed so it tests the no- | 2476 // for some unrelated test cases. This should be fixed so it tests the no- |
2468 // monitor case again. | 2477 // monitor case again. |
2469 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { | 2478 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { |
2470 BlockUntilBrowsingDataRemoved( | 2479 BlockUntilBrowsingDataRemoved( |
2471 browsing_data::ALL_TIME, | 2480 base::Time(), base::Time::Max(), |
2472 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, | 2481 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, |
2473 false); | 2482 false); |
2474 } | 2483 } |
2475 | 2484 |
2476 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { | 2485 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { |
2477 RemoveDownloadsTester tester(GetProfile()); | 2486 RemoveDownloadsTester tester(GetProfile()); |
2478 base::Callback<bool(const GURL&)> filter = | 2487 base::Callback<bool(const GURL&)> filter = |
2479 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2488 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2480 | 2489 |
2481 EXPECT_CALL( | 2490 EXPECT_CALL( |
2482 *tester.download_manager(), | 2491 *tester.download_manager(), |
2483 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2492 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2484 | 2493 |
2485 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2494 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2486 BrowsingDataRemover::REMOVE_DOWNLOADS, false); | 2495 BrowsingDataRemover::REMOVE_DOWNLOADS, false); |
2487 } | 2496 } |
2488 | 2497 |
2489 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { | 2498 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { |
2490 RemoveDownloadsTester tester(GetProfile()); | 2499 RemoveDownloadsTester tester(GetProfile()); |
2491 RegistrableDomainFilterBuilder builder( | 2500 RegistrableDomainFilterBuilder builder( |
2492 RegistrableDomainFilterBuilder::WHITELIST); | 2501 RegistrableDomainFilterBuilder::WHITELIST); |
2493 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2502 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2494 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2503 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2495 | 2504 |
2496 EXPECT_CALL( | 2505 EXPECT_CALL( |
2497 *tester.download_manager(), | 2506 *tester.download_manager(), |
2498 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2507 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2499 | 2508 |
2500 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2509 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2501 BrowsingDataRemover::REMOVE_DOWNLOADS, builder); | 2510 BrowsingDataRemover::REMOVE_DOWNLOADS, builder); |
2502 } | 2511 } |
2503 | 2512 |
2504 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { | 2513 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { |
2505 RemovePasswordsTester tester(GetProfile()); | 2514 RemovePasswordsTester tester(GetProfile()); |
2506 base::Callback<bool(const GURL&)> empty_filter; | 2515 base::Callback<bool(const GURL&)> empty_filter; |
2507 | 2516 |
2508 EXPECT_CALL(*tester.store(), RemoveStatisticsByOriginAndTimeImpl( | 2517 EXPECT_CALL(*tester.store(), RemoveStatisticsByOriginAndTimeImpl( |
2509 ProbablySameFilter(empty_filter), | 2518 ProbablySameFilter(empty_filter), |
2510 base::Time(), base::Time::Max())); | 2519 base::Time(), base::Time::Max())); |
2511 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2520 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2512 BrowsingDataRemover::REMOVE_HISTORY, false); | 2521 BrowsingDataRemover::REMOVE_HISTORY, false); |
2513 } | 2522 } |
2514 | 2523 |
2515 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatisticsByOrigin) { | 2524 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatisticsByOrigin) { |
2516 RemovePasswordsTester tester(GetProfile()); | 2525 RemovePasswordsTester tester(GetProfile()); |
2517 | 2526 |
2518 RegistrableDomainFilterBuilder builder( | 2527 RegistrableDomainFilterBuilder builder( |
2519 RegistrableDomainFilterBuilder::WHITELIST); | 2528 RegistrableDomainFilterBuilder::WHITELIST); |
2520 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2529 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2521 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2530 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2522 | 2531 |
2523 EXPECT_CALL(*tester.store(), | 2532 EXPECT_CALL(*tester.store(), |
2524 RemoveStatisticsByOriginAndTimeImpl( | 2533 RemoveStatisticsByOriginAndTimeImpl( |
2525 ProbablySameFilter(filter), base::Time(), base::Time::Max())); | 2534 ProbablySameFilter(filter), base::Time(), base::Time::Max())); |
2526 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2535 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2527 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2536 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2528 } | 2537 } |
2529 | 2538 |
2530 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { | 2539 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { |
2531 RemovePasswordsTester tester(GetProfile()); | 2540 RemovePasswordsTester tester(GetProfile()); |
2532 base::Callback<bool(const GURL&)> filter = | 2541 base::Callback<bool(const GURL&)> filter = |
2533 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2542 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2534 | 2543 |
2535 EXPECT_CALL(*tester.store(), | 2544 EXPECT_CALL(*tester.store(), |
2536 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2545 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2537 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2546 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2538 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2547 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2539 BrowsingDataRemover::REMOVE_PASSWORDS, false); | 2548 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
2540 } | 2549 } |
2541 | 2550 |
2542 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { | 2551 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { |
2543 RemovePasswordsTester tester(GetProfile()); | 2552 RemovePasswordsTester tester(GetProfile()); |
2544 RegistrableDomainFilterBuilder builder( | 2553 RegistrableDomainFilterBuilder builder( |
2545 RegistrableDomainFilterBuilder::WHITELIST); | 2554 RegistrableDomainFilterBuilder::WHITELIST); |
2546 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2555 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2547 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2556 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2548 | 2557 |
2549 EXPECT_CALL(*tester.store(), | 2558 EXPECT_CALL(*tester.store(), |
2550 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2559 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2551 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2560 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2552 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2561 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2553 BrowsingDataRemover::REMOVE_PASSWORDS, builder); | 2562 BrowsingDataRemover::REMOVE_PASSWORDS, builder); |
2554 } | 2563 } |
2555 | 2564 |
2556 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { | 2565 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { |
2557 RemovePasswordsTester tester(GetProfile()); | 2566 RemovePasswordsTester tester(GetProfile()); |
2558 base::Callback<bool(const GURL&)> empty_filter = | 2567 base::Callback<bool(const GURL&)> empty_filter = |
2559 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2568 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2560 | 2569 |
2561 EXPECT_CALL( | 2570 EXPECT_CALL( |
2562 *tester.store(), | 2571 *tester.store(), |
2563 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) | 2572 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) |
2564 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2573 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2565 | 2574 |
2566 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2575 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2567 BrowsingDataRemover::REMOVE_COOKIES, false); | 2576 BrowsingDataRemover::REMOVE_COOKIES, false); |
2568 } | 2577 } |
2569 | 2578 |
2570 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { | 2579 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { |
2571 RemovePasswordsTester tester(GetProfile()); | 2580 RemovePasswordsTester tester(GetProfile()); |
2572 base::Callback<bool(const GURL&)> empty_filter = | 2581 base::Callback<bool(const GURL&)> empty_filter = |
2573 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2582 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2574 | 2583 |
2575 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2584 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
2576 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2585 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2577 EXPECT_CALL( | 2586 EXPECT_CALL( |
2578 *tester.store(), | 2587 *tester.store(), |
2579 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) | 2588 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) |
2580 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2589 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2581 | 2590 |
2582 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2591 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2583 BrowsingDataRemover::REMOVE_COOKIES | | 2592 BrowsingDataRemover::REMOVE_COOKIES | |
2584 BrowsingDataRemover::REMOVE_PASSWORDS, | 2593 BrowsingDataRemover::REMOVE_PASSWORDS, |
2585 false); | 2594 false); |
2586 } | 2595 } |
2587 | 2596 |
2588 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { | 2597 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
2589 // Add our settings. | 2598 // Add our settings. |
2590 HostContentSettingsMap* host_content_settings_map = | 2599 HostContentSettingsMap* host_content_settings_map = |
2591 HostContentSettingsMapFactory::GetForProfile(GetProfile()); | 2600 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
2592 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2601 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2593 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2602 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2594 base::MakeUnique<base::DictionaryValue>()); | 2603 base::MakeUnique<base::DictionaryValue>()); |
2595 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2604 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2596 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2605 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2597 base::MakeUnique<base::DictionaryValue>()); | 2606 base::MakeUnique<base::DictionaryValue>()); |
2598 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2607 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2599 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2608 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2600 base::MakeUnique<base::DictionaryValue>()); | 2609 base::MakeUnique<base::DictionaryValue>()); |
2601 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2610 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2602 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2611 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2603 base::MakeUnique<base::DictionaryValue>()); | 2612 base::MakeUnique<base::DictionaryValue>()); |
2604 | 2613 |
2605 // Clear all except for origin1 and origin3. | 2614 // Clear all except for origin1 and origin3. |
2606 RegistrableDomainFilterBuilder filter( | 2615 RegistrableDomainFilterBuilder filter( |
2607 RegistrableDomainFilterBuilder::BLACKLIST); | 2616 RegistrableDomainFilterBuilder::BLACKLIST); |
2608 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 2617 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
2609 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 2618 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
2610 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2619 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
2611 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2620 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2612 filter); | 2621 filter); |
2613 | 2622 |
2614 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); | 2623 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
2615 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2624 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2616 | 2625 |
2617 // Verify we only have true, and they're origin1, origin3, and origin4. | 2626 // Verify we only have true, and they're origin1, origin3, and origin4. |
2618 ContentSettingsForOneType host_settings; | 2627 ContentSettingsForOneType host_settings; |
2619 host_content_settings_map->GetSettingsForOneType( | 2628 host_content_settings_map->GetSettingsForOneType( |
2620 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2629 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
(...skipping 18 matching lines...) Expand all Loading... | |
2639 durable_permission.UpdateContentSetting(kOrigin1, GURL(), | 2648 durable_permission.UpdateContentSetting(kOrigin1, GURL(), |
2640 CONTENT_SETTING_ALLOW); | 2649 CONTENT_SETTING_ALLOW); |
2641 durable_permission.UpdateContentSetting(kOrigin2, GURL(), | 2650 durable_permission.UpdateContentSetting(kOrigin2, GURL(), |
2642 CONTENT_SETTING_ALLOW); | 2651 CONTENT_SETTING_ALLOW); |
2643 | 2652 |
2644 // Clear all except for origin1 and origin3. | 2653 // Clear all except for origin1 and origin3. |
2645 RegistrableDomainFilterBuilder filter( | 2654 RegistrableDomainFilterBuilder filter( |
2646 RegistrableDomainFilterBuilder::BLACKLIST); | 2655 RegistrableDomainFilterBuilder::BLACKLIST); |
2647 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 2656 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
2648 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 2657 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
2649 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2658 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
2650 BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, | 2659 BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, |
2651 filter); | 2660 filter); |
2652 | 2661 |
2653 EXPECT_EQ(BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, GetRemovalMask()); | 2662 EXPECT_EQ(BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, GetRemovalMask()); |
2654 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2663 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2655 | 2664 |
2656 // Verify we only have allow for the first origin. | 2665 // Verify we only have allow for the first origin. |
2657 ContentSettingsForOneType host_settings; | 2666 ContentSettingsForOneType host_settings; |
2658 host_content_settings_map->GetSettingsForOneType( | 2667 host_content_settings_map->GetSettingsForOneType( |
2659 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); | 2668 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); |
(...skipping 23 matching lines...) Expand all Loading... | |
2683 | 2692 |
2684 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2693 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); |
2685 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, | 2694 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, |
2686 "test challenge", | 2695 "test challenge", |
2687 net::AuthCredentials(base::ASCIIToUTF16("foo"), | 2696 net::AuthCredentials(base::ASCIIToUTF16("foo"), |
2688 base::ASCIIToUTF16("bar")), | 2697 base::ASCIIToUTF16("bar")), |
2689 "/"); | 2698 "/"); |
2690 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2699 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2691 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2700 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2692 | 2701 |
2693 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2702 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2694 BrowsingDataRemover::REMOVE_COOKIES, false); | 2703 BrowsingDataRemover::REMOVE_COOKIES, false); |
2695 | 2704 |
2696 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2705 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2697 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2706 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2698 } | 2707 } |
2699 | 2708 |
2700 // Test that removing passwords clears HTTP auth data. | 2709 // Test that removing passwords clears HTTP auth data. |
2701 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { | 2710 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { |
2702 net::HttpNetworkSession* http_session = GetProfile() | 2711 net::HttpNetworkSession* http_session = GetProfile() |
2703 ->GetRequestContext() | 2712 ->GetRequestContext() |
2704 ->GetURLRequestContext() | 2713 ->GetURLRequestContext() |
2705 ->http_transaction_factory() | 2714 ->http_transaction_factory() |
2706 ->GetSession(); | 2715 ->GetSession(); |
2707 DCHECK(http_session); | 2716 DCHECK(http_session); |
2708 | 2717 |
2709 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2718 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); |
2710 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, | 2719 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, |
2711 "test challenge", | 2720 "test challenge", |
2712 net::AuthCredentials(base::ASCIIToUTF16("foo"), | 2721 net::AuthCredentials(base::ASCIIToUTF16("foo"), |
2713 base::ASCIIToUTF16("bar")), | 2722 base::ASCIIToUTF16("bar")), |
2714 "/"); | 2723 "/"); |
2715 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2724 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2716 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2725 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2717 | 2726 |
2718 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2727 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2719 BrowsingDataRemover::REMOVE_PASSWORDS, false); | 2728 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
2720 | 2729 |
2721 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2730 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2722 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2731 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2723 } | 2732 } |
2724 | 2733 |
2725 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) { | 2734 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) { |
2726 RemovePermissionPromptCountsTest tester(GetProfile()); | 2735 RemovePermissionPromptCountsTest tester(GetProfile()); |
2727 | 2736 |
2728 RegistrableDomainFilterBuilder filter_builder_1( | 2737 RegistrableDomainFilterBuilder filter_builder_1( |
(...skipping 12 matching lines...) Expand all Loading... | |
2741 content::PermissionType::GEOLOCATION)); | 2750 content::PermissionType::GEOLOCATION)); |
2742 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2751 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2743 content::PermissionType::NOTIFICATIONS)); | 2752 content::PermissionType::NOTIFICATIONS)); |
2744 tester.ShouldChangeDismissalToBlock(kOrigin1, | 2753 tester.ShouldChangeDismissalToBlock(kOrigin1, |
2745 content::PermissionType::MIDI_SYSEX); | 2754 content::PermissionType::MIDI_SYSEX); |
2746 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, | 2755 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, |
2747 content::PermissionType::DURABLE_STORAGE)); | 2756 content::PermissionType::DURABLE_STORAGE)); |
2748 tester.ShouldChangeDismissalToBlock(kOrigin2, | 2757 tester.ShouldChangeDismissalToBlock(kOrigin2, |
2749 content::PermissionType::NOTIFICATIONS); | 2758 content::PermissionType::NOTIFICATIONS); |
2750 | 2759 |
2751 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2760 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
2752 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2761 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2753 filter_builder_1); | 2762 filter_builder_1); |
2754 | 2763 |
2755 // kOrigin1 should be gone, but kOrigin2 remains. | 2764 // kOrigin1 should be gone, but kOrigin2 remains. |
2756 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2765 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2757 content::PermissionType::GEOLOCATION)); | 2766 content::PermissionType::GEOLOCATION)); |
2758 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2767 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2759 content::PermissionType::NOTIFICATIONS)); | 2768 content::PermissionType::NOTIFICATIONS)); |
2760 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2769 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2761 content::PermissionType::MIDI_SYSEX)); | 2770 content::PermissionType::MIDI_SYSEX)); |
2762 EXPECT_EQ(1, tester.GetIgnoreCount( | 2771 EXPECT_EQ(1, tester.GetIgnoreCount( |
2763 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2772 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2764 EXPECT_EQ(1, tester.GetDismissCount( | 2773 EXPECT_EQ(1, tester.GetDismissCount( |
2765 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2774 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2766 | 2775 |
2767 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2776 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
2768 BrowsingDataRemover::REMOVE_HISTORY, false); | 2777 BrowsingDataRemover::REMOVE_HISTORY, false); |
2769 | 2778 |
2770 // Everything should be gone. | 2779 // Everything should be gone. |
2771 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2780 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2772 content::PermissionType::GEOLOCATION)); | 2781 content::PermissionType::GEOLOCATION)); |
2773 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2782 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2774 content::PermissionType::NOTIFICATIONS)); | 2783 content::PermissionType::NOTIFICATIONS)); |
2775 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2784 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2776 content::PermissionType::MIDI_SYSEX)); | 2785 content::PermissionType::MIDI_SYSEX)); |
2777 EXPECT_EQ(0, tester.GetIgnoreCount( | 2786 EXPECT_EQ(0, tester.GetIgnoreCount( |
2778 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2787 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2779 EXPECT_EQ(0, tester.GetDismissCount( | 2788 EXPECT_EQ(0, tester.GetDismissCount( |
2780 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2789 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2781 } | 2790 } |
2782 { | 2791 { |
2783 // Test REMOVE_SITE_DATA. | 2792 // Test REMOVE_SITE_DATA. |
2784 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2793 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2785 content::PermissionType::GEOLOCATION)); | 2794 content::PermissionType::GEOLOCATION)); |
2786 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, | 2795 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, |
2787 content::PermissionType::GEOLOCATION)); | 2796 content::PermissionType::GEOLOCATION)); |
2788 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2797 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2789 content::PermissionType::NOTIFICATIONS)); | 2798 content::PermissionType::NOTIFICATIONS)); |
2790 tester.ShouldChangeDismissalToBlock(kOrigin1, | 2799 tester.ShouldChangeDismissalToBlock(kOrigin1, |
2791 content::PermissionType::MIDI_SYSEX); | 2800 content::PermissionType::MIDI_SYSEX); |
2792 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, | 2801 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, |
2793 content::PermissionType::DURABLE_STORAGE)); | 2802 content::PermissionType::DURABLE_STORAGE)); |
2794 tester.ShouldChangeDismissalToBlock(kOrigin2, | 2803 tester.ShouldChangeDismissalToBlock(kOrigin2, |
2795 content::PermissionType::NOTIFICATIONS); | 2804 content::PermissionType::NOTIFICATIONS); |
2796 | 2805 |
2797 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2806 BlockUntilOriginDataRemoved(HourAgo(), base::Time::Max(), |
2798 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2807 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2799 filter_builder_2); | 2808 filter_builder_2); |
2800 | 2809 |
2801 // kOrigin2 should be gone, but kOrigin1 remains. | 2810 // kOrigin2 should be gone, but kOrigin1 remains. |
2802 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1, | 2811 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1, |
2803 content::PermissionType::GEOLOCATION)); | 2812 content::PermissionType::GEOLOCATION)); |
2804 EXPECT_EQ(1, tester.GetIgnoreCount(kOrigin1, | 2813 EXPECT_EQ(1, tester.GetIgnoreCount(kOrigin1, |
2805 content::PermissionType::NOTIFICATIONS)); | 2814 content::PermissionType::NOTIFICATIONS)); |
2806 EXPECT_EQ(1, tester.GetDismissCount(kOrigin1, | 2815 EXPECT_EQ(1, tester.GetDismissCount(kOrigin1, |
2807 content::PermissionType::MIDI_SYSEX)); | 2816 content::PermissionType::MIDI_SYSEX)); |
2808 EXPECT_EQ(0, tester.GetIgnoreCount( | 2817 EXPECT_EQ(0, tester.GetIgnoreCount( |
2809 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2818 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2810 EXPECT_EQ(0, tester.GetDismissCount( | 2819 EXPECT_EQ(0, tester.GetDismissCount( |
2811 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2820 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2812 | 2821 |
2813 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2822 BlockUntilBrowsingDataRemoved(HourAgo(), base::Time::Max(), |
2814 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2823 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2815 false); | 2824 false); |
2816 | 2825 |
2817 // Everything should be gone. | 2826 // Everything should be gone. |
2818 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2827 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2819 content::PermissionType::GEOLOCATION)); | 2828 content::PermissionType::GEOLOCATION)); |
2820 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2829 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2821 content::PermissionType::NOTIFICATIONS)); | 2830 content::PermissionType::NOTIFICATIONS)); |
2822 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2831 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2823 content::PermissionType::MIDI_SYSEX)); | 2832 content::PermissionType::MIDI_SYSEX)); |
(...skipping 13 matching lines...) Expand all Loading... | |
2837 tester.AddDomain(kOrigin3.host()); | 2846 tester.AddDomain(kOrigin3.host()); |
2838 | 2847 |
2839 std::vector<std::string> expected = { | 2848 std::vector<std::string> expected = { |
2840 kOrigin1.host(), kOrigin2.host(), kOrigin3.host() }; | 2849 kOrigin1.host(), kOrigin2.host(), kOrigin3.host() }; |
2841 EXPECT_EQ(expected, tester.GetDomains()); | 2850 EXPECT_EQ(expected, tester.GetDomains()); |
2842 | 2851 |
2843 // Delete data with a filter for the registrable domain of |kOrigin3|. | 2852 // Delete data with a filter for the registrable domain of |kOrigin3|. |
2844 RegistrableDomainFilterBuilder filter_builder( | 2853 RegistrableDomainFilterBuilder filter_builder( |
2845 RegistrableDomainFilterBuilder::WHITELIST); | 2854 RegistrableDomainFilterBuilder::WHITELIST); |
2846 filter_builder.AddRegisterableDomain(kTestRegisterableDomain3); | 2855 filter_builder.AddRegisterableDomain(kTestRegisterableDomain3); |
2847 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2856 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2848 BrowsingDataRemover::REMOVE_PLUGIN_DATA, | 2857 BrowsingDataRemover::REMOVE_PLUGIN_DATA, |
2849 filter_builder); | 2858 filter_builder); |
2850 | 2859 |
2851 // Plugin data for |kOrigin3.host()| should have been removed. | 2860 // Plugin data for |kOrigin3.host()| should have been removed. |
2852 expected.pop_back(); | 2861 expected.pop_back(); |
2853 EXPECT_EQ(expected, tester.GetDomains()); | 2862 EXPECT_EQ(expected, tester.GetDomains()); |
2854 | 2863 |
2855 // TODO(msramek): Mock PluginDataRemover and test the complete deletion | 2864 // TODO(msramek): Mock PluginDataRemover and test the complete deletion |
2856 // of plugin data as well. | 2865 // of plugin data as well. |
2857 } | 2866 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2922 new RegistrableDomainFilterBuilder( | 2931 new RegistrableDomainFilterBuilder( |
2923 RegistrableDomainFilterBuilder::BLACKLIST)); | 2932 RegistrableDomainFilterBuilder::BLACKLIST)); |
2924 filter_builder_2->AddRegisterableDomain("example.com"); | 2933 filter_builder_2->AddRegisterableDomain("example.com"); |
2925 | 2934 |
2926 MultipleTasksObserver observer(remover); | 2935 MultipleTasksObserver observer(remover); |
2927 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2936 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2928 | 2937 |
2929 // Test several tasks with various configuration of masks, filters, and target | 2938 // Test several tasks with various configuration of masks, filters, and target |
2930 // observers. | 2939 // observers. |
2931 std::list<BrowsingDataRemover::RemovalTask> tasks; | 2940 std::list<BrowsingDataRemover::RemovalTask> tasks; |
2932 tasks.emplace_back(BrowsingDataRemover::Unbounded(), | 2941 tasks.emplace_back(base::Time(), base::Time::Max(), |
2933 BrowsingDataRemover::REMOVE_HISTORY, | 2942 BrowsingDataRemover::REMOVE_HISTORY, |
2934 BrowsingDataHelper::UNPROTECTED_WEB, | 2943 BrowsingDataHelper::UNPROTECTED_WEB, |
2935 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2944 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2936 RegistrableDomainFilterBuilder::BLACKLIST), | 2945 RegistrableDomainFilterBuilder::BLACKLIST), |
2937 observer.target_a()); | 2946 observer.target_a()); |
2938 tasks.emplace_back(BrowsingDataRemover::Unbounded(), | 2947 tasks.emplace_back(base::Time(), base::Time::Max(), |
2939 BrowsingDataRemover::REMOVE_COOKIES, | 2948 BrowsingDataRemover::REMOVE_COOKIES, |
2940 BrowsingDataHelper::PROTECTED_WEB, | 2949 BrowsingDataHelper::PROTECTED_WEB, |
2941 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2950 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2942 RegistrableDomainFilterBuilder::BLACKLIST), | 2951 RegistrableDomainFilterBuilder::BLACKLIST), |
2943 nullptr); | 2952 nullptr); |
2944 tasks.emplace_back( | 2953 tasks.emplace_back( |
2945 BrowsingDataRemover::TimeRange(base::Time::Now(), base::Time::Max()), | 2954 base::Time::Now(), base::Time::Max(), |
2946 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL, | 2955 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL, |
2947 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2956 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2948 RegistrableDomainFilterBuilder::BLACKLIST), | 2957 RegistrableDomainFilterBuilder::BLACKLIST), |
2949 observer.target_b()); | 2958 observer.target_b()); |
2950 tasks.emplace_back( | 2959 tasks.emplace_back( |
2951 BrowsingDataRemover::TimeRange(base::Time(), base::Time::UnixEpoch()), | 2960 base::Time(), base::Time::UnixEpoch(), |
2952 BrowsingDataRemover::REMOVE_WEBSQL, | 2961 BrowsingDataRemover::REMOVE_WEBSQL, |
2953 BrowsingDataHelper::UNPROTECTED_WEB, | 2962 BrowsingDataHelper::UNPROTECTED_WEB, |
2954 std::move(filter_builder_1), | 2963 std::move(filter_builder_1), |
2955 observer.target_b()); | 2964 observer.target_b()); |
2956 tasks.emplace_back( | 2965 tasks.emplace_back( |
2957 BrowsingDataRemover::TimeRange( | 2966 base::Time::UnixEpoch(), base::Time::Now(), |
2958 base::Time::UnixEpoch(), base::Time::Now()), | |
2959 BrowsingDataRemover::REMOVE_CHANNEL_IDS, | 2967 BrowsingDataRemover::REMOVE_CHANNEL_IDS, |
2960 BrowsingDataHelper::ALL, | 2968 BrowsingDataHelper::ALL, |
2961 std::move(filter_builder_2), | 2969 std::move(filter_builder_2), |
2962 nullptr); | 2970 nullptr); |
2963 | 2971 |
2964 for (BrowsingDataRemover::RemovalTask& task : tasks) { | 2972 for (BrowsingDataRemover::RemovalTask& task : tasks) { |
2965 // All tasks can be directly translated to a RemoveInternal() call. Since | 2973 // All tasks can be directly translated to a RemoveInternal() call. Since |
2966 // that is a private method, we must call the four public versions of | 2974 // that is a private method, we must call the four public versions of |
2967 // Remove.* instead. This also serves as a test that those methods are all | 2975 // Remove.* instead. This also serves as a test that those methods are all |
2968 // correctly reduced to RemoveInternal(). | 2976 // correctly reduced to RemoveInternal(). |
2969 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) { | 2977 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) { |
2970 remover->Remove(task.time_range, task.remove_mask, task.origin_type_mask); | 2978 remover->Remove(task.delete_begin, task.delete_end, |
2979 task.remove_mask, task.origin_type_mask); | |
2971 } else if (task.filter_builder->IsEmptyBlacklist()) { | 2980 } else if (task.filter_builder->IsEmptyBlacklist()) { |
2972 remover->RemoveAndReply(task.time_range, task.remove_mask, | 2981 remover->RemoveAndReply(task.delete_begin, task.delete_end, |
2973 task.origin_type_mask, task.observer); | 2982 task.remove_mask, task.origin_type_mask, |
2983 task.observer); | |
2974 } else if (!task.observer) { | 2984 } else if (!task.observer) { |
2975 remover->RemoveWithFilter(task.time_range, task.remove_mask, | 2985 remover->RemoveWithFilter(task.delete_begin, task.delete_end, |
2976 task.origin_type_mask, | 2986 task.remove_mask, task.origin_type_mask, |
2977 std::move(task.filter_builder)); | 2987 std::move(task.filter_builder)); |
2978 } else { | 2988 } else { |
2979 remover->RemoveWithFilterAndReply(task.time_range, task.remove_mask, | 2989 remover->RemoveWithFilterAndReply(task.delete_begin, task.delete_end, |
2980 task.origin_type_mask, | 2990 task.remove_mask, task.origin_type_mask, |
2981 std::move(task.filter_builder), | 2991 std::move(task.filter_builder), |
2982 task.observer); | 2992 task.observer); |
2983 } | 2993 } |
2984 } | 2994 } |
2985 | 2995 |
2986 // Use the inhibitor to stop after every task and check the results. | 2996 // Use the inhibitor to stop after every task and check the results. |
2987 for (BrowsingDataRemover::RemovalTask& task : tasks) { | 2997 for (BrowsingDataRemover::RemovalTask& task : tasks) { |
2988 EXPECT_TRUE(remover->is_removing()); | 2998 EXPECT_TRUE(remover->is_removing()); |
2989 observer.ClearLastCalledTarget(); | 2999 observer.ClearLastCalledTarget(); |
2990 | 3000 |
2991 // Finish the task execution synchronously. | 3001 // Finish the task execution synchronously. |
2992 completion_inhibitor.BlockUntilNearCompletion(); | 3002 completion_inhibitor.BlockUntilNearCompletion(); |
2993 completion_inhibitor.ContinueToCompletion(); | 3003 completion_inhibitor.ContinueToCompletion(); |
2994 | 3004 |
2995 // Observers, if any, should have been called by now (since we call | 3005 // Observers, if any, should have been called by now (since we call |
2996 // observers on the same thread). | 3006 // observers on the same thread). |
2997 EXPECT_EQ(task.observer, observer.GetLastCalledTarget()); | 3007 EXPECT_EQ(task.observer, observer.GetLastCalledTarget()); |
2998 | 3008 |
2999 // TODO(msramek): If BrowsingDataRemover took ownership of the last used | 3009 // TODO(msramek): If BrowsingDataRemover took ownership of the last used |
3000 // filter builder and exposed it, we could also test it here. Make it so. | 3010 // filter builder and exposed it, we could also test it here. Make it so. |
3001 EXPECT_EQ(task.remove_mask, GetRemovalMask()); | 3011 EXPECT_EQ(task.remove_mask, GetRemovalMask()); |
3002 EXPECT_EQ(task.origin_type_mask, GetOriginTypeMask()); | 3012 EXPECT_EQ(task.origin_type_mask, GetOriginTypeMask()); |
3003 EXPECT_EQ(task.time_range.begin, GetBeginTime()); | 3013 EXPECT_EQ(task.delete_begin, GetBeginTime()); |
3004 } | 3014 } |
3005 | 3015 |
3006 EXPECT_FALSE(remover->is_removing()); | 3016 EXPECT_FALSE(remover->is_removing()); |
3007 } | 3017 } |
3008 | 3018 |
3009 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the | 3019 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the |
3010 // tasks are not mixed up and they are executed in a correct order. However, | 3020 // tasks are not mixed up and they are executed in a correct order. However, |
3011 // the completion inhibitor kept synchronizing the execution in order to verify | 3021 // the completion inhibitor kept synchronizing the execution in order to verify |
3012 // the parameters. This test demonstrates that even running the tasks without | 3022 // the parameters. This test demonstrates that even running the tasks without |
3013 // inhibition is executed correctly and doesn't crash. | 3023 // inhibition is executed correctly and doesn't crash. |
(...skipping 14 matching lines...) Expand all Loading... | |
3028 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, | 3038 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, |
3029 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, | 3039 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, |
3030 BrowsingDataRemover::REMOVE_COOKIES | | 3040 BrowsingDataRemover::REMOVE_COOKIES | |
3031 BrowsingDataRemover::REMOVE_HISTORY | | 3041 BrowsingDataRemover::REMOVE_HISTORY | |
3032 BrowsingDataRemover::REMOVE_PASSWORDS, | 3042 BrowsingDataRemover::REMOVE_PASSWORDS, |
3033 BrowsingDataRemover::REMOVE_PASSWORDS, | 3043 BrowsingDataRemover::REMOVE_PASSWORDS, |
3034 BrowsingDataRemover::REMOVE_PASSWORDS, | 3044 BrowsingDataRemover::REMOVE_PASSWORDS, |
3035 }; | 3045 }; |
3036 | 3046 |
3037 for (int removal_mask : test_removal_masks) { | 3047 for (int removal_mask : test_removal_masks) { |
3038 remover->Remove(BrowsingDataRemover::Unbounded(), removal_mask, | 3048 remover->Remove(base::Time(), base::Time::Max(), removal_mask, |
3039 BrowsingDataHelper::UNPROTECTED_WEB); | 3049 BrowsingDataHelper::UNPROTECTED_WEB); |
3040 } | 3050 } |
3041 | 3051 |
3042 EXPECT_TRUE(remover->is_removing()); | 3052 EXPECT_TRUE(remover->is_removing()); |
3043 | 3053 |
3044 // Add one more deletion and wait for it. | 3054 // Add one more deletion and wait for it. |
3045 BlockUntilBrowsingDataRemoved( | 3055 BlockUntilBrowsingDataRemoved( |
3046 browsing_data::ALL_TIME, | 3056 base::Time(), base::Time::Max(), |
3047 BrowsingDataRemover::REMOVE_COOKIES, | 3057 BrowsingDataRemover::REMOVE_COOKIES, |
3048 BrowsingDataHelper::UNPROTECTED_WEB); | 3058 BrowsingDataHelper::UNPROTECTED_WEB); |
3049 | 3059 |
3050 EXPECT_FALSE(remover->is_removing()); | 3060 EXPECT_FALSE(remover->is_removing()); |
3051 } | 3061 } |
3052 | 3062 |
3053 // Test that the remover clears bookmark meta data (normally added in a tab | 3063 // Test that the remover clears bookmark meta data (normally added in a tab |
3054 // helper). | 3064 // helper). |
3055 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { | 3065 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { |
3056 TestingProfile profile; | 3066 TestingProfile profile; |
(...skipping 23 matching lines...) Expand all Loading... | |
3080 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( | 3090 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
3081 bookmark_model, 2, base::Time::UnixEpoch(), | 3091 bookmark_model, 2, base::Time::UnixEpoch(), |
3082 /*consider_visits_from_desktop=*/false), | 3092 /*consider_visits_from_desktop=*/false), |
3083 Not(IsEmpty())); | 3093 Not(IsEmpty())); |
3084 | 3094 |
3085 // Inject the bookmark model into the remover. | 3095 // Inject the bookmark model into the remover. |
3086 BrowsingDataRemover* remover = | 3096 BrowsingDataRemover* remover = |
3087 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); | 3097 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); |
3088 | 3098 |
3089 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 3099 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
3090 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 3100 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
3091 BrowsingDataRemover::REMOVE_HISTORY, | 3101 BrowsingDataRemover::REMOVE_HISTORY, |
3092 BrowsingDataHelper::ALL, &completion_observer); | 3102 BrowsingDataHelper::ALL, &completion_observer); |
3093 completion_observer.BlockUntilCompletion(); | 3103 completion_observer.BlockUntilCompletion(); |
3094 | 3104 |
3095 // There should be no recently visited bookmarks. | 3105 // There should be no recently visited bookmarks. |
3096 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( | 3106 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
3097 bookmark_model, 2, base::Time::UnixEpoch(), | 3107 bookmark_model, 2, base::Time::UnixEpoch(), |
3098 /*consider_visits_from_desktop=*/false), | 3108 /*consider_visits_from_desktop=*/false), |
3099 IsEmpty()); | 3109 IsEmpty()); |
3100 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( | 3110 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
3101 bookmark_model, 2, base::Time::UnixEpoch(), | 3111 bookmark_model, 2, base::Time::UnixEpoch(), |
3102 /*consider_visits_from_desktop=*/true), | 3112 /*consider_visits_from_desktop=*/true), |
3103 IsEmpty()); | 3113 IsEmpty()); |
3104 } | 3114 } |
OLD | NEW |