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 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
393 const base::Callback<bool(const GURL&)>& filter) { | 393 const base::Callback<bool(const GURL&)>& filter) { |
394 return MakeMatcher(new ProbablySameFilterMatcher(filter)); | 394 return MakeMatcher(new ProbablySameFilterMatcher(filter)); |
395 } | 395 } |
396 | 396 |
397 bool ProbablySameFilters( | 397 bool ProbablySameFilters( |
398 const base::Callback<bool(const GURL&)>& filter1, | 398 const base::Callback<bool(const GURL&)>& filter1, |
399 const base::Callback<bool(const GURL&)>& filter2) { | 399 const base::Callback<bool(const GURL&)>& filter2) { |
400 return ProbablySameFilter(filter1).MatchAndExplain(filter2, nullptr); | 400 return ProbablySameFilter(filter1).MatchAndExplain(filter2, nullptr); |
401 } | 401 } |
402 | 402 |
| 403 base::Time AnHourAgo() { |
| 404 return base::Time::Now() - base::TimeDelta::FromHours(1); |
| 405 } |
| 406 |
403 } // namespace | 407 } // namespace |
404 | 408 |
405 // Testers ------------------------------------------------------------------- | 409 // Testers ------------------------------------------------------------------- |
406 | 410 |
407 class RemoveCookieTester { | 411 class RemoveCookieTester { |
408 public: | 412 public: |
409 RemoveCookieTester() {} | 413 RemoveCookieTester() {} |
410 | 414 |
411 // Returns true, if the given cookie exists in the cookie store. | 415 // Returns true, if the given cookie exists in the cookie store. |
412 bool ContainsCookie() { | 416 bool ContainsCookie() { |
(...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 // posts a message to the WEBKIT thread to delete some of its member | 1167 // posts a message to the WEBKIT thread to delete some of its member |
1164 // variables. We need to ensure that the profile is destroyed, and that | 1168 // variables. We need to ensure that the profile is destroyed, and that |
1165 // the message loop is cleared out, before destroying the threads and loop. | 1169 // the message loop is cleared out, before destroying the threads and loop. |
1166 // Otherwise we leak memory. | 1170 // Otherwise we leak memory. |
1167 profile_.reset(); | 1171 profile_.reset(); |
1168 base::RunLoop().RunUntilIdle(); | 1172 base::RunLoop().RunUntilIdle(); |
1169 | 1173 |
1170 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); | 1174 TestingBrowserProcess::GetGlobal()->SetLocalState(nullptr); |
1171 } | 1175 } |
1172 | 1176 |
1173 void BlockUntilBrowsingDataRemoved(browsing_data::TimePeriod period, | 1177 void BlockUntilBrowsingDataRemoved(const base::Time& delete_begin, |
| 1178 const base::Time& delete_end, |
1174 int remove_mask, | 1179 int remove_mask, |
1175 bool include_protected_origins) { | 1180 bool include_protected_origins) { |
1176 BrowsingDataRemover* remover = | 1181 BrowsingDataRemover* remover = |
1177 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1182 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
1178 | 1183 |
1179 TestStoragePartition storage_partition; | 1184 TestStoragePartition storage_partition; |
1180 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1185 remover->OverrideStoragePartitionForTesting(&storage_partition); |
1181 | 1186 |
1182 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB; | 1187 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB; |
1183 if (include_protected_origins) | 1188 if (include_protected_origins) |
1184 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB; | 1189 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB; |
1185 | 1190 |
1186 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1191 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
1187 remover->RemoveAndReply(BrowsingDataRemover::Period(period), remove_mask, | 1192 remover->RemoveAndReply( |
1188 origin_type_mask, &completion_observer); | 1193 delete_begin, delete_end, remove_mask, origin_type_mask, |
| 1194 &completion_observer); |
1189 completion_observer.BlockUntilCompletion(); | 1195 completion_observer.BlockUntilCompletion(); |
1190 | 1196 |
1191 // Save so we can verify later. | 1197 // Save so we can verify later. |
1192 storage_partition_removal_data_ = | 1198 storage_partition_removal_data_ = |
1193 storage_partition.GetStoragePartitionRemovalData(); | 1199 storage_partition.GetStoragePartitionRemovalData(); |
1194 } | 1200 } |
1195 | 1201 |
1196 void BlockUntilOriginDataRemoved( | 1202 void BlockUntilOriginDataRemoved( |
1197 browsing_data::TimePeriod period, | 1203 const base::Time& delete_begin, |
| 1204 const base::Time& delete_end, |
1198 int remove_mask, | 1205 int remove_mask, |
1199 const BrowsingDataFilterBuilder& filter_builder) { | 1206 const BrowsingDataFilterBuilder& filter_builder) { |
1200 BrowsingDataRemover* remover = | 1207 BrowsingDataRemover* remover = |
1201 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1208 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
1202 TestStoragePartition storage_partition; | 1209 TestStoragePartition storage_partition; |
1203 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1210 remover->OverrideStoragePartitionForTesting(&storage_partition); |
1204 | 1211 |
1205 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 1212 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
1206 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1213 remover->RemoveImpl(delete_begin, delete_end, remove_mask, filter_builder, |
1207 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); | 1214 BrowsingDataHelper::UNPROTECTED_WEB); |
1208 completion_inhibitor.BlockUntilNearCompletion(); | 1215 completion_inhibitor.BlockUntilNearCompletion(); |
1209 completion_inhibitor.ContinueToCompletion(); | 1216 completion_inhibitor.ContinueToCompletion(); |
1210 | 1217 |
1211 // Save so we can verify later. | 1218 // Save so we can verify later. |
1212 storage_partition_removal_data_ = | 1219 storage_partition_removal_data_ = |
1213 storage_partition.GetStoragePartitionRemovalData(); | 1220 storage_partition.GetStoragePartitionRemovalData(); |
1214 } | 1221 } |
1215 | 1222 |
1216 TestingProfile* GetProfile() { | 1223 TestingProfile* GetProfile() { |
1217 return profile_.get(); | 1224 return profile_.get(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1282 | 1289 |
1283 // Needed to mock out DomainReliabilityService, even for unrelated tests. | 1290 // Needed to mock out DomainReliabilityService, even for unrelated tests. |
1284 ClearDomainReliabilityTester clear_domain_reliability_tester_; | 1291 ClearDomainReliabilityTester clear_domain_reliability_tester_; |
1285 | 1292 |
1286 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); | 1293 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); |
1287 }; | 1294 }; |
1288 | 1295 |
1289 // Tests --------------------------------------------------------------------- | 1296 // Tests --------------------------------------------------------------------- |
1290 | 1297 |
1291 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { | 1298 TEST_F(BrowsingDataRemoverTest, RemoveCookieForever) { |
1292 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1299 BlockUntilBrowsingDataRemoved(base::Time(), 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 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1309 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1303 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1310 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1304 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1311 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1305 } | 1312 } |
1306 | 1313 |
1307 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1314 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
1308 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1315 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
1309 BrowsingDataRemover::REMOVE_COOKIES, false); | 1316 BrowsingDataRemover::REMOVE_COOKIES, false); |
1310 | 1317 |
1311 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1318 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1312 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1319 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1313 | 1320 |
1314 // Verify that storage partition was instructed to remove the cookies. | 1321 // Verify that storage partition was instructed to remove the cookies. |
1315 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1322 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1316 EXPECT_EQ(removal_data.remove_mask, | 1323 EXPECT_EQ(removal_data.remove_mask, |
1317 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1324 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1318 // Removing with time period other than ALL_TIME should not clear | 1325 // Removing with time period other than all time should not clear |
1319 // persistent storage data. | 1326 // persistent storage data. |
1320 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1327 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1321 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1328 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1322 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1329 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1323 } | 1330 } |
1324 | 1331 |
1325 TEST_F(BrowsingDataRemoverTest, RemoveCookiesDomainBlacklist) { | 1332 TEST_F(BrowsingDataRemoverTest, RemoveCookiesDomainBlacklist) { |
1326 RegistrableDomainFilterBuilder filter( | 1333 RegistrableDomainFilterBuilder filter( |
1327 RegistrableDomainFilterBuilder::BLACKLIST); | 1334 RegistrableDomainFilterBuilder::BLACKLIST); |
1328 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 1335 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
1329 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 1336 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
1330 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 1337 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
1331 BrowsingDataRemover::REMOVE_COOKIES, filter); | 1338 BrowsingDataRemover::REMOVE_COOKIES, filter); |
1332 | 1339 |
1333 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1340 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1334 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1341 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1335 | 1342 |
1336 // Verify that storage partition was instructed to remove the cookies. | 1343 // Verify that storage partition was instructed to remove the cookies. |
1337 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1344 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1338 EXPECT_EQ(removal_data.remove_mask, | 1345 EXPECT_EQ(removal_data.remove_mask, |
1339 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1346 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1340 // Removing with time period other than ALL_TIME should not clear | 1347 // Removing with time period other than all time should not clear |
1341 // persistent storage data. | 1348 // persistent storage data. |
1342 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1349 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1343 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1350 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1344 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1351 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1345 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1352 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1346 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1353 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1347 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1354 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1348 // Even though it's a different origin, it's the same domain. | 1355 // Even though it's a different origin, it's the same domain. |
1349 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); | 1356 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
1350 | 1357 |
1351 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); | 1358 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); |
1352 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); | 1359 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); |
1353 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); | 1360 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); |
1354 // This is false, because this is the same domain as 3, just with a different | 1361 // This is false, because this is the same domain as 3, just with a different |
1355 // scheme. | 1362 // scheme. |
1356 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); | 1363 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); |
1357 } | 1364 } |
1358 | 1365 |
1359 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1366 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
1360 RemoveSafeBrowsingCookieTester tester; | 1367 RemoveSafeBrowsingCookieTester tester; |
1361 | 1368 |
1362 tester.AddCookie(); | 1369 tester.AddCookie(); |
1363 ASSERT_TRUE(tester.ContainsCookie()); | 1370 ASSERT_TRUE(tester.ContainsCookie()); |
1364 | 1371 |
1365 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1372 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1366 BrowsingDataRemover::REMOVE_COOKIES, false); | 1373 BrowsingDataRemover::REMOVE_COOKIES, false); |
1367 | 1374 |
1368 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1375 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1369 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1376 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1370 EXPECT_FALSE(tester.ContainsCookie()); | 1377 EXPECT_FALSE(tester.ContainsCookie()); |
1371 } | 1378 } |
1372 | 1379 |
1373 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) { | 1380 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieLastHour) { |
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 | 1385 |
1379 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1386 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
1380 BrowsingDataRemover::REMOVE_COOKIES, false); | 1387 BrowsingDataRemover::REMOVE_COOKIES, false); |
1381 | 1388 |
1382 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1389 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1383 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1390 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1384 // Removing with time period other than ALL_TIME should not clear safe | 1391 // Removing with time period other than all time should not clear safe |
1385 // browsing cookies. | 1392 // browsing cookies. |
1386 EXPECT_TRUE(tester.ContainsCookie()); | 1393 EXPECT_TRUE(tester.ContainsCookie()); |
1387 } | 1394 } |
1388 | 1395 |
1389 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { | 1396 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { |
1390 RemoveSafeBrowsingCookieTester tester; | 1397 RemoveSafeBrowsingCookieTester tester; |
1391 | 1398 |
1392 tester.AddCookie(); | 1399 tester.AddCookie(); |
1393 ASSERT_TRUE(tester.ContainsCookie()); | 1400 ASSERT_TRUE(tester.ContainsCookie()); |
1394 RegistrableDomainFilterBuilder filter( | 1401 RegistrableDomainFilterBuilder filter( |
1395 RegistrableDomainFilterBuilder::BLACKLIST); | 1402 RegistrableDomainFilterBuilder::BLACKLIST); |
1396 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 1403 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
1397 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1404 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1398 BrowsingDataRemover::REMOVE_COOKIES, filter); | 1405 BrowsingDataRemover::REMOVE_COOKIES, filter); |
1399 | 1406 |
1400 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1407 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1401 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1408 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1402 EXPECT_TRUE(tester.ContainsCookie()); | 1409 EXPECT_TRUE(tester.ContainsCookie()); |
1403 | 1410 |
1404 RegistrableDomainFilterBuilder filter2( | 1411 RegistrableDomainFilterBuilder filter2( |
1405 RegistrableDomainFilterBuilder::WHITELIST); | 1412 RegistrableDomainFilterBuilder::WHITELIST); |
1406 filter2.AddRegisterableDomain(kTestRegisterableDomain1); | 1413 filter2.AddRegisterableDomain(kTestRegisterableDomain1); |
1407 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1414 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1408 BrowsingDataRemover::REMOVE_COOKIES, filter2); | 1415 BrowsingDataRemover::REMOVE_COOKIES, filter2); |
1409 EXPECT_FALSE(tester.ContainsCookie()); | 1416 EXPECT_FALSE(tester.ContainsCookie()); |
1410 } | 1417 } |
1411 | 1418 |
1412 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { | 1419 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { |
1413 RemoveChannelIDTester tester(GetProfile()); | 1420 RemoveChannelIDTester tester(GetProfile()); |
1414 | 1421 |
1415 tester.AddChannelID(kTestOrigin1); | 1422 tester.AddChannelID(kTestOrigin1); |
1416 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1423 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
1417 EXPECT_EQ(1, tester.ChannelIDCount()); | 1424 EXPECT_EQ(1, tester.ChannelIDCount()); |
1418 | 1425 |
1419 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1426 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1420 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1427 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
1421 | 1428 |
1422 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); | 1429 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); |
1423 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1430 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1424 EXPECT_EQ(1, tester.ssl_config_changed_count()); | 1431 EXPECT_EQ(1, tester.ssl_config_changed_count()); |
1425 EXPECT_EQ(0, tester.ChannelIDCount()); | 1432 EXPECT_EQ(0, tester.ChannelIDCount()); |
1426 } | 1433 } |
1427 | 1434 |
1428 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) { | 1435 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDLastHour) { |
1429 RemoveChannelIDTester tester(GetProfile()); | 1436 RemoveChannelIDTester tester(GetProfile()); |
1430 | 1437 |
1431 base::Time now = base::Time::Now(); | 1438 base::Time now = base::Time::Now(); |
1432 tester.AddChannelID(kTestOrigin1); | 1439 tester.AddChannelID(kTestOrigin1); |
1433 tester.AddChannelIDWithTimes(kTestOrigin2, | 1440 tester.AddChannelIDWithTimes(kTestOrigin2, |
1434 now - base::TimeDelta::FromHours(2)); | 1441 now - base::TimeDelta::FromHours(2)); |
1435 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1442 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
1436 EXPECT_EQ(2, tester.ChannelIDCount()); | 1443 EXPECT_EQ(2, tester.ChannelIDCount()); |
1437 | 1444 |
1438 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1445 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
1439 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1446 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
1440 | 1447 |
1441 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); | 1448 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); |
1442 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1449 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1443 EXPECT_EQ(1, tester.ssl_config_changed_count()); | 1450 EXPECT_EQ(1, tester.ssl_config_changed_count()); |
1444 ASSERT_EQ(1, tester.ChannelIDCount()); | 1451 ASSERT_EQ(1, tester.ChannelIDCount()); |
1445 net::ChannelIDStore::ChannelIDList channel_ids; | 1452 net::ChannelIDStore::ChannelIDList channel_ids; |
1446 tester.GetChannelIDList(&channel_ids); | 1453 tester.GetChannelIDList(&channel_ids); |
1447 ASSERT_EQ(1U, channel_ids.size()); | 1454 ASSERT_EQ(1U, channel_ids.size()); |
1448 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier()); | 1455 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier()); |
1449 } | 1456 } |
1450 | 1457 |
1451 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDsForServerIdentifiers) { | 1458 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDsForServerIdentifiers) { |
1452 RemoveChannelIDTester tester(GetProfile()); | 1459 RemoveChannelIDTester tester(GetProfile()); |
1453 | 1460 |
1454 tester.AddChannelID(kTestRegisterableDomain1); | 1461 tester.AddChannelID(kTestRegisterableDomain1); |
1455 tester.AddChannelID(kTestRegisterableDomain3); | 1462 tester.AddChannelID(kTestRegisterableDomain3); |
1456 EXPECT_EQ(2, tester.ChannelIDCount()); | 1463 EXPECT_EQ(2, tester.ChannelIDCount()); |
1457 | 1464 |
1458 RegistrableDomainFilterBuilder filter_builder( | 1465 RegistrableDomainFilterBuilder filter_builder( |
1459 RegistrableDomainFilterBuilder::WHITELIST); | 1466 RegistrableDomainFilterBuilder::WHITELIST); |
1460 filter_builder.AddRegisterableDomain(kTestRegisterableDomain1); | 1467 filter_builder.AddRegisterableDomain(kTestRegisterableDomain1); |
1461 | 1468 |
1462 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1469 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1463 BrowsingDataRemover::REMOVE_CHANNEL_IDS, | 1470 BrowsingDataRemover::REMOVE_CHANNEL_IDS, |
1464 filter_builder); | 1471 filter_builder); |
1465 | 1472 |
1466 EXPECT_EQ(1, tester.ChannelIDCount()); | 1473 EXPECT_EQ(1, tester.ChannelIDCount()); |
1467 net::ChannelIDStore::ChannelIDList channel_ids; | 1474 net::ChannelIDStore::ChannelIDList channel_ids; |
1468 tester.GetChannelIDList(&channel_ids); | 1475 tester.GetChannelIDList(&channel_ids); |
1469 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); | 1476 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); |
1470 } | 1477 } |
1471 | 1478 |
1472 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { | 1479 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { |
1473 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1480 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1474 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1481 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1475 // Protect kOrigin1. | 1482 // Protect kOrigin1. |
1476 policy->AddProtected(kOrigin1.GetOrigin()); | 1483 policy->AddProtected(kOrigin1.GetOrigin()); |
1477 #endif | 1484 #endif |
1478 | 1485 |
1479 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1486 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1480 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1487 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
1481 false); | 1488 false); |
1482 | 1489 |
1483 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1490 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1484 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1491 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1485 | 1492 |
1486 // Verify that storage partition was instructed to remove the data correctly. | 1493 // Verify that storage partition was instructed to remove the data correctly. |
1487 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1494 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1488 EXPECT_EQ(removal_data.remove_mask, | 1495 EXPECT_EQ(removal_data.remove_mask, |
1489 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1496 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1490 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1497 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1491 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1498 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1492 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1499 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1493 | 1500 |
1494 // Check origin matcher. | 1501 // Check origin matcher. |
1495 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1502 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
1496 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1503 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1497 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1504 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1498 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1505 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1499 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1506 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1500 } | 1507 } |
1501 | 1508 |
1502 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) { | 1509 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) { |
1503 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1510 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1504 // Protect kOrigin1. | 1511 // Protect kOrigin1. |
1505 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1512 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1506 policy->AddProtected(kOrigin1.GetOrigin()); | 1513 policy->AddProtected(kOrigin1.GetOrigin()); |
1507 #endif | 1514 #endif |
1508 | 1515 |
1509 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1516 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1510 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1517 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
1511 true); | 1518 true); |
1512 | 1519 |
1513 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1520 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1514 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1521 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
1515 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1522 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
1516 | 1523 |
1517 // Verify that storage partition was instructed to remove the data correctly. | 1524 // Verify that storage partition was instructed to remove the data correctly. |
1518 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1525 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1519 EXPECT_EQ(removal_data.remove_mask, | 1526 EXPECT_EQ(removal_data.remove_mask, |
1520 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1527 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1521 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1528 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1522 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1529 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1523 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1530 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1524 | 1531 |
1525 // Check origin matcher all http origin will match since we specified | 1532 // Check origin matcher all http origin will match since we specified |
1526 // both protected and unprotected. | 1533 // both protected and unprotected. |
1527 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1534 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1528 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1535 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1529 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1536 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1530 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1537 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1531 } | 1538 } |
1532 | 1539 |
1533 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1540 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
1534 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1541 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1535 CreateMockPolicy(); | 1542 CreateMockPolicy(); |
1536 #endif | 1543 #endif |
1537 | 1544 |
1538 BlockUntilBrowsingDataRemoved(browsing_data::LAST_WEEK, | 1545 BlockUntilBrowsingDataRemoved( |
1539 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1546 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), |
1540 false); | 1547 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, false); |
1541 | 1548 |
1542 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1549 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1543 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1550 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1544 | 1551 |
1545 // Verify that storage partition was instructed to remove the data correctly. | 1552 // Verify that storage partition was instructed to remove the data correctly. |
1546 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1553 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1547 EXPECT_EQ(removal_data.remove_mask, | 1554 EXPECT_EQ(removal_data.remove_mask, |
1548 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1555 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1549 // Persistent storage won't be deleted. | 1556 // Persistent storage won't be deleted. |
1550 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1557 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1551 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1558 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1552 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1559 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1553 | 1560 |
1554 // Check origin matcher. | 1561 // Check origin matcher. |
1555 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1562 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1556 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1563 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1557 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1564 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1558 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1565 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1559 } | 1566 } |
1560 | 1567 |
1561 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1568 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
1562 RemoveHistoryTester tester; | 1569 RemoveHistoryTester tester; |
1563 ASSERT_TRUE(tester.Init(GetProfile())); | 1570 ASSERT_TRUE(tester.Init(GetProfile())); |
1564 | 1571 |
1565 tester.AddHistory(kOrigin1, base::Time::Now()); | 1572 tester.AddHistory(kOrigin1, base::Time::Now()); |
1566 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1573 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1567 | 1574 |
1568 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1575 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1569 BrowsingDataRemover::REMOVE_HISTORY, false); | 1576 BrowsingDataRemover::REMOVE_HISTORY, false); |
1570 | 1577 |
1571 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1578 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1572 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1579 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1573 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 1580 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
1574 } | 1581 } |
1575 | 1582 |
1576 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { | 1583 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForLastHour) { |
1577 RemoveHistoryTester tester; | 1584 RemoveHistoryTester tester; |
1578 ASSERT_TRUE(tester.Init(GetProfile())); | 1585 ASSERT_TRUE(tester.Init(GetProfile())); |
1579 | 1586 |
1580 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 1587 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
1581 | 1588 |
1582 tester.AddHistory(kOrigin1, base::Time::Now()); | 1589 tester.AddHistory(kOrigin1, base::Time::Now()); |
1583 tester.AddHistory(kOrigin2, two_hours_ago); | 1590 tester.AddHistory(kOrigin2, two_hours_ago); |
1584 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1591 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1585 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1592 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1586 | 1593 |
1587 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1594 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
1588 BrowsingDataRemover::REMOVE_HISTORY, false); | 1595 BrowsingDataRemover::REMOVE_HISTORY, false); |
1589 | 1596 |
1590 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1597 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1591 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1598 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1592 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 1599 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
1593 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1600 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1594 } | 1601 } |
1595 | 1602 |
1596 // This should crash (DCHECK) in Debug, but death tests don't work properly | 1603 // This should crash (DCHECK) in Debug, but death tests don't work properly |
1597 // here. | 1604 // here. |
1598 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) | 1605 #if defined(NDEBUG) && !defined(DCHECK_ALWAYS_ON) |
1599 TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) { | 1606 TEST_F(BrowsingDataRemoverTest, RemoveHistoryProhibited) { |
1600 RemoveHistoryTester tester; | 1607 RemoveHistoryTester tester; |
1601 ASSERT_TRUE(tester.Init(GetProfile())); | 1608 ASSERT_TRUE(tester.Init(GetProfile())); |
1602 PrefService* prefs = GetProfile()->GetPrefs(); | 1609 PrefService* prefs = GetProfile()->GetPrefs(); |
1603 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); | 1610 prefs->SetBoolean(prefs::kAllowDeletingBrowserHistory, false); |
1604 | 1611 |
1605 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 1612 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
1606 | 1613 |
1607 tester.AddHistory(kOrigin1, base::Time::Now()); | 1614 tester.AddHistory(kOrigin1, base::Time::Now()); |
1608 tester.AddHistory(kOrigin2, two_hours_ago); | 1615 tester.AddHistory(kOrigin2, two_hours_ago); |
1609 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1616 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1610 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1617 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1611 | 1618 |
1612 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 1619 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
1613 BrowsingDataRemover::REMOVE_HISTORY, false); | 1620 BrowsingDataRemover::REMOVE_HISTORY, false); |
1614 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1621 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1615 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1622 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1616 | 1623 |
1617 // Nothing should have been deleted. | 1624 // Nothing should have been deleted. |
1618 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 1625 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1619 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 1626 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1620 } | 1627 } |
1621 #endif | 1628 #endif |
1622 | 1629 |
1623 TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) { | 1630 TEST_F(BrowsingDataRemoverTest, RemoveMultipleTypes) { |
1624 // Add some history. | 1631 // Add some history. |
1625 RemoveHistoryTester history_tester; | 1632 RemoveHistoryTester history_tester; |
1626 ASSERT_TRUE(history_tester.Init(GetProfile())); | 1633 ASSERT_TRUE(history_tester.Init(GetProfile())); |
1627 history_tester.AddHistory(kOrigin1, base::Time::Now()); | 1634 history_tester.AddHistory(kOrigin1, base::Time::Now()); |
1628 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1635 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1629 | 1636 |
1630 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | | 1637 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | |
1631 BrowsingDataRemover::REMOVE_COOKIES; | 1638 BrowsingDataRemover::REMOVE_COOKIES; |
1632 | 1639 |
1633 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, removal_mask, false); | 1640 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
| 1641 removal_mask, false); |
1634 | 1642 |
1635 EXPECT_EQ(removal_mask, GetRemovalMask()); | 1643 EXPECT_EQ(removal_mask, GetRemovalMask()); |
1636 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1644 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1637 EXPECT_FALSE(history_tester.HistoryContainsURL(kOrigin1)); | 1645 EXPECT_FALSE(history_tester.HistoryContainsURL(kOrigin1)); |
1638 | 1646 |
1639 // The cookie would be deleted throught the StorageParition, check if the | 1647 // The cookie would be deleted throught the StorageParition, check if the |
1640 // partition was requested to remove cookie. | 1648 // partition was requested to remove cookie. |
1641 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1649 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1642 EXPECT_EQ(removal_data.remove_mask, | 1650 EXPECT_EQ(removal_data.remove_mask, |
1643 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1651 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
(...skipping 10 matching lines...) Expand all Loading... |
1654 | 1662 |
1655 // Add some history. | 1663 // Add some history. |
1656 RemoveHistoryTester history_tester; | 1664 RemoveHistoryTester history_tester; |
1657 ASSERT_TRUE(history_tester.Init(GetProfile())); | 1665 ASSERT_TRUE(history_tester.Init(GetProfile())); |
1658 history_tester.AddHistory(kOrigin1, base::Time::Now()); | 1666 history_tester.AddHistory(kOrigin1, base::Time::Now()); |
1659 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1667 ASSERT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1660 | 1668 |
1661 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | | 1669 int removal_mask = BrowsingDataRemover::REMOVE_HISTORY | |
1662 BrowsingDataRemover::REMOVE_COOKIES; | 1670 BrowsingDataRemover::REMOVE_COOKIES; |
1663 | 1671 |
1664 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, removal_mask, false); | 1672 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
| 1673 removal_mask, false); |
1665 EXPECT_EQ(removal_mask, GetRemovalMask()); | 1674 EXPECT_EQ(removal_mask, GetRemovalMask()); |
1666 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1675 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1667 | 1676 |
1668 // 1/2. History should remain. | 1677 // 1/2. History should remain. |
1669 EXPECT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); | 1678 EXPECT_TRUE(history_tester.HistoryContainsURL(kOrigin1)); |
1670 | 1679 |
1671 // 2/2. The cookie(s) would be deleted throught the StorageParition, check if | 1680 // 2/2. The cookie(s) would be deleted throught the StorageParition, check if |
1672 // the partition was requested to remove cookie. | 1681 // the partition was requested to remove cookie. |
1673 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1682 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1674 EXPECT_EQ(removal_data.remove_mask, | 1683 EXPECT_EQ(removal_data.remove_mask, |
1675 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1684 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1676 // Persistent storage won't be deleted, since ALL_TIME was not specified. | 1685 // Persistent storage won't be deleted, since the time period is not all time. |
1677 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1686 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1678 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1687 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1679 } | 1688 } |
1680 #endif | 1689 #endif |
1681 | 1690 |
1682 // Test that clearing history deletes favicons not associated with bookmarks. | 1691 // Test that clearing history deletes favicons not associated with bookmarks. |
1683 TEST_F(BrowsingDataRemoverTest, RemoveFaviconsForever) { | 1692 TEST_F(BrowsingDataRemoverTest, RemoveFaviconsForever) { |
1684 GURL page_url("http://a"); | 1693 GURL page_url("http://a"); |
1685 | 1694 |
1686 RemoveFaviconTester favicon_tester; | 1695 RemoveFaviconTester favicon_tester; |
1687 ASSERT_TRUE(favicon_tester.Init(GetProfile())); | 1696 ASSERT_TRUE(favicon_tester.Init(GetProfile())); |
1688 favicon_tester.VisitAndAddFavicon(page_url); | 1697 favicon_tester.VisitAndAddFavicon(page_url); |
1689 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(page_url)); | 1698 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(page_url)); |
1690 | 1699 |
1691 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1700 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1692 BrowsingDataRemover::REMOVE_HISTORY, false); | 1701 BrowsingDataRemover::REMOVE_HISTORY, false); |
1693 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1702 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1694 EXPECT_FALSE(favicon_tester.HasFaviconForPageURL(page_url)); | 1703 EXPECT_FALSE(favicon_tester.HasFaviconForPageURL(page_url)); |
1695 } | 1704 } |
1696 | 1705 |
1697 // Test that a bookmark's favicon is expired and not deleted when clearing | 1706 // Test that a bookmark's favicon is expired and not deleted when clearing |
1698 // history. Expiring the favicon causes the bookmark's favicon to be updated | 1707 // history. Expiring the favicon causes the bookmark's favicon to be updated |
1699 // when the user next visits the bookmarked page. Expiring the bookmark's | 1708 // when the user next visits the bookmarked page. Expiring the bookmark's |
1700 // favicon is useful when the bookmark's favicon becomes incorrect (See | 1709 // favicon is useful when the bookmark's favicon becomes incorrect (See |
1701 // crbug.com/474421 for a sample bug which causes this). | 1710 // crbug.com/474421 for a sample bug which causes this). |
1702 TEST_F(BrowsingDataRemoverTest, ExpireBookmarkFavicons) { | 1711 TEST_F(BrowsingDataRemoverTest, ExpireBookmarkFavicons) { |
1703 GURL bookmarked_page("http://a"); | 1712 GURL bookmarked_page("http://a"); |
1704 | 1713 |
1705 TestingProfile* profile = GetProfile(); | 1714 TestingProfile* profile = GetProfile(); |
1706 profile->CreateBookmarkModel(true); | 1715 profile->CreateBookmarkModel(true); |
1707 bookmarks::BookmarkModel* bookmark_model = | 1716 bookmarks::BookmarkModel* bookmark_model = |
1708 BookmarkModelFactory::GetForBrowserContext(profile); | 1717 BookmarkModelFactory::GetForBrowserContext(profile); |
1709 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 1718 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
1710 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, | 1719 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 0, |
1711 base::ASCIIToUTF16("a"), bookmarked_page); | 1720 base::ASCIIToUTF16("a"), bookmarked_page); |
1712 | 1721 |
1713 RemoveFaviconTester favicon_tester; | 1722 RemoveFaviconTester favicon_tester; |
1714 ASSERT_TRUE(favicon_tester.Init(GetProfile())); | 1723 ASSERT_TRUE(favicon_tester.Init(GetProfile())); |
1715 favicon_tester.VisitAndAddFavicon(bookmarked_page); | 1724 favicon_tester.VisitAndAddFavicon(bookmarked_page); |
1716 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(bookmarked_page)); | 1725 ASSERT_TRUE(favicon_tester.HasFaviconForPageURL(bookmarked_page)); |
1717 | 1726 |
1718 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 1727 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
1719 BrowsingDataRemover::REMOVE_HISTORY, false); | 1728 BrowsingDataRemover::REMOVE_HISTORY, false); |
1720 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 1729 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1721 EXPECT_TRUE(favicon_tester.HasExpiredFaviconForPageURL(bookmarked_page)); | 1730 EXPECT_TRUE(favicon_tester.HasExpiredFaviconForPageURL(bookmarked_page)); |
1722 } | 1731 } |
1723 | 1732 |
1724 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { | 1733 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverBoth) { |
1725 BlockUntilBrowsingDataRemoved( | 1734 BlockUntilBrowsingDataRemoved( |
1726 browsing_data::ALL_TIME, | 1735 base::Time(), base::Time::Max(), |
1727 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1736 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1728 BrowsingDataRemover::REMOVE_WEBSQL | | 1737 BrowsingDataRemover::REMOVE_WEBSQL | |
1729 BrowsingDataRemover::REMOVE_APPCACHE | | 1738 BrowsingDataRemover::REMOVE_APPCACHE | |
1730 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1739 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1731 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1740 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1732 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1741 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1733 false); | 1742 false); |
1734 | 1743 |
1735 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1744 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1736 BrowsingDataRemover::REMOVE_WEBSQL | | 1745 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 16 matching lines...) Expand all Loading... |
1753 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1762 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1754 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1763 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1755 } | 1764 } |
1756 | 1765 |
1757 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1766 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
1758 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1767 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1759 CreateMockPolicy(); | 1768 CreateMockPolicy(); |
1760 #endif | 1769 #endif |
1761 | 1770 |
1762 BlockUntilBrowsingDataRemoved( | 1771 BlockUntilBrowsingDataRemoved( |
1763 browsing_data::ALL_TIME, | 1772 base::Time(), base::Time::Max(), |
1764 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1773 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1765 BrowsingDataRemover::REMOVE_WEBSQL | | 1774 BrowsingDataRemover::REMOVE_WEBSQL | |
1766 BrowsingDataRemover::REMOVE_APPCACHE | | 1775 BrowsingDataRemover::REMOVE_APPCACHE | |
1767 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1776 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1768 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1777 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1769 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1778 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1770 false); | 1779 false); |
1771 | 1780 |
1772 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1781 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1773 BrowsingDataRemover::REMOVE_WEBSQL | | 1782 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 23 matching lines...) Expand all Loading... |
1797 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1806 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1798 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1807 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1799 } | 1808 } |
1800 | 1809 |
1801 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1810 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
1802 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1811 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1803 CreateMockPolicy(); | 1812 CreateMockPolicy(); |
1804 #endif | 1813 #endif |
1805 | 1814 |
1806 BlockUntilBrowsingDataRemoved( | 1815 BlockUntilBrowsingDataRemoved( |
1807 browsing_data::ALL_TIME, | 1816 base::Time(), base::Time::Max(), |
1808 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1817 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1809 BrowsingDataRemover::REMOVE_WEBSQL | | 1818 BrowsingDataRemover::REMOVE_WEBSQL | |
1810 BrowsingDataRemover::REMOVE_APPCACHE | | 1819 BrowsingDataRemover::REMOVE_APPCACHE | |
1811 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1820 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1812 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1821 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1813 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1822 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1814 false); | 1823 false); |
1815 | 1824 |
1816 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1825 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1817 BrowsingDataRemover::REMOVE_WEBSQL | | 1826 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 23 matching lines...) Expand all Loading... |
1841 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1850 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1842 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1851 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1843 } | 1852 } |
1844 | 1853 |
1845 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1854 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
1846 #if BUILDFLAG(ENABLE_EXTENSIONS) | 1855 #if BUILDFLAG(ENABLE_EXTENSIONS) |
1847 CreateMockPolicy(); | 1856 CreateMockPolicy(); |
1848 #endif | 1857 #endif |
1849 | 1858 |
1850 BlockUntilBrowsingDataRemoved( | 1859 BlockUntilBrowsingDataRemoved( |
1851 browsing_data::ALL_TIME, | 1860 base::Time(), base::Time::Max(), |
1852 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1861 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1853 BrowsingDataRemover::REMOVE_WEBSQL | | 1862 BrowsingDataRemover::REMOVE_WEBSQL | |
1854 BrowsingDataRemover::REMOVE_APPCACHE | | 1863 BrowsingDataRemover::REMOVE_APPCACHE | |
1855 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1864 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1856 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1865 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1857 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1866 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1858 false); | 1867 false); |
1859 | 1868 |
1860 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1869 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1861 BrowsingDataRemover::REMOVE_WEBSQL | | 1870 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 22 matching lines...) Expand all Loading... |
1884 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1893 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1885 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1894 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1886 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1895 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1887 } | 1896 } |
1888 | 1897 |
1889 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1898 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
1890 RegistrableDomainFilterBuilder builder( | 1899 RegistrableDomainFilterBuilder builder( |
1891 RegistrableDomainFilterBuilder::WHITELIST); | 1900 RegistrableDomainFilterBuilder::WHITELIST); |
1892 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 1901 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
1893 // Remove Origin 1. | 1902 // Remove Origin 1. |
1894 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 1903 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
1895 BrowsingDataRemover::REMOVE_APPCACHE | | 1904 BrowsingDataRemover::REMOVE_APPCACHE | |
1896 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1905 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1897 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1906 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1898 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1907 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1899 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1908 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1900 BrowsingDataRemover::REMOVE_WEBSQL, | 1909 BrowsingDataRemover::REMOVE_WEBSQL, |
1901 builder); | 1910 builder); |
1902 | 1911 |
1903 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 1912 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
1904 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1913 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 17 matching lines...) Expand all Loading... |
1922 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1931 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1923 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1932 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1924 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1933 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1925 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1934 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1926 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1935 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1927 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); | 1936 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
1928 } | 1937 } |
1929 | 1938 |
1930 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1939 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
1931 BlockUntilBrowsingDataRemoved( | 1940 BlockUntilBrowsingDataRemoved( |
1932 browsing_data::LAST_HOUR, | 1941 AnHourAgo(), base::Time::Max(), |
1933 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1942 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1934 BrowsingDataRemover::REMOVE_WEBSQL | | 1943 BrowsingDataRemover::REMOVE_WEBSQL | |
1935 BrowsingDataRemover::REMOVE_APPCACHE | | 1944 BrowsingDataRemover::REMOVE_APPCACHE | |
1936 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1945 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1937 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1946 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1938 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1947 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1939 false); | 1948 false); |
1940 | 1949 |
1941 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1950 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1942 BrowsingDataRemover::REMOVE_WEBSQL | | 1951 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 19 matching lines...) Expand all Loading... |
1962 // beginning of time. | 1971 // beginning of time. |
1963 uint32_t expected_quota_mask = | 1972 uint32_t expected_quota_mask = |
1964 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1973 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1965 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1974 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1966 // Check removal begin time. | 1975 // Check removal begin time. |
1967 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1976 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1968 } | 1977 } |
1969 | 1978 |
1970 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1979 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
1971 BlockUntilBrowsingDataRemoved( | 1980 BlockUntilBrowsingDataRemoved( |
1972 browsing_data::LAST_WEEK, | 1981 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), |
1973 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1982 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1974 BrowsingDataRemover::REMOVE_WEBSQL | | 1983 BrowsingDataRemover::REMOVE_WEBSQL | |
1975 BrowsingDataRemover::REMOVE_APPCACHE | | 1984 BrowsingDataRemover::REMOVE_APPCACHE | |
1976 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1985 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1977 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1986 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1978 BrowsingDataRemover::REMOVE_INDEXEDDB, | 1987 BrowsingDataRemover::REMOVE_INDEXEDDB, |
1979 false); | 1988 false); |
1980 | 1989 |
1981 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1990 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1982 BrowsingDataRemover::REMOVE_WEBSQL | | 1991 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 25 matching lines...) Expand all Loading... |
2008 } | 2017 } |
2009 | 2018 |
2010 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 2019 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
2011 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2020 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2012 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2021 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
2013 // Protect kOrigin1. | 2022 // Protect kOrigin1. |
2014 policy->AddProtected(kOrigin1.GetOrigin()); | 2023 policy->AddProtected(kOrigin1.GetOrigin()); |
2015 #endif | 2024 #endif |
2016 | 2025 |
2017 BlockUntilBrowsingDataRemoved( | 2026 BlockUntilBrowsingDataRemoved( |
2018 browsing_data::ALL_TIME, | 2027 base::Time(), base::Time::Max(), |
2019 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2028 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2020 BrowsingDataRemover::REMOVE_WEBSQL | | 2029 BrowsingDataRemover::REMOVE_WEBSQL | |
2021 BrowsingDataRemover::REMOVE_APPCACHE | | 2030 BrowsingDataRemover::REMOVE_APPCACHE | |
2022 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2031 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2023 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2032 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2024 BrowsingDataRemover::REMOVE_INDEXEDDB, | 2033 BrowsingDataRemover::REMOVE_INDEXEDDB, |
2025 false); | 2034 false); |
2026 | 2035 |
2027 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2036 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2028 BrowsingDataRemover::REMOVE_WEBSQL | | 2037 BrowsingDataRemover::REMOVE_WEBSQL | |
(...skipping 29 matching lines...) Expand all Loading... |
2058 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2067 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
2059 // Protect kOrigin1. | 2068 // Protect kOrigin1. |
2060 policy->AddProtected(kOrigin1.GetOrigin()); | 2069 policy->AddProtected(kOrigin1.GetOrigin()); |
2061 #endif | 2070 #endif |
2062 | 2071 |
2063 RegistrableDomainFilterBuilder builder( | 2072 RegistrableDomainFilterBuilder builder( |
2064 RegistrableDomainFilterBuilder::WHITELIST); | 2073 RegistrableDomainFilterBuilder::WHITELIST); |
2065 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2074 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2066 | 2075 |
2067 // Try to remove kOrigin1. Expect failure. | 2076 // Try to remove kOrigin1. Expect failure. |
2068 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2077 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2069 BrowsingDataRemover::REMOVE_APPCACHE | | 2078 BrowsingDataRemover::REMOVE_APPCACHE | |
2070 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2079 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2071 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2080 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2072 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2081 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2073 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2082 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2074 BrowsingDataRemover::REMOVE_WEBSQL, | 2083 BrowsingDataRemover::REMOVE_WEBSQL, |
2075 builder); | 2084 builder); |
2076 | 2085 |
2077 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2086 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2078 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2087 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 28 matching lines...) Expand all Loading... |
2107 | 2116 |
2108 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 2117 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
2109 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2118 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2110 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 2119 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
2111 // Protect kOrigin1. | 2120 // Protect kOrigin1. |
2112 policy->AddProtected(kOrigin1.GetOrigin()); | 2121 policy->AddProtected(kOrigin1.GetOrigin()); |
2113 #endif | 2122 #endif |
2114 | 2123 |
2115 // Try to remove kOrigin1. Expect success. | 2124 // Try to remove kOrigin1. Expect success. |
2116 BlockUntilBrowsingDataRemoved( | 2125 BlockUntilBrowsingDataRemoved( |
2117 browsing_data::ALL_TIME, | 2126 base::Time(), base::Time::Max(), |
2118 BrowsingDataRemover::REMOVE_APPCACHE | | 2127 BrowsingDataRemover::REMOVE_APPCACHE | |
2119 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2128 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2120 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2129 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2121 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2130 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2122 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2131 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2123 BrowsingDataRemover::REMOVE_WEBSQL, | 2132 BrowsingDataRemover::REMOVE_WEBSQL, |
2124 true); | 2133 true); |
2125 | 2134 |
2126 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2135 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2127 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2136 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 24 matching lines...) Expand all Loading... |
2152 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 2161 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
2153 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 2162 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
2154 } | 2163 } |
2155 | 2164 |
2156 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 2165 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
2157 #if BUILDFLAG(ENABLE_EXTENSIONS) | 2166 #if BUILDFLAG(ENABLE_EXTENSIONS) |
2158 CreateMockPolicy(); | 2167 CreateMockPolicy(); |
2159 #endif | 2168 #endif |
2160 | 2169 |
2161 BlockUntilBrowsingDataRemoved( | 2170 BlockUntilBrowsingDataRemoved( |
2162 browsing_data::ALL_TIME, | 2171 base::Time(), base::Time::Max(), |
2163 BrowsingDataRemover::REMOVE_APPCACHE | | 2172 BrowsingDataRemover::REMOVE_APPCACHE | |
2164 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2173 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
2165 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 2174 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
2166 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 2175 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
2167 BrowsingDataRemover::REMOVE_INDEXEDDB | | 2176 BrowsingDataRemover::REMOVE_INDEXEDDB | |
2168 BrowsingDataRemover::REMOVE_WEBSQL, | 2177 BrowsingDataRemover::REMOVE_WEBSQL, |
2169 false); | 2178 false); |
2170 | 2179 |
2171 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 2180 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
2172 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 2181 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
(...skipping 29 matching lines...) Expand all Loading... |
2202 | 2211 |
2203 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 2212 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
2204 | 2213 |
2205 tester.AddHistory(kOrigin1, base::Time::Now()); | 2214 tester.AddHistory(kOrigin1, base::Time::Now()); |
2206 tester.AddHistory(kOrigin2, two_hours_ago); | 2215 tester.AddHistory(kOrigin2, two_hours_ago); |
2207 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2216 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
2208 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2217 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
2209 | 2218 |
2210 RegistrableDomainFilterBuilder builder( | 2219 RegistrableDomainFilterBuilder builder( |
2211 RegistrableDomainFilterBuilder::BLACKLIST); | 2220 RegistrableDomainFilterBuilder::BLACKLIST); |
2212 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2221 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
2213 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2222 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2214 | 2223 |
2215 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2224 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
2216 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2225 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2217 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); | 2226 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
2218 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2227 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
2219 } | 2228 } |
2220 | 2229 |
2221 // Verify that clearing autofill form data works. | 2230 // Verify that clearing autofill form data works. |
2222 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2231 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
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::LAST_HOUR, | 2239 BlockUntilBrowsingDataRemoved(AnHourAgo(), 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 TEST_F(BrowsingDataRemoverTest, AutofillRemovalEverything) { | 2247 TEST_F(BrowsingDataRemoverTest, AutofillRemovalEverything) { |
2239 GetProfile()->CreateWebDataService(); | 2248 GetProfile()->CreateWebDataService(); |
2240 RemoveAutofillTester tester(GetProfile()); | 2249 RemoveAutofillTester tester(GetProfile()); |
2241 | 2250 |
2242 ASSERT_FALSE(tester.HasProfile()); | 2251 ASSERT_FALSE(tester.HasProfile()); |
2243 tester.AddProfilesAndCards(); | 2252 tester.AddProfilesAndCards(); |
2244 ASSERT_TRUE(tester.HasProfile()); | 2253 ASSERT_TRUE(tester.HasProfile()); |
2245 | 2254 |
2246 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2255 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2247 BrowsingDataRemover::REMOVE_FORM_DATA, false); | 2256 BrowsingDataRemover::REMOVE_FORM_DATA, false); |
2248 | 2257 |
2249 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); | 2258 EXPECT_EQ(BrowsingDataRemover::REMOVE_FORM_DATA, GetRemovalMask()); |
2250 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2259 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2251 ASSERT_FALSE(tester.HasProfile()); | 2260 ASSERT_FALSE(tester.HasProfile()); |
2252 } | 2261 } |
2253 | 2262 |
2254 // Verify that clearing autofill form data works. | 2263 // Verify that clearing autofill form data works. |
2255 TEST_F(BrowsingDataRemoverTest, AutofillOriginsRemovedWithHistory) { | 2264 TEST_F(BrowsingDataRemoverTest, AutofillOriginsRemovedWithHistory) { |
2256 GetProfile()->CreateWebDataService(); | 2265 GetProfile()->CreateWebDataService(); |
2257 RemoveAutofillTester tester(GetProfile()); | 2266 RemoveAutofillTester tester(GetProfile()); |
2258 | 2267 |
2259 tester.AddProfilesAndCards(); | 2268 tester.AddProfilesAndCards(); |
2260 EXPECT_FALSE(tester.HasOrigin(std::string())); | 2269 EXPECT_FALSE(tester.HasOrigin(std::string())); |
2261 EXPECT_TRUE(tester.HasOrigin(kWebOrigin)); | 2270 EXPECT_TRUE(tester.HasOrigin(kWebOrigin)); |
2262 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); | 2271 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); |
2263 | 2272 |
2264 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2273 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
2265 BrowsingDataRemover::REMOVE_HISTORY, false); | 2274 BrowsingDataRemover::REMOVE_HISTORY, false); |
2266 | 2275 |
2267 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2276 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
2268 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2277 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2269 EXPECT_TRUE(tester.HasOrigin(std::string())); | 2278 EXPECT_TRUE(tester.HasOrigin(std::string())); |
2270 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); | 2279 EXPECT_FALSE(tester.HasOrigin(kWebOrigin)); |
2271 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); | 2280 EXPECT_TRUE(tester.HasOrigin(autofill::kSettingsOrigin)); |
2272 } | 2281 } |
2273 | 2282 |
2274 class InspectableCompletionObserver | 2283 class InspectableCompletionObserver |
(...skipping 16 matching lines...) Expand all Loading... |
2291 }; | 2300 }; |
2292 | 2301 |
2293 TEST_F(BrowsingDataRemoverTest, CompletionInhibition) { | 2302 TEST_F(BrowsingDataRemoverTest, CompletionInhibition) { |
2294 // The |completion_inhibitor| on the stack should prevent removal sessions | 2303 // The |completion_inhibitor| on the stack should prevent removal sessions |
2295 // from completing until after ContinueToCompletion() is called. | 2304 // from completing until after ContinueToCompletion() is called. |
2296 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2305 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2297 | 2306 |
2298 BrowsingDataRemover* remover = | 2307 BrowsingDataRemover* remover = |
2299 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 2308 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
2300 InspectableCompletionObserver completion_observer(remover); | 2309 InspectableCompletionObserver completion_observer(remover); |
2301 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 2310 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
2302 BrowsingDataRemover::REMOVE_HISTORY, | 2311 BrowsingDataRemover::REMOVE_HISTORY, |
2303 BrowsingDataHelper::UNPROTECTED_WEB, | 2312 BrowsingDataHelper::UNPROTECTED_WEB, |
2304 &completion_observer); | 2313 &completion_observer); |
2305 | 2314 |
2306 // Process messages until the inhibitor is notified, and then some, to make | 2315 // Process messages until the inhibitor is notified, and then some, to make |
2307 // sure we do not complete asynchronously before ContinueToCompletion() is | 2316 // sure we do not complete asynchronously before ContinueToCompletion() is |
2308 // called. | 2317 // called. |
2309 completion_inhibitor.BlockUntilNearCompletion(); | 2318 completion_inhibitor.BlockUntilNearCompletion(); |
2310 base::RunLoop().RunUntilIdle(); | 2319 base::RunLoop().RunUntilIdle(); |
2311 | 2320 |
2312 // Verify that the removal has not yet been completed and the observer has | 2321 // Verify that the removal has not yet been completed and the observer has |
2313 // not been called. | 2322 // not been called. |
2314 EXPECT_TRUE(remover->is_removing()); | 2323 EXPECT_TRUE(remover->is_removing()); |
2315 EXPECT_FALSE(completion_observer.called()); | 2324 EXPECT_FALSE(completion_observer.called()); |
2316 | 2325 |
2317 // Now run the removal process until completion, and verify that observers are | 2326 // Now run the removal process until completion, and verify that observers are |
2318 // now notified, and the notifications is sent out. | 2327 // now notified, and the notifications is sent out. |
2319 completion_inhibitor.ContinueToCompletion(); | 2328 completion_inhibitor.ContinueToCompletion(); |
2320 completion_observer.BlockUntilCompletion(); | 2329 completion_observer.BlockUntilCompletion(); |
2321 | 2330 |
2322 EXPECT_FALSE(remover->is_removing()); | 2331 EXPECT_FALSE(remover->is_removing()); |
2323 EXPECT_TRUE(completion_observer.called()); | 2332 EXPECT_TRUE(completion_observer.called()); |
2324 } | 2333 } |
2325 | 2334 |
2326 TEST_F(BrowsingDataRemoverTest, EarlyShutdown) { | 2335 TEST_F(BrowsingDataRemoverTest, EarlyShutdown) { |
2327 BrowsingDataRemover* remover = | 2336 BrowsingDataRemover* remover = |
2328 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); | 2337 BrowsingDataRemoverFactory::GetForBrowserContext(GetProfile()); |
2329 InspectableCompletionObserver completion_observer(remover); | 2338 InspectableCompletionObserver completion_observer(remover); |
2330 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2339 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2331 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 2340 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
2332 BrowsingDataRemover::REMOVE_HISTORY, | 2341 BrowsingDataRemover::REMOVE_HISTORY, |
2333 BrowsingDataHelper::UNPROTECTED_WEB, | 2342 BrowsingDataHelper::UNPROTECTED_WEB, |
2334 &completion_observer); | 2343 &completion_observer); |
2335 | 2344 |
2336 completion_inhibitor.BlockUntilNearCompletion(); | 2345 completion_inhibitor.BlockUntilNearCompletion(); |
2337 | 2346 |
2338 // Verify that the deletion has not yet been completed and the observer has | 2347 // Verify that the deletion has not yet been completed and the observer has |
2339 // not been called. | 2348 // not been called. |
2340 EXPECT_TRUE(remover->is_removing()); | 2349 EXPECT_TRUE(remover->is_removing()); |
2341 EXPECT_FALSE(completion_observer.called()); | 2350 EXPECT_FALSE(completion_observer.called()); |
2342 | 2351 |
2343 // Destroying the profile should trigger the notification. | 2352 // Destroying the profile should trigger the notification. |
2344 DestroyProfile(); | 2353 DestroyProfile(); |
2345 | 2354 |
2346 EXPECT_TRUE(completion_observer.called()); | 2355 EXPECT_TRUE(completion_observer.called()); |
2347 | 2356 |
2348 // Finishing after shutdown shouldn't break anything. | 2357 // Finishing after shutdown shouldn't break anything. |
2349 completion_inhibitor.ContinueToCompletion(); | 2358 completion_inhibitor.ContinueToCompletion(); |
2350 completion_observer.BlockUntilCompletion(); | 2359 completion_observer.BlockUntilCompletion(); |
2351 } | 2360 } |
2352 | 2361 |
2353 TEST_F(BrowsingDataRemoverTest, ZeroSuggestCacheClear) { | 2362 TEST_F(BrowsingDataRemoverTest, ZeroSuggestCacheClear) { |
2354 PrefService* prefs = GetProfile()->GetPrefs(); | 2363 PrefService* prefs = GetProfile()->GetPrefs(); |
2355 prefs->SetString(omnibox::kZeroSuggestCachedResults, | 2364 prefs->SetString(omnibox::kZeroSuggestCachedResults, |
2356 "[\"\", [\"foo\", \"bar\"]]"); | 2365 "[\"\", [\"foo\", \"bar\"]]"); |
2357 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2366 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2358 BrowsingDataRemover::REMOVE_COOKIES, false); | 2367 BrowsingDataRemover::REMOVE_COOKIES, false); |
2359 | 2368 |
2360 // Expect the prefs to be cleared when cookies are removed. | 2369 // Expect the prefs to be cleared when cookies are removed. |
2361 EXPECT_TRUE(prefs->GetString(omnibox::kZeroSuggestCachedResults).empty()); | 2370 EXPECT_TRUE(prefs->GetString(omnibox::kZeroSuggestCachedResults).empty()); |
2362 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 2371 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
2363 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2372 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2364 } | 2373 } |
2365 | 2374 |
2366 #if defined(OS_CHROMEOS) | 2375 #if defined(OS_CHROMEOS) |
2367 TEST_F(BrowsingDataRemoverTest, ContentProtectionPlatformKeysRemoval) { | 2376 TEST_F(BrowsingDataRemoverTest, ContentProtectionPlatformKeysRemoval) { |
(...skipping 10 matching lines...) Expand all Loading... |
2378 chromeos::MockCryptohomeClient* cryptohome_client = | 2387 chromeos::MockCryptohomeClient* cryptohome_client = |
2379 new chromeos::MockCryptohomeClient; | 2388 new chromeos::MockCryptohomeClient; |
2380 dbus_setter->SetCryptohomeClient( | 2389 dbus_setter->SetCryptohomeClient( |
2381 std::unique_ptr<chromeos::CryptohomeClient>(cryptohome_client)); | 2390 std::unique_ptr<chromeos::CryptohomeClient>(cryptohome_client)); |
2382 | 2391 |
2383 // Expect exactly one call. No calls means no attempt to delete keys and more | 2392 // Expect exactly one call. No calls means no attempt to delete keys and more |
2384 // than one call means a significant performance problem. | 2393 // than one call means a significant performance problem. |
2385 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) | 2394 EXPECT_CALL(*cryptohome_client, TpmAttestationDeleteKeys(_, _, _, _)) |
2386 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); | 2395 .WillOnce(WithArgs<3>(Invoke(FakeDBusCall))); |
2387 | 2396 |
2388 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2397 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2389 BrowsingDataRemover::REMOVE_MEDIA_LICENSES, | 2398 BrowsingDataRemover::REMOVE_MEDIA_LICENSES, |
2390 false); | 2399 false); |
2391 | 2400 |
2392 chromeos::DBusThreadManager::Shutdown(); | 2401 chromeos::DBusThreadManager::Shutdown(); |
2393 } | 2402 } |
2394 #endif | 2403 #endif |
2395 | 2404 |
2396 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) { | 2405 TEST_F(BrowsingDataRemoverTest, DomainReliability_Null) { |
2397 const ClearDomainReliabilityTester& tester = | 2406 const ClearDomainReliabilityTester& tester = |
2398 clear_domain_reliability_tester(); | 2407 clear_domain_reliability_tester(); |
2399 | 2408 |
2400 EXPECT_EQ(0u, tester.clear_count()); | 2409 EXPECT_EQ(0u, tester.clear_count()); |
2401 } | 2410 } |
2402 | 2411 |
2403 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) { | 2412 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons) { |
2404 const ClearDomainReliabilityTester& tester = | 2413 const ClearDomainReliabilityTester& tester = |
2405 clear_domain_reliability_tester(); | 2414 clear_domain_reliability_tester(); |
2406 | 2415 |
2407 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2416 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2408 BrowsingDataRemover::REMOVE_HISTORY, false); | 2417 BrowsingDataRemover::REMOVE_HISTORY, false); |
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 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); | 2421 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); |
2413 } | 2422 } |
2414 | 2423 |
2415 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons_WithFilter) { | 2424 TEST_F(BrowsingDataRemoverTest, DomainReliability_Beacons_WithFilter) { |
2416 const ClearDomainReliabilityTester& tester = | 2425 const ClearDomainReliabilityTester& tester = |
2417 clear_domain_reliability_tester(); | 2426 clear_domain_reliability_tester(); |
2418 | 2427 |
2419 RegistrableDomainFilterBuilder builder( | 2428 RegistrableDomainFilterBuilder builder( |
2420 RegistrableDomainFilterBuilder::WHITELIST); | 2429 RegistrableDomainFilterBuilder::WHITELIST); |
2421 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2430 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2422 | 2431 |
2423 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2432 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2424 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2433 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2425 EXPECT_EQ(1u, tester.clear_count()); | 2434 EXPECT_EQ(1u, tester.clear_count()); |
2426 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); | 2435 EXPECT_EQ(CLEAR_BEACONS, tester.last_clear_mode()); |
2427 EXPECT_TRUE(ProbablySameFilters( | 2436 EXPECT_TRUE(ProbablySameFilters( |
2428 builder.BuildGeneralFilter(), tester.last_filter())); | 2437 builder.BuildGeneralFilter(), tester.last_filter())); |
2429 } | 2438 } |
2430 | 2439 |
2431 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) { | 2440 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts) { |
2432 const ClearDomainReliabilityTester& tester = | 2441 const ClearDomainReliabilityTester& tester = |
2433 clear_domain_reliability_tester(); | 2442 clear_domain_reliability_tester(); |
2434 | 2443 |
2435 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2444 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2436 BrowsingDataRemover::REMOVE_COOKIES, false); | 2445 BrowsingDataRemover::REMOVE_COOKIES, false); |
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 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); | 2449 BrowsingDataFilterBuilder::BuildNoopFilter(), tester.last_filter())); |
2441 } | 2450 } |
2442 | 2451 |
2443 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_WithFilter) { | 2452 TEST_F(BrowsingDataRemoverTest, DomainReliability_Contexts_WithFilter) { |
2444 const ClearDomainReliabilityTester& tester = | 2453 const ClearDomainReliabilityTester& tester = |
2445 clear_domain_reliability_tester(); | 2454 clear_domain_reliability_tester(); |
2446 | 2455 |
2447 RegistrableDomainFilterBuilder builder( | 2456 RegistrableDomainFilterBuilder builder( |
2448 RegistrableDomainFilterBuilder::WHITELIST); | 2457 RegistrableDomainFilterBuilder::WHITELIST); |
2449 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2458 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2450 | 2459 |
2451 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2460 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2452 BrowsingDataRemover::REMOVE_COOKIES, builder); | 2461 BrowsingDataRemover::REMOVE_COOKIES, builder); |
2453 EXPECT_EQ(1u, tester.clear_count()); | 2462 EXPECT_EQ(1u, tester.clear_count()); |
2454 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2463 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2455 EXPECT_TRUE(ProbablySameFilters( | 2464 EXPECT_TRUE(ProbablySameFilters( |
2456 builder.BuildGeneralFilter(), tester.last_filter())); | 2465 builder.BuildGeneralFilter(), tester.last_filter())); |
2457 } | 2466 } |
2458 | 2467 |
2459 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) { | 2468 TEST_F(BrowsingDataRemoverTest, DomainReliability_ContextsWin) { |
2460 const ClearDomainReliabilityTester& tester = | 2469 const ClearDomainReliabilityTester& tester = |
2461 clear_domain_reliability_tester(); | 2470 clear_domain_reliability_tester(); |
2462 | 2471 |
2463 BlockUntilBrowsingDataRemoved( | 2472 BlockUntilBrowsingDataRemoved( |
2464 browsing_data::ALL_TIME, | 2473 base::Time(), base::Time::Max(), |
2465 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, | 2474 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, |
2466 false); | 2475 false); |
2467 EXPECT_EQ(1u, tester.clear_count()); | 2476 EXPECT_EQ(1u, tester.clear_count()); |
2468 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2477 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2469 } | 2478 } |
2470 | 2479 |
2471 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) { | 2480 TEST_F(BrowsingDataRemoverTest, DomainReliability_ProtectedOrigins) { |
2472 const ClearDomainReliabilityTester& tester = | 2481 const ClearDomainReliabilityTester& tester = |
2473 clear_domain_reliability_tester(); | 2482 clear_domain_reliability_tester(); |
2474 | 2483 |
2475 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2484 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2476 BrowsingDataRemover::REMOVE_COOKIES, true); | 2485 BrowsingDataRemover::REMOVE_COOKIES, true); |
2477 EXPECT_EQ(1u, tester.clear_count()); | 2486 EXPECT_EQ(1u, tester.clear_count()); |
2478 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); | 2487 EXPECT_EQ(CLEAR_CONTEXTS, tester.last_clear_mode()); |
2479 } | 2488 } |
2480 | 2489 |
2481 // TODO(juliatuttle): This isn't actually testing the no-monitor case, since | 2490 // TODO(juliatuttle): This isn't actually testing the no-monitor case, since |
2482 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed | 2491 // BrowsingDataRemoverTest now creates one unconditionally, since it's needed |
2483 // for some unrelated test cases. This should be fixed so it tests the no- | 2492 // for some unrelated test cases. This should be fixed so it tests the no- |
2484 // monitor case again. | 2493 // monitor case again. |
2485 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { | 2494 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { |
2486 BlockUntilBrowsingDataRemoved( | 2495 BlockUntilBrowsingDataRemoved( |
2487 browsing_data::ALL_TIME, | 2496 base::Time(), base::Time::Max(), |
2488 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, | 2497 BrowsingDataRemover::REMOVE_HISTORY | BrowsingDataRemover::REMOVE_COOKIES, |
2489 false); | 2498 false); |
2490 } | 2499 } |
2491 | 2500 |
2492 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { | 2501 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { |
2493 RemoveDownloadsTester tester(GetProfile()); | 2502 RemoveDownloadsTester tester(GetProfile()); |
2494 base::Callback<bool(const GURL&)> filter = | 2503 base::Callback<bool(const GURL&)> filter = |
2495 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2504 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2496 | 2505 |
2497 EXPECT_CALL( | 2506 EXPECT_CALL( |
2498 *tester.download_manager(), | 2507 *tester.download_manager(), |
2499 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2508 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2500 | 2509 |
2501 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2510 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2502 BrowsingDataRemover::REMOVE_DOWNLOADS, false); | 2511 BrowsingDataRemover::REMOVE_DOWNLOADS, false); |
2503 } | 2512 } |
2504 | 2513 |
2505 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { | 2514 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { |
2506 RemoveDownloadsTester tester(GetProfile()); | 2515 RemoveDownloadsTester tester(GetProfile()); |
2507 RegistrableDomainFilterBuilder builder( | 2516 RegistrableDomainFilterBuilder builder( |
2508 RegistrableDomainFilterBuilder::WHITELIST); | 2517 RegistrableDomainFilterBuilder::WHITELIST); |
2509 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2518 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2510 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2519 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2511 | 2520 |
2512 EXPECT_CALL( | 2521 EXPECT_CALL( |
2513 *tester.download_manager(), | 2522 *tester.download_manager(), |
2514 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2523 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2515 | 2524 |
2516 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2525 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2517 BrowsingDataRemover::REMOVE_DOWNLOADS, builder); | 2526 BrowsingDataRemover::REMOVE_DOWNLOADS, builder); |
2518 } | 2527 } |
2519 | 2528 |
2520 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { | 2529 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { |
2521 RemovePasswordsTester tester(GetProfile()); | 2530 RemovePasswordsTester tester(GetProfile()); |
2522 base::Callback<bool(const GURL&)> empty_filter; | 2531 base::Callback<bool(const GURL&)> empty_filter; |
2523 | 2532 |
2524 EXPECT_CALL(*tester.store(), RemoveStatisticsByOriginAndTimeImpl( | 2533 EXPECT_CALL(*tester.store(), RemoveStatisticsByOriginAndTimeImpl( |
2525 ProbablySameFilter(empty_filter), | 2534 ProbablySameFilter(empty_filter), |
2526 base::Time(), base::Time::Max())); | 2535 base::Time(), base::Time::Max())); |
2527 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2536 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2528 BrowsingDataRemover::REMOVE_HISTORY, false); | 2537 BrowsingDataRemover::REMOVE_HISTORY, false); |
2529 } | 2538 } |
2530 | 2539 |
2531 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatisticsByOrigin) { | 2540 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatisticsByOrigin) { |
2532 RemovePasswordsTester tester(GetProfile()); | 2541 RemovePasswordsTester tester(GetProfile()); |
2533 | 2542 |
2534 RegistrableDomainFilterBuilder builder( | 2543 RegistrableDomainFilterBuilder builder( |
2535 RegistrableDomainFilterBuilder::WHITELIST); | 2544 RegistrableDomainFilterBuilder::WHITELIST); |
2536 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2545 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2537 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2546 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2538 | 2547 |
2539 EXPECT_CALL(*tester.store(), | 2548 EXPECT_CALL(*tester.store(), |
2540 RemoveStatisticsByOriginAndTimeImpl( | 2549 RemoveStatisticsByOriginAndTimeImpl( |
2541 ProbablySameFilter(filter), base::Time(), base::Time::Max())); | 2550 ProbablySameFilter(filter), base::Time(), base::Time::Max())); |
2542 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2551 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2543 BrowsingDataRemover::REMOVE_HISTORY, builder); | 2552 BrowsingDataRemover::REMOVE_HISTORY, builder); |
2544 } | 2553 } |
2545 | 2554 |
2546 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { | 2555 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { |
2547 RemovePasswordsTester tester(GetProfile()); | 2556 RemovePasswordsTester tester(GetProfile()); |
2548 base::Callback<bool(const GURL&)> filter = | 2557 base::Callback<bool(const GURL&)> filter = |
2549 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2558 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2550 | 2559 |
2551 EXPECT_CALL(*tester.store(), | 2560 EXPECT_CALL(*tester.store(), |
2552 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2561 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2553 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2562 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2554 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2563 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2555 BrowsingDataRemover::REMOVE_PASSWORDS, false); | 2564 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
2556 } | 2565 } |
2557 | 2566 |
2558 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { | 2567 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { |
2559 RemovePasswordsTester tester(GetProfile()); | 2568 RemovePasswordsTester tester(GetProfile()); |
2560 RegistrableDomainFilterBuilder builder( | 2569 RegistrableDomainFilterBuilder builder( |
2561 RegistrableDomainFilterBuilder::WHITELIST); | 2570 RegistrableDomainFilterBuilder::WHITELIST); |
2562 builder.AddRegisterableDomain(kTestRegisterableDomain1); | 2571 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2563 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); | 2572 base::Callback<bool(const GURL&)> filter = builder.BuildGeneralFilter(); |
2564 | 2573 |
2565 EXPECT_CALL(*tester.store(), | 2574 EXPECT_CALL(*tester.store(), |
2566 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2575 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2567 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2576 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2568 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2577 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2569 BrowsingDataRemover::REMOVE_PASSWORDS, builder); | 2578 BrowsingDataRemover::REMOVE_PASSWORDS, builder); |
2570 } | 2579 } |
2571 | 2580 |
2572 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { | 2581 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { |
2573 RemovePasswordsTester tester(GetProfile()); | 2582 RemovePasswordsTester tester(GetProfile()); |
2574 base::Callback<bool(const GURL&)> empty_filter = | 2583 base::Callback<bool(const GURL&)> empty_filter = |
2575 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2584 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2576 | 2585 |
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, false); | 2592 BrowsingDataRemover::REMOVE_COOKIES, false); |
2584 } | 2593 } |
2585 | 2594 |
2586 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { | 2595 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { |
2587 RemovePasswordsTester tester(GetProfile()); | 2596 RemovePasswordsTester tester(GetProfile()); |
2588 base::Callback<bool(const GURL&)> empty_filter = | 2597 base::Callback<bool(const GURL&)> empty_filter = |
2589 BrowsingDataFilterBuilder::BuildNoopFilter(); | 2598 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2590 | 2599 |
2591 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2600 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
2592 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2601 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2593 EXPECT_CALL( | 2602 EXPECT_CALL( |
2594 *tester.store(), | 2603 *tester.store(), |
2595 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) | 2604 DisableAutoSignInForOriginsImpl(ProbablySameFilter(empty_filter))) |
2596 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2605 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2597 | 2606 |
2598 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2607 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2599 BrowsingDataRemover::REMOVE_COOKIES | | 2608 BrowsingDataRemover::REMOVE_COOKIES | |
2600 BrowsingDataRemover::REMOVE_PASSWORDS, | 2609 BrowsingDataRemover::REMOVE_PASSWORDS, |
2601 false); | 2610 false); |
2602 } | 2611 } |
2603 | 2612 |
2604 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { | 2613 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
2605 // Add our settings. | 2614 // Add our settings. |
2606 HostContentSettingsMap* host_content_settings_map = | 2615 HostContentSettingsMap* host_content_settings_map = |
2607 HostContentSettingsMapFactory::GetForProfile(GetProfile()); | 2616 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
2608 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2617 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2609 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2618 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2610 base::MakeUnique<base::DictionaryValue>()); | 2619 base::MakeUnique<base::DictionaryValue>()); |
2611 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2620 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2612 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2621 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2613 base::MakeUnique<base::DictionaryValue>()); | 2622 base::MakeUnique<base::DictionaryValue>()); |
2614 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2623 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2615 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2624 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2616 base::MakeUnique<base::DictionaryValue>()); | 2625 base::MakeUnique<base::DictionaryValue>()); |
2617 host_content_settings_map->SetWebsiteSettingDefaultScope( | 2626 host_content_settings_map->SetWebsiteSettingDefaultScope( |
2618 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), | 2627 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
2619 base::MakeUnique<base::DictionaryValue>()); | 2628 base::MakeUnique<base::DictionaryValue>()); |
2620 | 2629 |
2621 // Clear all except for origin1 and origin3. | 2630 // Clear all except for origin1 and origin3. |
2622 RegistrableDomainFilterBuilder filter( | 2631 RegistrableDomainFilterBuilder filter( |
2623 RegistrableDomainFilterBuilder::BLACKLIST); | 2632 RegistrableDomainFilterBuilder::BLACKLIST); |
2624 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 2633 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
2625 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 2634 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
2626 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2635 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
2627 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2636 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2628 filter); | 2637 filter); |
2629 | 2638 |
2630 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); | 2639 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
2631 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2640 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2632 | 2641 |
2633 // Verify we only have true, and they're origin1, origin3, and origin4. | 2642 // Verify we only have true, and they're origin1, origin3, and origin4. |
2634 ContentSettingsForOneType host_settings; | 2643 ContentSettingsForOneType host_settings; |
2635 host_content_settings_map->GetSettingsForOneType( | 2644 host_content_settings_map->GetSettingsForOneType( |
2636 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); | 2645 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
(...skipping 18 matching lines...) Expand all Loading... |
2655 durable_permission.UpdateContentSetting(kOrigin1, GURL(), | 2664 durable_permission.UpdateContentSetting(kOrigin1, GURL(), |
2656 CONTENT_SETTING_ALLOW); | 2665 CONTENT_SETTING_ALLOW); |
2657 durable_permission.UpdateContentSetting(kOrigin2, GURL(), | 2666 durable_permission.UpdateContentSetting(kOrigin2, GURL(), |
2658 CONTENT_SETTING_ALLOW); | 2667 CONTENT_SETTING_ALLOW); |
2659 | 2668 |
2660 // Clear all except for origin1 and origin3. | 2669 // Clear all except for origin1 and origin3. |
2661 RegistrableDomainFilterBuilder filter( | 2670 RegistrableDomainFilterBuilder filter( |
2662 RegistrableDomainFilterBuilder::BLACKLIST); | 2671 RegistrableDomainFilterBuilder::BLACKLIST); |
2663 filter.AddRegisterableDomain(kTestRegisterableDomain1); | 2672 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
2664 filter.AddRegisterableDomain(kTestRegisterableDomain3); | 2673 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
2665 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2674 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
2666 BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, | 2675 BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, |
2667 filter); | 2676 filter); |
2668 | 2677 |
2669 EXPECT_EQ(BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, GetRemovalMask()); | 2678 EXPECT_EQ(BrowsingDataRemover::REMOVE_DURABLE_PERMISSION, GetRemovalMask()); |
2670 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2679 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2671 | 2680 |
2672 // Verify we only have allow for the first origin. | 2681 // Verify we only have allow for the first origin. |
2673 ContentSettingsForOneType host_settings; | 2682 ContentSettingsForOneType host_settings; |
2674 host_content_settings_map->GetSettingsForOneType( | 2683 host_content_settings_map->GetSettingsForOneType( |
2675 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); | 2684 CONTENT_SETTINGS_TYPE_DURABLE_STORAGE, std::string(), &host_settings); |
(...skipping 23 matching lines...) Expand all Loading... |
2699 | 2708 |
2700 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2709 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); |
2701 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, | 2710 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, |
2702 "test challenge", | 2711 "test challenge", |
2703 net::AuthCredentials(base::ASCIIToUTF16("foo"), | 2712 net::AuthCredentials(base::ASCIIToUTF16("foo"), |
2704 base::ASCIIToUTF16("bar")), | 2713 base::ASCIIToUTF16("bar")), |
2705 "/"); | 2714 "/"); |
2706 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2715 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2707 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2716 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2708 | 2717 |
2709 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2718 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2710 BrowsingDataRemover::REMOVE_COOKIES, false); | 2719 BrowsingDataRemover::REMOVE_COOKIES, false); |
2711 | 2720 |
2712 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2721 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2713 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2722 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2714 } | 2723 } |
2715 | 2724 |
2716 // Test that removing passwords clears HTTP auth data. | 2725 // Test that removing passwords clears HTTP auth data. |
2717 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { | 2726 TEST_F(BrowsingDataRemoverTest, ClearHttpAuthCache_RemovePasswords) { |
2718 net::HttpNetworkSession* http_session = GetProfile() | 2727 net::HttpNetworkSession* http_session = GetProfile() |
2719 ->GetRequestContext() | 2728 ->GetRequestContext() |
2720 ->GetURLRequestContext() | 2729 ->GetURLRequestContext() |
2721 ->http_transaction_factory() | 2730 ->http_transaction_factory() |
2722 ->GetSession(); | 2731 ->GetSession(); |
2723 DCHECK(http_session); | 2732 DCHECK(http_session); |
2724 | 2733 |
2725 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); | 2734 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); |
2726 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, | 2735 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, |
2727 "test challenge", | 2736 "test challenge", |
2728 net::AuthCredentials(base::ASCIIToUTF16("foo"), | 2737 net::AuthCredentials(base::ASCIIToUTF16("foo"), |
2729 base::ASCIIToUTF16("bar")), | 2738 base::ASCIIToUTF16("bar")), |
2730 "/"); | 2739 "/"); |
2731 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2740 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2732 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2741 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2733 | 2742 |
2734 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, | 2743 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), |
2735 BrowsingDataRemover::REMOVE_PASSWORDS, false); | 2744 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
2736 | 2745 |
2737 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, | 2746 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, |
2738 net::HttpAuth::AUTH_SCHEME_BASIC)); | 2747 net::HttpAuth::AUTH_SCHEME_BASIC)); |
2739 } | 2748 } |
2740 | 2749 |
2741 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) { | 2750 TEST_F(BrowsingDataRemoverTest, ClearPermissionPromptCounts) { |
2742 RemovePermissionPromptCountsTest tester(GetProfile()); | 2751 RemovePermissionPromptCountsTest tester(GetProfile()); |
2743 | 2752 |
2744 RegistrableDomainFilterBuilder filter_builder_1( | 2753 RegistrableDomainFilterBuilder filter_builder_1( |
(...skipping 12 matching lines...) Expand all Loading... |
2757 content::PermissionType::GEOLOCATION)); | 2766 content::PermissionType::GEOLOCATION)); |
2758 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2767 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2759 content::PermissionType::NOTIFICATIONS)); | 2768 content::PermissionType::NOTIFICATIONS)); |
2760 tester.ShouldChangeDismissalToBlock(kOrigin1, | 2769 tester.ShouldChangeDismissalToBlock(kOrigin1, |
2761 content::PermissionType::MIDI_SYSEX); | 2770 content::PermissionType::MIDI_SYSEX); |
2762 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, | 2771 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, |
2763 content::PermissionType::DURABLE_STORAGE)); | 2772 content::PermissionType::DURABLE_STORAGE)); |
2764 tester.ShouldChangeDismissalToBlock(kOrigin2, | 2773 tester.ShouldChangeDismissalToBlock(kOrigin2, |
2765 content::PermissionType::NOTIFICATIONS); | 2774 content::PermissionType::NOTIFICATIONS); |
2766 | 2775 |
2767 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2776 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
2768 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2777 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2769 filter_builder_1); | 2778 filter_builder_1); |
2770 | 2779 |
2771 // kOrigin1 should be gone, but kOrigin2 remains. | 2780 // kOrigin1 should be gone, but kOrigin2 remains. |
2772 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2781 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2773 content::PermissionType::GEOLOCATION)); | 2782 content::PermissionType::GEOLOCATION)); |
2774 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2783 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2775 content::PermissionType::NOTIFICATIONS)); | 2784 content::PermissionType::NOTIFICATIONS)); |
2776 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2785 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2777 content::PermissionType::MIDI_SYSEX)); | 2786 content::PermissionType::MIDI_SYSEX)); |
2778 EXPECT_EQ(1, tester.GetIgnoreCount( | 2787 EXPECT_EQ(1, tester.GetIgnoreCount( |
2779 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2788 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2780 EXPECT_EQ(1, tester.GetDismissCount( | 2789 EXPECT_EQ(1, tester.GetDismissCount( |
2781 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2790 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2782 | 2791 |
2783 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2792 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
2784 BrowsingDataRemover::REMOVE_HISTORY, false); | 2793 BrowsingDataRemover::REMOVE_HISTORY, false); |
2785 | 2794 |
2786 // Everything should be gone. | 2795 // Everything should be gone. |
2787 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2796 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2788 content::PermissionType::GEOLOCATION)); | 2797 content::PermissionType::GEOLOCATION)); |
2789 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2798 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2790 content::PermissionType::NOTIFICATIONS)); | 2799 content::PermissionType::NOTIFICATIONS)); |
2791 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2800 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2792 content::PermissionType::MIDI_SYSEX)); | 2801 content::PermissionType::MIDI_SYSEX)); |
2793 EXPECT_EQ(0, tester.GetIgnoreCount( | 2802 EXPECT_EQ(0, tester.GetIgnoreCount( |
2794 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2803 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2795 EXPECT_EQ(0, tester.GetDismissCount( | 2804 EXPECT_EQ(0, tester.GetDismissCount( |
2796 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2805 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2797 } | 2806 } |
2798 { | 2807 { |
2799 // Test REMOVE_SITE_DATA. | 2808 // Test REMOVE_SITE_DATA. |
2800 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2809 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2801 content::PermissionType::GEOLOCATION)); | 2810 content::PermissionType::GEOLOCATION)); |
2802 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, | 2811 EXPECT_EQ(2, tester.RecordIgnore(kOrigin1, |
2803 content::PermissionType::GEOLOCATION)); | 2812 content::PermissionType::GEOLOCATION)); |
2804 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, | 2813 EXPECT_EQ(1, tester.RecordIgnore(kOrigin1, |
2805 content::PermissionType::NOTIFICATIONS)); | 2814 content::PermissionType::NOTIFICATIONS)); |
2806 tester.ShouldChangeDismissalToBlock(kOrigin1, | 2815 tester.ShouldChangeDismissalToBlock(kOrigin1, |
2807 content::PermissionType::MIDI_SYSEX); | 2816 content::PermissionType::MIDI_SYSEX); |
2808 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, | 2817 EXPECT_EQ(1, tester.RecordIgnore(kOrigin2, |
2809 content::PermissionType::DURABLE_STORAGE)); | 2818 content::PermissionType::DURABLE_STORAGE)); |
2810 tester.ShouldChangeDismissalToBlock(kOrigin2, | 2819 tester.ShouldChangeDismissalToBlock(kOrigin2, |
2811 content::PermissionType::NOTIFICATIONS); | 2820 content::PermissionType::NOTIFICATIONS); |
2812 | 2821 |
2813 BlockUntilOriginDataRemoved(browsing_data::LAST_HOUR, | 2822 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), |
2814 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2823 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2815 filter_builder_2); | 2824 filter_builder_2); |
2816 | 2825 |
2817 // kOrigin2 should be gone, but kOrigin1 remains. | 2826 // kOrigin2 should be gone, but kOrigin1 remains. |
2818 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1, | 2827 EXPECT_EQ(2, tester.GetIgnoreCount(kOrigin1, |
2819 content::PermissionType::GEOLOCATION)); | 2828 content::PermissionType::GEOLOCATION)); |
2820 EXPECT_EQ(1, tester.GetIgnoreCount(kOrigin1, | 2829 EXPECT_EQ(1, tester.GetIgnoreCount(kOrigin1, |
2821 content::PermissionType::NOTIFICATIONS)); | 2830 content::PermissionType::NOTIFICATIONS)); |
2822 EXPECT_EQ(1, tester.GetDismissCount(kOrigin1, | 2831 EXPECT_EQ(1, tester.GetDismissCount(kOrigin1, |
2823 content::PermissionType::MIDI_SYSEX)); | 2832 content::PermissionType::MIDI_SYSEX)); |
2824 EXPECT_EQ(0, tester.GetIgnoreCount( | 2833 EXPECT_EQ(0, tester.GetIgnoreCount( |
2825 kOrigin2, content::PermissionType::DURABLE_STORAGE)); | 2834 kOrigin2, content::PermissionType::DURABLE_STORAGE)); |
2826 EXPECT_EQ(0, tester.GetDismissCount( | 2835 EXPECT_EQ(0, tester.GetDismissCount( |
2827 kOrigin2, content::PermissionType::NOTIFICATIONS)); | 2836 kOrigin2, content::PermissionType::NOTIFICATIONS)); |
2828 | 2837 |
2829 BlockUntilBrowsingDataRemoved(browsing_data::LAST_HOUR, | 2838 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), |
2830 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, | 2839 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
2831 false); | 2840 false); |
2832 | 2841 |
2833 // Everything should be gone. | 2842 // Everything should be gone. |
2834 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2843 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2835 content::PermissionType::GEOLOCATION)); | 2844 content::PermissionType::GEOLOCATION)); |
2836 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, | 2845 EXPECT_EQ(0, tester.GetIgnoreCount(kOrigin1, |
2837 content::PermissionType::NOTIFICATIONS)); | 2846 content::PermissionType::NOTIFICATIONS)); |
2838 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, | 2847 EXPECT_EQ(0, tester.GetDismissCount(kOrigin1, |
2839 content::PermissionType::MIDI_SYSEX)); | 2848 content::PermissionType::MIDI_SYSEX)); |
(...skipping 13 matching lines...) Expand all Loading... |
2853 tester.AddDomain(kOrigin3.host()); | 2862 tester.AddDomain(kOrigin3.host()); |
2854 | 2863 |
2855 std::vector<std::string> expected = { | 2864 std::vector<std::string> expected = { |
2856 kOrigin1.host(), kOrigin2.host(), kOrigin3.host() }; | 2865 kOrigin1.host(), kOrigin2.host(), kOrigin3.host() }; |
2857 EXPECT_EQ(expected, tester.GetDomains()); | 2866 EXPECT_EQ(expected, tester.GetDomains()); |
2858 | 2867 |
2859 // Delete data with a filter for the registrable domain of |kOrigin3|. | 2868 // Delete data with a filter for the registrable domain of |kOrigin3|. |
2860 RegistrableDomainFilterBuilder filter_builder( | 2869 RegistrableDomainFilterBuilder filter_builder( |
2861 RegistrableDomainFilterBuilder::WHITELIST); | 2870 RegistrableDomainFilterBuilder::WHITELIST); |
2862 filter_builder.AddRegisterableDomain(kTestRegisterableDomain3); | 2871 filter_builder.AddRegisterableDomain(kTestRegisterableDomain3); |
2863 BlockUntilOriginDataRemoved(browsing_data::ALL_TIME, | 2872 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), |
2864 BrowsingDataRemover::REMOVE_PLUGIN_DATA, | 2873 BrowsingDataRemover::REMOVE_PLUGIN_DATA, |
2865 filter_builder); | 2874 filter_builder); |
2866 | 2875 |
2867 // Plugin data for |kOrigin3.host()| should have been removed. | 2876 // Plugin data for |kOrigin3.host()| should have been removed. |
2868 expected.pop_back(); | 2877 expected.pop_back(); |
2869 EXPECT_EQ(expected, tester.GetDomains()); | 2878 EXPECT_EQ(expected, tester.GetDomains()); |
2870 | 2879 |
2871 // TODO(msramek): Mock PluginDataRemover and test the complete deletion | 2880 // TODO(msramek): Mock PluginDataRemover and test the complete deletion |
2872 // of plugin data as well. | 2881 // of plugin data as well. |
2873 } | 2882 } |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2938 new RegistrableDomainFilterBuilder( | 2947 new RegistrableDomainFilterBuilder( |
2939 RegistrableDomainFilterBuilder::BLACKLIST)); | 2948 RegistrableDomainFilterBuilder::BLACKLIST)); |
2940 filter_builder_2->AddRegisterableDomain("example.com"); | 2949 filter_builder_2->AddRegisterableDomain("example.com"); |
2941 | 2950 |
2942 MultipleTasksObserver observer(remover); | 2951 MultipleTasksObserver observer(remover); |
2943 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; | 2952 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; |
2944 | 2953 |
2945 // Test several tasks with various configuration of masks, filters, and target | 2954 // Test several tasks with various configuration of masks, filters, and target |
2946 // observers. | 2955 // observers. |
2947 std::list<BrowsingDataRemover::RemovalTask> tasks; | 2956 std::list<BrowsingDataRemover::RemovalTask> tasks; |
2948 tasks.emplace_back(BrowsingDataRemover::Unbounded(), | 2957 tasks.emplace_back(base::Time(), base::Time::Max(), |
2949 BrowsingDataRemover::REMOVE_HISTORY, | 2958 BrowsingDataRemover::REMOVE_HISTORY, |
2950 BrowsingDataHelper::UNPROTECTED_WEB, | 2959 BrowsingDataHelper::UNPROTECTED_WEB, |
2951 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2960 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2952 RegistrableDomainFilterBuilder::BLACKLIST), | 2961 RegistrableDomainFilterBuilder::BLACKLIST), |
2953 observer.target_a()); | 2962 observer.target_a()); |
2954 tasks.emplace_back(BrowsingDataRemover::Unbounded(), | 2963 tasks.emplace_back(base::Time(), base::Time::Max(), |
2955 BrowsingDataRemover::REMOVE_COOKIES, | 2964 BrowsingDataRemover::REMOVE_COOKIES, |
2956 BrowsingDataHelper::PROTECTED_WEB, | 2965 BrowsingDataHelper::PROTECTED_WEB, |
2957 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2966 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2958 RegistrableDomainFilterBuilder::BLACKLIST), | 2967 RegistrableDomainFilterBuilder::BLACKLIST), |
2959 nullptr); | 2968 nullptr); |
2960 tasks.emplace_back( | 2969 tasks.emplace_back( |
2961 BrowsingDataRemover::TimeRange(base::Time::Now(), base::Time::Max()), | 2970 base::Time::Now(), base::Time::Max(), |
2962 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL, | 2971 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL, |
2963 base::MakeUnique<RegistrableDomainFilterBuilder>( | 2972 base::MakeUnique<RegistrableDomainFilterBuilder>( |
2964 RegistrableDomainFilterBuilder::BLACKLIST), | 2973 RegistrableDomainFilterBuilder::BLACKLIST), |
2965 observer.target_b()); | 2974 observer.target_b()); |
2966 tasks.emplace_back( | 2975 tasks.emplace_back( |
2967 BrowsingDataRemover::TimeRange(base::Time(), base::Time::UnixEpoch()), | 2976 base::Time(), base::Time::UnixEpoch(), |
2968 BrowsingDataRemover::REMOVE_WEBSQL, | 2977 BrowsingDataRemover::REMOVE_WEBSQL, |
2969 BrowsingDataHelper::UNPROTECTED_WEB, | 2978 BrowsingDataHelper::UNPROTECTED_WEB, |
2970 std::move(filter_builder_1), | 2979 std::move(filter_builder_1), |
2971 observer.target_b()); | 2980 observer.target_b()); |
2972 tasks.emplace_back( | 2981 tasks.emplace_back( |
2973 BrowsingDataRemover::TimeRange( | 2982 base::Time::UnixEpoch(), base::Time::Now(), |
2974 base::Time::UnixEpoch(), base::Time::Now()), | |
2975 BrowsingDataRemover::REMOVE_CHANNEL_IDS, | 2983 BrowsingDataRemover::REMOVE_CHANNEL_IDS, |
2976 BrowsingDataHelper::ALL, | 2984 BrowsingDataHelper::ALL, |
2977 std::move(filter_builder_2), | 2985 std::move(filter_builder_2), |
2978 nullptr); | 2986 nullptr); |
2979 | 2987 |
2980 for (BrowsingDataRemover::RemovalTask& task : tasks) { | 2988 for (BrowsingDataRemover::RemovalTask& task : tasks) { |
2981 // All tasks can be directly translated to a RemoveInternal() call. Since | 2989 // All tasks can be directly translated to a RemoveInternal() call. Since |
2982 // that is a private method, we must call the four public versions of | 2990 // that is a private method, we must call the four public versions of |
2983 // Remove.* instead. This also serves as a test that those methods are all | 2991 // Remove.* instead. This also serves as a test that those methods are all |
2984 // correctly reduced to RemoveInternal(). | 2992 // correctly reduced to RemoveInternal(). |
2985 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) { | 2993 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) { |
2986 remover->Remove(task.time_range, task.remove_mask, task.origin_type_mask); | 2994 remover->Remove(task.delete_begin, task.delete_end, |
| 2995 task.remove_mask, task.origin_type_mask); |
2987 } else if (task.filter_builder->IsEmptyBlacklist()) { | 2996 } else if (task.filter_builder->IsEmptyBlacklist()) { |
2988 remover->RemoveAndReply(task.time_range, task.remove_mask, | 2997 remover->RemoveAndReply(task.delete_begin, task.delete_end, |
2989 task.origin_type_mask, task.observer); | 2998 task.remove_mask, task.origin_type_mask, |
| 2999 task.observer); |
2990 } else if (!task.observer) { | 3000 } else if (!task.observer) { |
2991 remover->RemoveWithFilter(task.time_range, task.remove_mask, | 3001 remover->RemoveWithFilter(task.delete_begin, task.delete_end, |
2992 task.origin_type_mask, | 3002 task.remove_mask, task.origin_type_mask, |
2993 std::move(task.filter_builder)); | 3003 std::move(task.filter_builder)); |
2994 } else { | 3004 } else { |
2995 remover->RemoveWithFilterAndReply(task.time_range, task.remove_mask, | 3005 remover->RemoveWithFilterAndReply(task.delete_begin, task.delete_end, |
2996 task.origin_type_mask, | 3006 task.remove_mask, task.origin_type_mask, |
2997 std::move(task.filter_builder), | 3007 std::move(task.filter_builder), |
2998 task.observer); | 3008 task.observer); |
2999 } | 3009 } |
3000 } | 3010 } |
3001 | 3011 |
3002 // Use the inhibitor to stop after every task and check the results. | 3012 // Use the inhibitor to stop after every task and check the results. |
3003 for (BrowsingDataRemover::RemovalTask& task : tasks) { | 3013 for (BrowsingDataRemover::RemovalTask& task : tasks) { |
3004 EXPECT_TRUE(remover->is_removing()); | 3014 EXPECT_TRUE(remover->is_removing()); |
3005 observer.ClearLastCalledTarget(); | 3015 observer.ClearLastCalledTarget(); |
3006 | 3016 |
3007 // Finish the task execution synchronously. | 3017 // Finish the task execution synchronously. |
3008 completion_inhibitor.BlockUntilNearCompletion(); | 3018 completion_inhibitor.BlockUntilNearCompletion(); |
3009 completion_inhibitor.ContinueToCompletion(); | 3019 completion_inhibitor.ContinueToCompletion(); |
3010 | 3020 |
3011 // Observers, if any, should have been called by now (since we call | 3021 // Observers, if any, should have been called by now (since we call |
3012 // observers on the same thread). | 3022 // observers on the same thread). |
3013 EXPECT_EQ(task.observer, observer.GetLastCalledTarget()); | 3023 EXPECT_EQ(task.observer, observer.GetLastCalledTarget()); |
3014 | 3024 |
3015 // TODO(msramek): If BrowsingDataRemover took ownership of the last used | 3025 // TODO(msramek): If BrowsingDataRemover took ownership of the last used |
3016 // filter builder and exposed it, we could also test it here. Make it so. | 3026 // filter builder and exposed it, we could also test it here. Make it so. |
3017 EXPECT_EQ(task.remove_mask, GetRemovalMask()); | 3027 EXPECT_EQ(task.remove_mask, GetRemovalMask()); |
3018 EXPECT_EQ(task.origin_type_mask, GetOriginTypeMask()); | 3028 EXPECT_EQ(task.origin_type_mask, GetOriginTypeMask()); |
3019 EXPECT_EQ(task.time_range.begin, GetBeginTime()); | 3029 EXPECT_EQ(task.delete_begin, GetBeginTime()); |
3020 } | 3030 } |
3021 | 3031 |
3022 EXPECT_FALSE(remover->is_removing()); | 3032 EXPECT_FALSE(remover->is_removing()); |
3023 } | 3033 } |
3024 | 3034 |
3025 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the | 3035 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the |
3026 // tasks are not mixed up and they are executed in a correct order. However, | 3036 // tasks are not mixed up and they are executed in a correct order. However, |
3027 // the completion inhibitor kept synchronizing the execution in order to verify | 3037 // the completion inhibitor kept synchronizing the execution in order to verify |
3028 // the parameters. This test demonstrates that even running the tasks without | 3038 // the parameters. This test demonstrates that even running the tasks without |
3029 // inhibition is executed correctly and doesn't crash. | 3039 // inhibition is executed correctly and doesn't crash. |
(...skipping 14 matching lines...) Expand all Loading... |
3044 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, | 3054 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, |
3045 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, | 3055 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, |
3046 BrowsingDataRemover::REMOVE_COOKIES | | 3056 BrowsingDataRemover::REMOVE_COOKIES | |
3047 BrowsingDataRemover::REMOVE_HISTORY | | 3057 BrowsingDataRemover::REMOVE_HISTORY | |
3048 BrowsingDataRemover::REMOVE_PASSWORDS, | 3058 BrowsingDataRemover::REMOVE_PASSWORDS, |
3049 BrowsingDataRemover::REMOVE_PASSWORDS, | 3059 BrowsingDataRemover::REMOVE_PASSWORDS, |
3050 BrowsingDataRemover::REMOVE_PASSWORDS, | 3060 BrowsingDataRemover::REMOVE_PASSWORDS, |
3051 }; | 3061 }; |
3052 | 3062 |
3053 for (int removal_mask : test_removal_masks) { | 3063 for (int removal_mask : test_removal_masks) { |
3054 remover->Remove(BrowsingDataRemover::Unbounded(), removal_mask, | 3064 remover->Remove(base::Time(), base::Time::Max(), removal_mask, |
3055 BrowsingDataHelper::UNPROTECTED_WEB); | 3065 BrowsingDataHelper::UNPROTECTED_WEB); |
3056 } | 3066 } |
3057 | 3067 |
3058 EXPECT_TRUE(remover->is_removing()); | 3068 EXPECT_TRUE(remover->is_removing()); |
3059 | 3069 |
3060 // Add one more deletion and wait for it. | 3070 // Add one more deletion and wait for it. |
3061 BlockUntilBrowsingDataRemoved( | 3071 BlockUntilBrowsingDataRemoved( |
3062 browsing_data::ALL_TIME, | 3072 base::Time(), base::Time::Max(), |
3063 BrowsingDataRemover::REMOVE_COOKIES, | 3073 BrowsingDataRemover::REMOVE_COOKIES, |
3064 BrowsingDataHelper::UNPROTECTED_WEB); | 3074 BrowsingDataHelper::UNPROTECTED_WEB); |
3065 | 3075 |
3066 EXPECT_FALSE(remover->is_removing()); | 3076 EXPECT_FALSE(remover->is_removing()); |
3067 } | 3077 } |
3068 | 3078 |
3069 // Test that the remover clears bookmark meta data (normally added in a tab | 3079 // Test that the remover clears bookmark meta data (normally added in a tab |
3070 // helper). | 3080 // helper). |
3071 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { | 3081 TEST_F(BrowsingDataRemoverTest, BookmarkLastVisitDatesGetCleared) { |
3072 TestingProfile profile; | 3082 TestingProfile profile; |
(...skipping 23 matching lines...) Expand all Loading... |
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 Not(IsEmpty())); | 3109 Not(IsEmpty())); |
3100 | 3110 |
3101 // Inject the bookmark model into the remover. | 3111 // Inject the bookmark model into the remover. |
3102 BrowsingDataRemover* remover = | 3112 BrowsingDataRemover* remover = |
3103 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); | 3113 BrowsingDataRemoverFactory::GetForBrowserContext(&profile); |
3104 | 3114 |
3105 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 3115 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
3106 remover->RemoveAndReply(BrowsingDataRemover::Unbounded(), | 3116 remover->RemoveAndReply(base::Time(), base::Time::Max(), |
3107 BrowsingDataRemover::REMOVE_HISTORY, | 3117 BrowsingDataRemover::REMOVE_HISTORY, |
3108 BrowsingDataHelper::ALL, &completion_observer); | 3118 BrowsingDataHelper::ALL, &completion_observer); |
3109 completion_observer.BlockUntilCompletion(); | 3119 completion_observer.BlockUntilCompletion(); |
3110 | 3120 |
3111 // There should be no recently visited bookmarks. | 3121 // There should be no recently visited bookmarks. |
3112 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( | 3122 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
3113 bookmark_model, 2, base::Time::UnixEpoch(), | 3123 bookmark_model, 2, base::Time::UnixEpoch(), |
3114 /*consider_visits_from_desktop=*/false), | 3124 /*consider_visits_from_desktop=*/false), |
3115 IsEmpty()); | 3125 IsEmpty()); |
3116 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( | 3126 EXPECT_THAT(ntp_snippets::GetRecentlyVisitedBookmarks( |
3117 bookmark_model, 2, base::Time::UnixEpoch(), | 3127 bookmark_model, 2, base::Time::UnixEpoch(), |
3118 /*consider_visits_from_desktop=*/true), | 3128 /*consider_visits_from_desktop=*/true), |
3119 IsEmpty()); | 3129 IsEmpty()); |
3120 } | 3130 } |
OLD | NEW |