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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_remover_impl_unittest.cc

Issue 2697123004: Convert RemoveDataMask from enum to pointers and split it between content and embedder (Closed)
Patch Set: More compilation error fixes. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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 <stddef.h> 5 #include <stddef.h>
6 #include <stdint.h> 6 #include <stdint.h>
7 7
8 #include <list> 8 #include <list>
9 #include <memory> 9 #include <memory>
10 #include <set> 10 #include <set>
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 61
62 #if BUILDFLAG(ENABLE_EXTENSIONS) 62 #if BUILDFLAG(ENABLE_EXTENSIONS)
63 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" 63 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
64 #endif 64 #endif
65 65
66 class MockExtensionSpecialStoragePolicy; 66 class MockExtensionSpecialStoragePolicy;
67 67
68 using content::BrowserThread; 68 using content::BrowserThread;
69 using content::BrowserContext; 69 using content::BrowserContext;
70 using content::BrowsingDataFilterBuilder; 70 using content::BrowsingDataFilterBuilder;
71 using content::BrowsingDataType;
71 using content::StoragePartition; 72 using content::StoragePartition;
72 using testing::_; 73 using testing::_;
73 using testing::ByRef; 74 using testing::ByRef;
74 using testing::Eq; 75 using testing::Eq;
75 using testing::Invoke; 76 using testing::Invoke;
76 using testing::IsEmpty; 77 using testing::IsEmpty;
77 using testing::Matcher; 78 using testing::Matcher;
78 using testing::MakeMatcher; 79 using testing::MakeMatcher;
79 using testing::MatcherInterface; 80 using testing::MatcherInterface;
80 using testing::MatchResultListener; 81 using testing::MatchResultListener;
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 301
301 inline Matcher<const base::Callback<bool(const GURL&)>&> ProbablySameFilter( 302 inline Matcher<const base::Callback<bool(const GURL&)>&> ProbablySameFilter(
302 const base::Callback<bool(const GURL&)>& filter) { 303 const base::Callback<bool(const GURL&)>& filter) {
303 return MakeMatcher(new ProbablySameFilterMatcher(filter)); 304 return MakeMatcher(new ProbablySameFilterMatcher(filter));
304 } 305 }
305 306
306 base::Time AnHourAgo() { 307 base::Time AnHourAgo() {
307 return base::Time::Now() - base::TimeDelta::FromHours(1); 308 return base::Time::Now() - base::TimeDelta::FromHours(1);
308 } 309 }
309 310
311 const std::set<const BrowsingDataType*> kQuotaMask = {
312 &content::kBrowsingDataTypeFileSystems,
313 &content::kBrowsingDataTypeWebSQL,
314 &content::kBrowsingDataTypeAppCache,
315 &content::kBrowsingDataTypeServiceWorkers,
316 &content::kBrowsingDataTypeCacheStorage,
317 &content::kBrowsingDataTypeIndexedDB
318 };
319
320 // A wrapper to typecast a const initializer to std::set in ambiguous
321 // situations, such as the EXPECT macros.
322 inline const std::set<const BrowsingDataType*> Mask(
323 const std::set<const BrowsingDataType*> mask) {
324 return mask;
325 }
326
310 } // namespace 327 } // namespace
311 328
312 // Testers ------------------------------------------------------------------- 329 // Testers -------------------------------------------------------------------
313 330
314 class RemoveCookieTester { 331 class RemoveCookieTester {
315 public: 332 public:
316 RemoveCookieTester() {} 333 RemoveCookieTester() {}
317 334
318 // Returns true, if the given cookie exists in the cookie store. 335 // Returns true, if the given cookie exists in the cookie store.
319 bool ContainsCookie() { 336 bool ContainsCookie() {
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 572
556 // BrowserContext contains a DOMStorageContext. BrowserContext's 573 // BrowserContext contains a DOMStorageContext. BrowserContext's
557 // destructor posts a message to the WEBKIT thread to delete some of its 574 // destructor posts a message to the WEBKIT thread to delete some of its
558 // member variables. We need to ensure that the browser context is 575 // member variables. We need to ensure that the browser context is
559 // destroyed, and that the message loop is cleared out, before destroying 576 // destroyed, and that the message loop is cleared out, before destroying
560 // the threads and loop. Otherwise we leak memory. 577 // the threads and loop. Otherwise we leak memory.
561 browser_context_.reset(); 578 browser_context_.reset();
562 base::RunLoop().RunUntilIdle(); 579 base::RunLoop().RunUntilIdle();
563 } 580 }
564 581
565 void BlockUntilBrowsingDataRemoved(const base::Time& delete_begin, 582 void BlockUntilBrowsingDataRemoved(
566 const base::Time& delete_end, 583 const base::Time& delete_begin,
567 int remove_mask, 584 const base::Time& delete_end,
568 bool include_protected_origins) { 585 const std::set<const BrowsingDataType*> remove_mask,
586 bool include_protected_origins) {
569 TestStoragePartition storage_partition; 587 TestStoragePartition storage_partition;
570 remover_->OverrideStoragePartitionForTesting(&storage_partition); 588 remover_->OverrideStoragePartitionForTesting(&storage_partition);
571 589
572 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB; 590 int origin_type_mask = BrowsingDataHelper::UNPROTECTED_WEB;
573 if (include_protected_origins) 591 if (include_protected_origins)
574 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB; 592 origin_type_mask |= BrowsingDataHelper::PROTECTED_WEB;
575 593
576 BrowsingDataRemoverCompletionObserver completion_observer(remover_); 594 BrowsingDataRemoverCompletionObserver completion_observer(remover_);
577 remover_->RemoveAndReply( 595 remover_->RemoveAndReply(
578 delete_begin, delete_end, remove_mask, origin_type_mask, 596 delete_begin, delete_end, remove_mask, origin_type_mask,
579 &completion_observer); 597 &completion_observer);
580 completion_observer.BlockUntilCompletion(); 598 completion_observer.BlockUntilCompletion();
581 599
582 // Save so we can verify later. 600 // Save so we can verify later.
583 storage_partition_removal_data_ = 601 storage_partition_removal_data_ =
584 storage_partition.GetStoragePartitionRemovalData(); 602 storage_partition.GetStoragePartitionRemovalData();
585 } 603 }
586 604
587 void BlockUntilOriginDataRemoved( 605 void BlockUntilOriginDataRemoved(
588 const base::Time& delete_begin, 606 const base::Time& delete_begin,
589 const base::Time& delete_end, 607 const base::Time& delete_end,
590 int remove_mask, 608 const std::set<const BrowsingDataType*> remove_mask,
591 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) { 609 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder) {
592 TestStoragePartition storage_partition; 610 TestStoragePartition storage_partition;
593 remover_->OverrideStoragePartitionForTesting(&storage_partition); 611 remover_->OverrideStoragePartitionForTesting(&storage_partition);
594 612
595 BrowsingDataRemoverCompletionObserver completion_observer(remover_); 613 BrowsingDataRemoverCompletionObserver completion_observer(remover_);
596 remover_->RemoveWithFilterAndReply( 614 remover_->RemoveWithFilterAndReply(
597 delete_begin, delete_end, remove_mask, 615 delete_begin, delete_end, remove_mask,
598 BrowsingDataHelper::UNPROTECTED_WEB, 616 BrowsingDataHelper::UNPROTECTED_WEB,
599 std::move(filter_builder), &completion_observer); 617 std::move(filter_builder), &completion_observer);
600 completion_observer.BlockUntilCompletion(); 618 completion_observer.BlockUntilCompletion();
601 619
602 // Save so we can verify later. 620 // Save so we can verify later.
603 storage_partition_removal_data_ = 621 storage_partition_removal_data_ =
604 storage_partition.GetStoragePartitionRemovalData(); 622 storage_partition.GetStoragePartitionRemovalData();
605 } 623 }
606 624
607 BrowserContext* GetBrowserContext() { 625 BrowserContext* GetBrowserContext() {
608 return browser_context_.get(); 626 return browser_context_.get();
609 } 627 }
610 628
611 void DestroyBrowserContext() { browser_context_.reset(); } 629 void DestroyBrowserContext() { browser_context_.reset(); }
612 630
613 const base::Time& GetBeginTime() { 631 const base::Time& GetBeginTime() {
614 return remover_->GetLastUsedBeginTime(); 632 return remover_->GetLastUsedBeginTime();
615 } 633 }
616 634
617 int GetRemovalMask() { 635 const std::set<const content::BrowsingDataType*>& GetRemovalMask() {
618 return remover_->GetLastUsedRemovalMask(); 636 return remover_->GetLastUsedRemovalMask();
619 } 637 }
620 638
621 int GetOriginTypeMask() { 639 int GetOriginTypeMask() {
622 return remover_->GetLastUsedOriginTypeMask(); 640 return remover_->GetLastUsedOriginTypeMask();
623 } 641 }
624 642
625 StoragePartitionRemovalData GetStoragePartitionRemovalData() { 643 StoragePartitionRemovalData GetStoragePartitionRemovalData() {
626 return storage_partition_removal_data_; 644 return storage_partition_removal_data_;
627 } 645 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
666 #if BUILDFLAG(ENABLE_EXTENSIONS) 684 #if BUILDFLAG(ENABLE_EXTENSIONS)
667 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_; 685 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_;
668 #endif 686 #endif
669 687
670 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverImplTest); 688 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverImplTest);
671 }; 689 };
672 690
673 // Tests --------------------------------------------------------------------- 691 // Tests ---------------------------------------------------------------------
674 692
675 TEST_F(BrowsingDataRemoverImplTest, RemoveCookieForever) { 693 TEST_F(BrowsingDataRemoverImplTest, RemoveCookieForever) {
676 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 694 BlockUntilBrowsingDataRemoved(
677 BrowsingDataRemover::REMOVE_COOKIES, false); 695 base::Time(), base::Time::Max(),
696 Mask({ &content::kBrowsingDataTypeCookies }), false);
678 697
679 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); 698 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeCookies }), GetRemovalMask());
680 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 699 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
681 700
682 // Verify that storage partition was instructed to remove the cookies. 701 // Verify that storage partition was instructed to remove the cookies.
683 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 702 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
684 EXPECT_EQ(removal_data.remove_mask, 703 EXPECT_EQ(removal_data.remove_mask,
685 StoragePartition::REMOVE_DATA_MASK_COOKIES); 704 StoragePartition::REMOVE_DATA_MASK_COOKIES);
686 EXPECT_EQ(removal_data.quota_storage_remove_mask, 705 EXPECT_EQ(removal_data.quota_storage_remove_mask,
687 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 706 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
688 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 707 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
689 } 708 }
690 709
691 TEST_F(BrowsingDataRemoverImplTest, RemoveCookieLastHour) { 710 TEST_F(BrowsingDataRemoverImplTest, RemoveCookieLastHour) {
692 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), 711 BlockUntilBrowsingDataRemoved(
693 BrowsingDataRemover::REMOVE_COOKIES, false); 712 AnHourAgo(), base::Time::Max(),
713 Mask({ &content::kBrowsingDataTypeCookies }), false);
694 714
695 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); 715 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeCookies }), GetRemovalMask());
696 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 716 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
697 717
698 // Verify that storage partition was instructed to remove the cookies. 718 // Verify that storage partition was instructed to remove the cookies.
699 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 719 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
700 EXPECT_EQ(removal_data.remove_mask, 720 EXPECT_EQ(removal_data.remove_mask,
701 StoragePartition::REMOVE_DATA_MASK_COOKIES); 721 StoragePartition::REMOVE_DATA_MASK_COOKIES);
702 // Removing with time period other than all time should not clear 722 // Removing with time period other than all time should not clear
703 // persistent storage data. 723 // persistent storage data.
704 EXPECT_EQ(removal_data.quota_storage_remove_mask, 724 EXPECT_EQ(removal_data.quota_storage_remove_mask,
705 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); 725 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT);
706 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 726 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
707 } 727 }
708 728
709 TEST_F(BrowsingDataRemoverImplTest, RemoveCookiesDomainBlacklist) { 729 TEST_F(BrowsingDataRemoverImplTest, RemoveCookiesDomainBlacklist) {
710 std::unique_ptr<BrowsingDataFilterBuilder> filter( 730 std::unique_ptr<BrowsingDataFilterBuilder> filter(
711 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST)); 731 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST));
712 filter->AddRegisterableDomain(kTestRegisterableDomain1); 732 filter->AddRegisterableDomain(kTestRegisterableDomain1);
713 filter->AddRegisterableDomain(kTestRegisterableDomain3); 733 filter->AddRegisterableDomain(kTestRegisterableDomain3);
714 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(), 734 BlockUntilOriginDataRemoved(AnHourAgo(), base::Time::Max(),
715 BrowsingDataRemover::REMOVE_COOKIES, 735 { &content::kBrowsingDataTypeCookies },
716 std::move(filter)); 736 std::move(filter));
717 737
718 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); 738 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeCookies }), GetRemovalMask());
719 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 739 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
720 740
721 // Verify that storage partition was instructed to remove the cookies. 741 // Verify that storage partition was instructed to remove the cookies.
722 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 742 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
723 EXPECT_EQ(removal_data.remove_mask, 743 EXPECT_EQ(removal_data.remove_mask,
724 StoragePartition::REMOVE_DATA_MASK_COOKIES); 744 StoragePartition::REMOVE_DATA_MASK_COOKIES);
725 // Removing with time period other than all time should not clear 745 // Removing with time period other than all time should not clear
726 // persistent storage data. 746 // persistent storage data.
727 EXPECT_EQ(removal_data.quota_storage_remove_mask, 747 EXPECT_EQ(removal_data.quota_storage_remove_mask,
728 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); 748 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT);
(...skipping 25 matching lines...) Expand all
754 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache(); 774 net::HttpAuthCache* http_auth_cache = http_session->http_auth_cache();
755 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC, 775 http_auth_cache->Add(kOrigin1, kTestRealm, net::HttpAuth::AUTH_SCHEME_BASIC,
756 "test challenge", 776 "test challenge",
757 net::AuthCredentials(base::ASCIIToUTF16("foo"), 777 net::AuthCredentials(base::ASCIIToUTF16("foo"),
758 base::ASCIIToUTF16("bar")), 778 base::ASCIIToUTF16("bar")),
759 "/"); 779 "/");
760 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm, 780 CHECK(http_auth_cache->Lookup(kOrigin1, kTestRealm,
761 net::HttpAuth::AUTH_SCHEME_BASIC)); 781 net::HttpAuth::AUTH_SCHEME_BASIC));
762 782
763 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 783 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
764 BrowsingDataRemover::REMOVE_COOKIES, false); 784 { &content::kBrowsingDataTypeCookies }, false);
765 785
766 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm, 786 EXPECT_EQ(nullptr, http_auth_cache->Lookup(kOrigin1, kTestRealm,
767 net::HttpAuth::AUTH_SCHEME_BASIC)); 787 net::HttpAuth::AUTH_SCHEME_BASIC));
768 } 788 }
769 789
770 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDForever) { 790 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDForever) {
771 RemoveChannelIDTester tester(GetBrowserContext()); 791 RemoveChannelIDTester tester(GetBrowserContext());
772 792
773 tester.AddChannelID(kTestOrigin1); 793 tester.AddChannelID(kTestOrigin1);
774 EXPECT_EQ(0, tester.ssl_config_changed_count()); 794 EXPECT_EQ(0, tester.ssl_config_changed_count());
775 EXPECT_EQ(1, tester.ChannelIDCount()); 795 EXPECT_EQ(1, tester.ChannelIDCount());
776 796
777 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 797 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
778 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); 798 { &content::kBrowsingDataTypeChannelIDs },
799 false);
779 800
780 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); 801 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeChannelIDs }), GetRemovalMask());
781 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 802 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
782 EXPECT_EQ(1, tester.ssl_config_changed_count()); 803 EXPECT_EQ(1, tester.ssl_config_changed_count());
783 EXPECT_EQ(0, tester.ChannelIDCount()); 804 EXPECT_EQ(0, tester.ChannelIDCount());
784 } 805 }
785 806
786 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDLastHour) { 807 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDLastHour) {
787 RemoveChannelIDTester tester(GetBrowserContext()); 808 RemoveChannelIDTester tester(GetBrowserContext());
788 809
789 base::Time now = base::Time::Now(); 810 base::Time now = base::Time::Now();
790 tester.AddChannelID(kTestOrigin1); 811 tester.AddChannelID(kTestOrigin1);
791 tester.AddChannelIDWithTimes(kTestOrigin2, 812 tester.AddChannelIDWithTimes(kTestOrigin2,
792 now - base::TimeDelta::FromHours(2)); 813 now - base::TimeDelta::FromHours(2));
793 EXPECT_EQ(0, tester.ssl_config_changed_count()); 814 EXPECT_EQ(0, tester.ssl_config_changed_count());
794 EXPECT_EQ(2, tester.ChannelIDCount()); 815 EXPECT_EQ(2, tester.ChannelIDCount());
795 816
796 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(), 817 BlockUntilBrowsingDataRemoved(AnHourAgo(), base::Time::Max(),
797 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); 818 { &content::kBrowsingDataTypeChannelIDs },
819 false);
798 820
799 EXPECT_EQ(BrowsingDataRemover::REMOVE_CHANNEL_IDS, GetRemovalMask()); 821 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeChannelIDs }), GetRemovalMask());
800 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 822 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
801 EXPECT_EQ(1, tester.ssl_config_changed_count()); 823 EXPECT_EQ(1, tester.ssl_config_changed_count());
802 ASSERT_EQ(1, tester.ChannelIDCount()); 824 ASSERT_EQ(1, tester.ChannelIDCount());
803 net::ChannelIDStore::ChannelIDList channel_ids; 825 net::ChannelIDStore::ChannelIDList channel_ids;
804 tester.GetChannelIDList(&channel_ids); 826 tester.GetChannelIDList(&channel_ids);
805 ASSERT_EQ(1U, channel_ids.size()); 827 ASSERT_EQ(1U, channel_ids.size());
806 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier()); 828 EXPECT_EQ(kTestOrigin2, channel_ids.front().server_identifier());
807 } 829 }
808 830
809 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDsForServerIdentifiers) { 831 TEST_F(BrowsingDataRemoverImplTest, RemoveChannelIDsForServerIdentifiers) {
810 RemoveChannelIDTester tester(GetBrowserContext()); 832 RemoveChannelIDTester tester(GetBrowserContext());
811 833
812 tester.AddChannelID(kTestRegisterableDomain1); 834 tester.AddChannelID(kTestRegisterableDomain1);
813 tester.AddChannelID(kTestRegisterableDomain3); 835 tester.AddChannelID(kTestRegisterableDomain3);
814 EXPECT_EQ(2, tester.ChannelIDCount()); 836 EXPECT_EQ(2, tester.ChannelIDCount());
815 837
816 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder( 838 std::unique_ptr<BrowsingDataFilterBuilder> filter_builder(
817 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST)); 839 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST));
818 filter_builder->AddRegisterableDomain(kTestRegisterableDomain1); 840 filter_builder->AddRegisterableDomain(kTestRegisterableDomain1);
819 841
820 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), 842 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
821 BrowsingDataRemover::REMOVE_CHANNEL_IDS, 843 { &content::kBrowsingDataTypeChannelIDs },
822 std::move(filter_builder)); 844 std::move(filter_builder));
823 845
824 EXPECT_EQ(1, tester.ChannelIDCount()); 846 EXPECT_EQ(1, tester.ChannelIDCount());
825 net::ChannelIDStore::ChannelIDList channel_ids; 847 net::ChannelIDStore::ChannelIDList channel_ids;
826 tester.GetChannelIDList(&channel_ids); 848 tester.GetChannelIDList(&channel_ids);
827 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); 849 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier());
828 } 850 }
829 851
830 TEST_F(BrowsingDataRemoverImplTest, RemoveUnprotectedLocalStorageForever) { 852 TEST_F(BrowsingDataRemoverImplTest, RemoveUnprotectedLocalStorageForever) {
831 #if BUILDFLAG(ENABLE_EXTENSIONS) 853 #if BUILDFLAG(ENABLE_EXTENSIONS)
832 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 854 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
833 // Protect kOrigin1. 855 // Protect kOrigin1.
834 policy->AddProtected(kOrigin1.GetOrigin()); 856 policy->AddProtected(kOrigin1.GetOrigin());
835 #endif 857 #endif
836 858
837 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 859 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
838 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, 860 { &content::kBrowsingDataTypeLocalStorage },
839 false); 861 false);
840 862
841 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 863 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeLocalStorage }),
864 GetRemovalMask());
842 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 865 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
843 866
844 // Verify that storage partition was instructed to remove the data correctly. 867 // Verify that storage partition was instructed to remove the data correctly.
845 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 868 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
846 EXPECT_EQ(removal_data.remove_mask, 869 EXPECT_EQ(removal_data.remove_mask,
847 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); 870 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE);
848 EXPECT_EQ(removal_data.quota_storage_remove_mask, 871 EXPECT_EQ(removal_data.quota_storage_remove_mask,
849 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 872 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
850 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 873 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
851 874
852 // Check origin matcher. 875 // Check origin matcher.
853 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), 876 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(),
854 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 877 removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
855 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 878 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
856 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 879 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
857 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); 880 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy()));
858 } 881 }
859 882
860 TEST_F(BrowsingDataRemoverImplTest, RemoveProtectedLocalStorageForever) { 883 TEST_F(BrowsingDataRemoverImplTest, RemoveProtectedLocalStorageForever) {
861 #if BUILDFLAG(ENABLE_EXTENSIONS) 884 #if BUILDFLAG(ENABLE_EXTENSIONS)
862 // Protect kOrigin1. 885 // Protect kOrigin1.
863 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 886 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
864 policy->AddProtected(kOrigin1.GetOrigin()); 887 policy->AddProtected(kOrigin1.GetOrigin());
865 #endif 888 #endif
866 889
867 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 890 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
868 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, 891 { &content::kBrowsingDataTypeLocalStorage },
869 true); 892 true);
870 893
871 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 894 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeLocalStorage }),
895 GetRemovalMask());
872 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | 896 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB |
873 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); 897 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask());
874 898
875 // Verify that storage partition was instructed to remove the data correctly. 899 // Verify that storage partition was instructed to remove the data correctly.
876 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 900 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
877 EXPECT_EQ(removal_data.remove_mask, 901 EXPECT_EQ(removal_data.remove_mask,
878 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); 902 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE);
879 EXPECT_EQ(removal_data.quota_storage_remove_mask, 903 EXPECT_EQ(removal_data.quota_storage_remove_mask,
880 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 904 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
881 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 905 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
882 906
883 // Check origin matcher all http origin will match since we specified 907 // Check origin matcher all http origin will match since we specified
884 // both protected and unprotected. 908 // both protected and unprotected.
885 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 909 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
886 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 910 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
887 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 911 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
888 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); 912 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy()));
889 } 913 }
890 914
891 TEST_F(BrowsingDataRemoverImplTest, RemoveLocalStorageForLastWeek) { 915 TEST_F(BrowsingDataRemoverImplTest, RemoveLocalStorageForLastWeek) {
892 #if BUILDFLAG(ENABLE_EXTENSIONS) 916 #if BUILDFLAG(ENABLE_EXTENSIONS)
893 CreateMockPolicy(); 917 CreateMockPolicy();
894 #endif 918 #endif
895 919
896 BlockUntilBrowsingDataRemoved( 920 BlockUntilBrowsingDataRemoved(
897 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), 921 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(),
898 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, false); 922 { &content::kBrowsingDataTypeLocalStorage }, false);
899 923
900 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 924 EXPECT_EQ(Mask({ &content::kBrowsingDataTypeLocalStorage }),
925 GetRemovalMask());
901 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 926 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
902 927
903 // Verify that storage partition was instructed to remove the data correctly. 928 // Verify that storage partition was instructed to remove the data correctly.
904 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 929 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
905 EXPECT_EQ(removal_data.remove_mask, 930 EXPECT_EQ(removal_data.remove_mask,
906 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); 931 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE);
907 // Persistent storage won't be deleted. 932 // Persistent storage won't be deleted.
908 EXPECT_EQ(removal_data.quota_storage_remove_mask, 933 EXPECT_EQ(removal_data.quota_storage_remove_mask,
909 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); 934 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT);
910 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 935 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
911 936
912 // Check origin matcher. 937 // Check origin matcher.
913 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 938 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
914 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 939 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
915 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 940 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
916 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); 941 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy()));
917 } 942 }
918 943
919 TEST_F(BrowsingDataRemoverImplTest, RemoveMultipleTypes) { 944 TEST_F(BrowsingDataRemoverImplTest, RemoveMultipleTypes) {
920 // Downloads should be deleted through the DownloadManager, assure it would 945 // Downloads should be deleted through the DownloadManager, assure it would
921 // be called. 946 // be called.
922 RemoveDownloadsTester downloads_tester(GetBrowserContext()); 947 RemoveDownloadsTester downloads_tester(GetBrowserContext());
923 EXPECT_CALL(*downloads_tester.download_manager(), 948 EXPECT_CALL(*downloads_tester.download_manager(),
924 RemoveDownloadsByURLAndTime(_, _, _)); 949 RemoveDownloadsByURLAndTime(_, _, _));
925 950
926 int removal_mask = BrowsingDataRemover::REMOVE_DOWNLOADS | 951 std::set<const BrowsingDataType*> removal_mask =
927 BrowsingDataRemover::REMOVE_COOKIES; 952 { &content::kBrowsingDataTypeDownloads,
Bernhard Bauer 2017/02/17 11:10:43 Is this what clang-format produces? Sigh...
msramek 2017/02/17 18:00:20 *cough* that might have been me *cough* Sorry for
953 &content::kBrowsingDataTypeCookies };
928 954
929 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 955 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(),
930 removal_mask, false); 956 removal_mask, false);
931 957
932 EXPECT_EQ(removal_mask, GetRemovalMask()); 958 EXPECT_EQ(removal_mask, GetRemovalMask());
933 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 959 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
934 960
935 // The cookie would be deleted throught the StorageParition, check if the 961 // The cookie would be deleted throught the StorageParition, check if the
936 // partition was requested to remove cookie. 962 // partition was requested to remove cookie.
937 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 963 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
938 EXPECT_EQ(removal_data.remove_mask, 964 EXPECT_EQ(removal_data.remove_mask,
939 StoragePartition::REMOVE_DATA_MASK_COOKIES); 965 StoragePartition::REMOVE_DATA_MASK_COOKIES);
940 EXPECT_EQ(removal_data.quota_storage_remove_mask, 966 EXPECT_EQ(removal_data.quota_storage_remove_mask,
941 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 967 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
942 } 968 }
943 969
944 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverBoth) { 970 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverBoth) {
945 BlockUntilBrowsingDataRemoved( 971 BlockUntilBrowsingDataRemoved(
946 base::Time(), base::Time::Max(), 972 base::Time(), base::Time::Max(), kQuotaMask, false);
947 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
948 BrowsingDataRemover::REMOVE_WEBSQL |
949 BrowsingDataRemover::REMOVE_APPCACHE |
950 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
951 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
952 BrowsingDataRemover::REMOVE_INDEXEDDB,
953 false);
954 973
955 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 974 EXPECT_EQ(kQuotaMask, GetRemovalMask());
956 BrowsingDataRemover::REMOVE_WEBSQL |
957 BrowsingDataRemover::REMOVE_APPCACHE |
958 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
959 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
960 BrowsingDataRemover::REMOVE_INDEXEDDB,
961 GetRemovalMask());
962 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 975 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
963 976
964 // Verify storage partition related stuffs. 977 // Verify storage partition related stuffs.
965 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 978 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
966 EXPECT_EQ(removal_data.remove_mask, 979 EXPECT_EQ(removal_data.remove_mask,
967 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 980 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
968 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 981 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
969 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 982 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
970 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 983 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
971 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 984 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
972 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 985 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
973 EXPECT_EQ(removal_data.quota_storage_remove_mask, 986 EXPECT_EQ(removal_data.quota_storage_remove_mask,
974 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 987 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
975 } 988 }
976 989
977 TEST_F(BrowsingDataRemoverImplTest, 990 TEST_F(BrowsingDataRemoverImplTest,
978 RemoveQuotaManagedDataForeverOnlyTemporary) { 991 RemoveQuotaManagedDataForeverOnlyTemporary) {
979 #if BUILDFLAG(ENABLE_EXTENSIONS) 992 #if BUILDFLAG(ENABLE_EXTENSIONS)
980 CreateMockPolicy(); 993 CreateMockPolicy();
981 #endif 994 #endif
982 995
983 BlockUntilBrowsingDataRemoved( 996 BlockUntilBrowsingDataRemoved(
984 base::Time(), base::Time::Max(), 997 base::Time(), base::Time::Max(), kQuotaMask, false);
985 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
986 BrowsingDataRemover::REMOVE_WEBSQL |
987 BrowsingDataRemover::REMOVE_APPCACHE |
988 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
989 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
990 BrowsingDataRemover::REMOVE_INDEXEDDB,
991 false);
992 998
993 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 999 EXPECT_EQ(kQuotaMask, GetRemovalMask());
994 BrowsingDataRemover::REMOVE_WEBSQL |
995 BrowsingDataRemover::REMOVE_APPCACHE |
996 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
997 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
998 BrowsingDataRemover::REMOVE_INDEXEDDB,
999 GetRemovalMask());
1000 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1000 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1001 1001
1002 // Verify storage partition related stuffs. 1002 // Verify storage partition related stuffs.
1003 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1003 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1004 1004
1005 EXPECT_EQ(removal_data.remove_mask, 1005 EXPECT_EQ(removal_data.remove_mask,
1006 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1006 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1007 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1007 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1008 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1008 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1009 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1009 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1010 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1010 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1011 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1011 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1012 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1012 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1013 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1013 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1014 1014
1015 // Check that all related origin data would be removed, that is, origin 1015 // Check that all related origin data would be removed, that is, origin
1016 // matcher would match these origin. 1016 // matcher would match these origin.
1017 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1017 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1018 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1018 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1019 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1019 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1020 } 1020 }
1021 1021
1022 TEST_F(BrowsingDataRemoverImplTest, 1022 TEST_F(BrowsingDataRemoverImplTest,
1023 RemoveQuotaManagedDataForeverOnlyPersistent) { 1023 RemoveQuotaManagedDataForeverOnlyPersistent) {
1024 #if BUILDFLAG(ENABLE_EXTENSIONS) 1024 #if BUILDFLAG(ENABLE_EXTENSIONS)
1025 CreateMockPolicy(); 1025 CreateMockPolicy();
1026 #endif 1026 #endif
1027 1027
1028 BlockUntilBrowsingDataRemoved( 1028 BlockUntilBrowsingDataRemoved(
1029 base::Time(), base::Time::Max(), 1029 base::Time(), base::Time::Max(), kQuotaMask, false);
1030 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1031 BrowsingDataRemover::REMOVE_WEBSQL |
1032 BrowsingDataRemover::REMOVE_APPCACHE |
1033 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1034 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1035 BrowsingDataRemover::REMOVE_INDEXEDDB,
1036 false);
1037 1030
1038 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1031 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1039 BrowsingDataRemover::REMOVE_WEBSQL |
1040 BrowsingDataRemover::REMOVE_APPCACHE |
1041 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1042 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1043 BrowsingDataRemover::REMOVE_INDEXEDDB,
1044 GetRemovalMask());
1045 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1032 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1046 1033
1047 // Verify storage partition related stuffs. 1034 // Verify storage partition related stuffs.
1048 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1035 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1049 1036
1050 EXPECT_EQ(removal_data.remove_mask, 1037 EXPECT_EQ(removal_data.remove_mask,
1051 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1038 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1052 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1039 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1053 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1040 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1054 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1041 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1055 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1042 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1056 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1043 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1057 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1044 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1058 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1045 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1059 1046
1060 // Check that all related origin data would be removed, that is, origin 1047 // Check that all related origin data would be removed, that is, origin
1061 // matcher would match these origin. 1048 // matcher would match these origin.
1062 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1049 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1063 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1050 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1064 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1051 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1065 } 1052 }
1066 1053
1067 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverNeither) { 1054 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForeverNeither) {
1068 #if BUILDFLAG(ENABLE_EXTENSIONS) 1055 #if BUILDFLAG(ENABLE_EXTENSIONS)
1069 CreateMockPolicy(); 1056 CreateMockPolicy();
1070 #endif 1057 #endif
1071 1058
1072 BlockUntilBrowsingDataRemoved( 1059 BlockUntilBrowsingDataRemoved(
1073 base::Time(), base::Time::Max(), 1060 base::Time(), base::Time::Max(), kQuotaMask, false);
1074 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1075 BrowsingDataRemover::REMOVE_WEBSQL |
1076 BrowsingDataRemover::REMOVE_APPCACHE |
1077 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1078 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1079 BrowsingDataRemover::REMOVE_INDEXEDDB,
1080 false);
1081 1061
1082 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1062 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1083 BrowsingDataRemover::REMOVE_WEBSQL |
1084 BrowsingDataRemover::REMOVE_APPCACHE |
1085 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1086 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1087 BrowsingDataRemover::REMOVE_INDEXEDDB,
1088 GetRemovalMask());
1089 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1063 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1090 1064
1091 // Verify storage partition related stuffs. 1065 // Verify storage partition related stuffs.
1092 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1066 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1093 1067
1094 EXPECT_EQ(removal_data.remove_mask, 1068 EXPECT_EQ(removal_data.remove_mask,
1095 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1069 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1096 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1070 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1097 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1071 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1098 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1072 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1099 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1073 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1100 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1074 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1101 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1075 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1102 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1076 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1103 1077
1104 // Check that all related origin data would be removed, that is, origin 1078 // Check that all related origin data would be removed, that is, origin
1105 // matcher would match these origin. 1079 // matcher would match these origin.
1106 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1080 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1107 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1081 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1108 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1082 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1109 } 1083 }
1110 1084
1111 TEST_F(BrowsingDataRemoverImplTest, 1085 TEST_F(BrowsingDataRemoverImplTest,
1112 RemoveQuotaManagedDataForeverSpecificOrigin) { 1086 RemoveQuotaManagedDataForeverSpecificOrigin) {
1113 std::unique_ptr<BrowsingDataFilterBuilder> builder( 1087 std::unique_ptr<BrowsingDataFilterBuilder> builder(
1114 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST)); 1088 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST));
1115 builder->AddRegisterableDomain(kTestRegisterableDomain1); 1089 builder->AddRegisterableDomain(kTestRegisterableDomain1);
1116 // Remove Origin 1. 1090 // Remove Origin 1.
1117 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), 1091 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
1118 BrowsingDataRemover::REMOVE_APPCACHE | 1092 kQuotaMask, std::move(builder));
1119 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1120 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1121 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1122 BrowsingDataRemover::REMOVE_INDEXEDDB |
1123 BrowsingDataRemover::REMOVE_WEBSQL,
1124 std::move(builder));
1125 1093
1126 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | 1094 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1127 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1128 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1129 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1130 BrowsingDataRemover::REMOVE_INDEXEDDB |
1131 BrowsingDataRemover::REMOVE_WEBSQL,
1132 GetRemovalMask());
1133 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1095 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1134 1096
1135 // Verify storage partition related stuffs. 1097 // Verify storage partition related stuffs.
1136 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1098 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1137 1099
1138 EXPECT_EQ(removal_data.remove_mask, 1100 EXPECT_EQ(removal_data.remove_mask,
1139 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1101 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1140 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1102 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1141 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1103 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1142 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1104 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1143 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1105 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1144 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1106 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1145 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1107 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1146 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1108 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1147 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1109 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1148 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1110 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1149 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1111 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1150 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); 1112 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy()));
1151 } 1113 }
1152 1114
1153 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastHour) { 1115 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastHour) {
1154 BlockUntilBrowsingDataRemoved( 1116 BlockUntilBrowsingDataRemoved(
1155 AnHourAgo(), base::Time::Max(), 1117 AnHourAgo(), base::Time::Max(), kQuotaMask, false);
1156 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1157 BrowsingDataRemover::REMOVE_WEBSQL |
1158 BrowsingDataRemover::REMOVE_APPCACHE |
1159 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1160 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1161 BrowsingDataRemover::REMOVE_INDEXEDDB,
1162 false);
1163 1118
1164 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1119 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1165 BrowsingDataRemover::REMOVE_WEBSQL |
1166 BrowsingDataRemover::REMOVE_APPCACHE |
1167 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1168 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1169 BrowsingDataRemover::REMOVE_INDEXEDDB,
1170 GetRemovalMask());
1171 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1120 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1172 1121
1173 // Verify storage partition related stuffs. 1122 // Verify storage partition related stuffs.
1174 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1123 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1175 1124
1176 EXPECT_EQ(removal_data.remove_mask, 1125 EXPECT_EQ(removal_data.remove_mask,
1177 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1126 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1178 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1127 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1179 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1128 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1180 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1129 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1181 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1130 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1182 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1131 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1183 1132
1184 // Persistent data would be left out since we are not removing from 1133 // Persistent data would be left out since we are not removing from
1185 // beginning of time. 1134 // beginning of time.
1186 uint32_t expected_quota_mask = 1135 uint32_t expected_quota_mask =
1187 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; 1136 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
1188 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); 1137 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask);
1189 // Check removal begin time. 1138 // Check removal begin time.
1190 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 1139 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
1191 } 1140 }
1192 1141
1193 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastWeek) { 1142 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedDataForLastWeek) {
1194 BlockUntilBrowsingDataRemoved( 1143 BlockUntilBrowsingDataRemoved(
1195 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(), 1144 base::Time::Now() - base::TimeDelta::FromDays(7), base::Time::Max(),
1196 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1145 kQuotaMask, false);
1197 BrowsingDataRemover::REMOVE_WEBSQL |
1198 BrowsingDataRemover::REMOVE_APPCACHE |
1199 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1200 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1201 BrowsingDataRemover::REMOVE_INDEXEDDB,
1202 false);
1203 1146
1204 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1147 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1205 BrowsingDataRemover::REMOVE_WEBSQL |
1206 BrowsingDataRemover::REMOVE_APPCACHE |
1207 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1208 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1209 BrowsingDataRemover::REMOVE_INDEXEDDB,
1210 GetRemovalMask());
1211 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1148 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1212 1149
1213 // Verify storage partition related stuffs. 1150 // Verify storage partition related stuffs.
1214 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1151 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1215 1152
1216 EXPECT_EQ(removal_data.remove_mask, 1153 EXPECT_EQ(removal_data.remove_mask,
1217 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1154 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1218 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1155 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1219 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1156 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1220 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1157 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
(...skipping 10 matching lines...) Expand all
1231 } 1168 }
1232 1169
1233 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedUnprotectedOrigins) { 1170 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedUnprotectedOrigins) {
1234 #if BUILDFLAG(ENABLE_EXTENSIONS) 1171 #if BUILDFLAG(ENABLE_EXTENSIONS)
1235 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 1172 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
1236 // Protect kOrigin1. 1173 // Protect kOrigin1.
1237 policy->AddProtected(kOrigin1.GetOrigin()); 1174 policy->AddProtected(kOrigin1.GetOrigin());
1238 #endif 1175 #endif
1239 1176
1240 BlockUntilBrowsingDataRemoved( 1177 BlockUntilBrowsingDataRemoved(
1241 base::Time(), base::Time::Max(), 1178 base::Time(), base::Time::Max(), kQuotaMask, false);
1242 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1243 BrowsingDataRemover::REMOVE_WEBSQL |
1244 BrowsingDataRemover::REMOVE_APPCACHE |
1245 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1246 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1247 BrowsingDataRemover::REMOVE_INDEXEDDB,
1248 false);
1249 1179
1250 EXPECT_EQ(BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1180 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1251 BrowsingDataRemover::REMOVE_WEBSQL |
1252 BrowsingDataRemover::REMOVE_APPCACHE |
1253 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1254 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1255 BrowsingDataRemover::REMOVE_INDEXEDDB,
1256 GetRemovalMask());
1257 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1181 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1258 1182
1259 // Verify storage partition related stuffs. 1183 // Verify storage partition related stuffs.
1260 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1184 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1261 1185
1262 EXPECT_EQ(removal_data.remove_mask, 1186 EXPECT_EQ(removal_data.remove_mask,
1263 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1187 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1264 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1188 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1265 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1189 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1266 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1190 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
(...skipping 15 matching lines...) Expand all
1282 // Protect kOrigin1. 1206 // Protect kOrigin1.
1283 policy->AddProtected(kOrigin1.GetOrigin()); 1207 policy->AddProtected(kOrigin1.GetOrigin());
1284 #endif 1208 #endif
1285 1209
1286 std::unique_ptr<BrowsingDataFilterBuilder> builder( 1210 std::unique_ptr<BrowsingDataFilterBuilder> builder(
1287 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST)); 1211 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST));
1288 builder->AddRegisterableDomain(kTestRegisterableDomain1); 1212 builder->AddRegisterableDomain(kTestRegisterableDomain1);
1289 1213
1290 // Try to remove kOrigin1. Expect failure. 1214 // Try to remove kOrigin1. Expect failure.
1291 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), 1215 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
1292 BrowsingDataRemover::REMOVE_APPCACHE | 1216 kQuotaMask, std::move(builder));
1293 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1294 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1295 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1296 BrowsingDataRemover::REMOVE_INDEXEDDB |
1297 BrowsingDataRemover::REMOVE_WEBSQL,
1298 std::move(builder));
1299 1217
1300 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | 1218 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1301 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1302 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1303 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1304 BrowsingDataRemover::REMOVE_INDEXEDDB |
1305 BrowsingDataRemover::REMOVE_WEBSQL,
1306 GetRemovalMask());
1307 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1219 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1308 1220
1309 // Verify storage partition related stuffs. 1221 // Verify storage partition related stuffs.
1310 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1222 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1311 1223
1312 EXPECT_EQ(removal_data.remove_mask, 1224 EXPECT_EQ(removal_data.remove_mask,
1313 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1225 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1314 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1226 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1315 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1227 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1316 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1228 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
(...skipping 13 matching lines...) Expand all
1330 1242
1331 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedOrigins) { 1243 TEST_F(BrowsingDataRemoverImplTest, RemoveQuotaManagedProtectedOrigins) {
1332 #if BUILDFLAG(ENABLE_EXTENSIONS) 1244 #if BUILDFLAG(ENABLE_EXTENSIONS)
1333 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 1245 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
1334 // Protect kOrigin1. 1246 // Protect kOrigin1.
1335 policy->AddProtected(kOrigin1.GetOrigin()); 1247 policy->AddProtected(kOrigin1.GetOrigin());
1336 #endif 1248 #endif
1337 1249
1338 // Try to remove kOrigin1. Expect success. 1250 // Try to remove kOrigin1. Expect success.
1339 BlockUntilBrowsingDataRemoved( 1251 BlockUntilBrowsingDataRemoved(
1340 base::Time(), base::Time::Max(), 1252 base::Time(), base::Time::Max(), kQuotaMask, true);
1341 BrowsingDataRemover::REMOVE_APPCACHE |
1342 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1343 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1344 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1345 BrowsingDataRemover::REMOVE_INDEXEDDB |
1346 BrowsingDataRemover::REMOVE_WEBSQL,
1347 true);
1348 1253
1349 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | 1254 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1350 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1351 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1352 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1353 BrowsingDataRemover::REMOVE_INDEXEDDB |
1354 BrowsingDataRemover::REMOVE_WEBSQL,
1355 GetRemovalMask());
1356 EXPECT_EQ(BrowsingDataHelper::PROTECTED_WEB | 1255 EXPECT_EQ(BrowsingDataHelper::PROTECTED_WEB |
1357 BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1256 BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1358 1257
1359 // Verify storage partition related stuffs. 1258 // Verify storage partition related stuffs.
1360 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1259 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1361 1260
1362 EXPECT_EQ(removal_data.remove_mask, 1261 EXPECT_EQ(removal_data.remove_mask,
1363 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1262 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1364 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1263 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1365 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1264 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
(...skipping 10 matching lines...) Expand all
1376 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1275 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1377 } 1276 }
1378 1277
1379 TEST_F(BrowsingDataRemoverImplTest, 1278 TEST_F(BrowsingDataRemoverImplTest,
1380 RemoveQuotaManagedIgnoreExtensionsAndDevTools) { 1279 RemoveQuotaManagedIgnoreExtensionsAndDevTools) {
1381 #if BUILDFLAG(ENABLE_EXTENSIONS) 1280 #if BUILDFLAG(ENABLE_EXTENSIONS)
1382 CreateMockPolicy(); 1281 CreateMockPolicy();
1383 #endif 1282 #endif
1384 1283
1385 BlockUntilBrowsingDataRemoved( 1284 BlockUntilBrowsingDataRemoved(
1386 base::Time(), base::Time::Max(), 1285 base::Time(), base::Time::Max(), kQuotaMask, false);
1387 BrowsingDataRemover::REMOVE_APPCACHE |
1388 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1389 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1390 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1391 BrowsingDataRemover::REMOVE_INDEXEDDB |
1392 BrowsingDataRemover::REMOVE_WEBSQL,
1393 false);
1394 1286
1395 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | 1287 EXPECT_EQ(kQuotaMask, GetRemovalMask());
1396 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1397 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
1398 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1399 BrowsingDataRemover::REMOVE_INDEXEDDB |
1400 BrowsingDataRemover::REMOVE_WEBSQL,
1401 GetRemovalMask());
1402 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1288 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1403 1289
1404 // Verify storage partition related stuffs. 1290 // Verify storage partition related stuffs.
1405 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1291 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1406 1292
1407 EXPECT_EQ(removal_data.remove_mask, 1293 EXPECT_EQ(removal_data.remove_mask,
1408 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | 1294 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS |
1409 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1295 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1410 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1296 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1411 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1297 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
(...skipping 29 matching lines...) Expand all
1441 1327
1442 TEST_F(BrowsingDataRemoverImplTest, CompletionInhibition) { 1328 TEST_F(BrowsingDataRemoverImplTest, CompletionInhibition) {
1443 // The |completion_inhibitor| on the stack should prevent removal sessions 1329 // The |completion_inhibitor| on the stack should prevent removal sessions
1444 // from completing until after ContinueToCompletion() is called. 1330 // from completing until after ContinueToCompletion() is called.
1445 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; 1331 BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
1446 1332
1447 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>( 1333 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>(
1448 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext())); 1334 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
1449 InspectableCompletionObserver completion_observer(remover); 1335 InspectableCompletionObserver completion_observer(remover);
1450 remover->RemoveAndReply(base::Time(), base::Time::Max(), 1336 remover->RemoveAndReply(base::Time(), base::Time::Max(),
1451 BrowsingDataRemover::REMOVE_HISTORY, 1337 { &content::kBrowsingDataTypeCookies },
1452 BrowsingDataHelper::UNPROTECTED_WEB, 1338 BrowsingDataHelper::UNPROTECTED_WEB,
1453 &completion_observer); 1339 &completion_observer);
1454 1340
1455 // Process messages until the inhibitor is notified, and then some, to make 1341 // Process messages until the inhibitor is notified, and then some, to make
1456 // sure we do not complete asynchronously before ContinueToCompletion() is 1342 // sure we do not complete asynchronously before ContinueToCompletion() is
1457 // called. 1343 // called.
1458 completion_inhibitor.BlockUntilNearCompletion(); 1344 completion_inhibitor.BlockUntilNearCompletion();
1459 base::RunLoop().RunUntilIdle(); 1345 base::RunLoop().RunUntilIdle();
1460 1346
1461 // Verify that the removal has not yet been completed and the observer has 1347 // Verify that the removal has not yet been completed and the observer has
1462 // not been called. 1348 // not been called.
1463 EXPECT_TRUE(remover->is_removing()); 1349 EXPECT_TRUE(remover->is_removing());
1464 EXPECT_FALSE(completion_observer.called()); 1350 EXPECT_FALSE(completion_observer.called());
1465 1351
1466 // Now run the removal process until completion, and verify that observers are 1352 // Now run the removal process until completion, and verify that observers are
1467 // now notified, and the notifications is sent out. 1353 // now notified, and the notifications is sent out.
1468 completion_inhibitor.ContinueToCompletion(); 1354 completion_inhibitor.ContinueToCompletion();
1469 completion_observer.BlockUntilCompletion(); 1355 completion_observer.BlockUntilCompletion();
1470 1356
1471 EXPECT_FALSE(remover->is_removing()); 1357 EXPECT_FALSE(remover->is_removing());
1472 EXPECT_TRUE(completion_observer.called()); 1358 EXPECT_TRUE(completion_observer.called());
1473 } 1359 }
1474 1360
1475 TEST_F(BrowsingDataRemoverImplTest, EarlyShutdown) { 1361 TEST_F(BrowsingDataRemoverImplTest, EarlyShutdown) {
1476 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>( 1362 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>(
1477 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext())); 1363 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
1478 InspectableCompletionObserver completion_observer(remover); 1364 InspectableCompletionObserver completion_observer(remover);
1479 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; 1365 BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
1480 remover->RemoveAndReply(base::Time(), base::Time::Max(), 1366 remover->RemoveAndReply(base::Time(), base::Time::Max(),
1481 BrowsingDataRemover::REMOVE_HISTORY, 1367 { &content::kBrowsingDataTypeCookies },
1482 BrowsingDataHelper::UNPROTECTED_WEB, 1368 BrowsingDataHelper::UNPROTECTED_WEB,
1483 &completion_observer); 1369 &completion_observer);
1484 1370
1485 completion_inhibitor.BlockUntilNearCompletion(); 1371 completion_inhibitor.BlockUntilNearCompletion();
1486 1372
1487 // Verify that the deletion has not yet been completed and the observer has 1373 // Verify that the deletion has not yet been completed and the observer has
1488 // not been called. 1374 // not been called.
1489 EXPECT_TRUE(remover->is_removing()); 1375 EXPECT_TRUE(remover->is_removing());
1490 EXPECT_FALSE(completion_observer.called()); 1376 EXPECT_FALSE(completion_observer.called());
1491 1377
1492 // Destroying the profile should trigger the notification. 1378 // Destroying the profile should trigger the notification.
1493 DestroyBrowserContext(); 1379 DestroyBrowserContext();
1494 1380
1495 EXPECT_TRUE(completion_observer.called()); 1381 EXPECT_TRUE(completion_observer.called());
1496 1382
1497 // Finishing after shutdown shouldn't break anything. 1383 // Finishing after shutdown shouldn't break anything.
1498 completion_inhibitor.ContinueToCompletion(); 1384 completion_inhibitor.ContinueToCompletion();
1499 completion_observer.BlockUntilCompletion(); 1385 completion_observer.BlockUntilCompletion();
1500 } 1386 }
1501 1387
1502 TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByTimeOnly) { 1388 TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByTimeOnly) {
1503 RemoveDownloadsTester tester(GetBrowserContext()); 1389 RemoveDownloadsTester tester(GetBrowserContext());
1504 base::Callback<bool(const GURL&)> filter = 1390 base::Callback<bool(const GURL&)> filter =
1505 BrowsingDataFilterBuilder::BuildNoopFilter(); 1391 BrowsingDataFilterBuilder::BuildNoopFilter();
1506 1392
1507 EXPECT_CALL( 1393 EXPECT_CALL(
1508 *tester.download_manager(), 1394 *tester.download_manager(),
1509 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); 1395 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _));
1510 1396
1511 BlockUntilBrowsingDataRemoved(base::Time(), base::Time::Max(), 1397 BlockUntilBrowsingDataRemoved(
1512 BrowsingDataRemover::REMOVE_DOWNLOADS, false); 1398 base::Time(), base::Time::Max(),
1399 { &content::kBrowsingDataTypeDownloads }, false);
1513 } 1400 }
1514 1401
1515 TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByOrigin) { 1402 TEST_F(BrowsingDataRemoverImplTest, RemoveDownloadsByOrigin) {
1516 RemoveDownloadsTester tester(GetBrowserContext()); 1403 RemoveDownloadsTester tester(GetBrowserContext());
1517 std::unique_ptr<BrowsingDataFilterBuilder> builder( 1404 std::unique_ptr<BrowsingDataFilterBuilder> builder(
1518 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST)); 1405 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::WHITELIST));
1519 builder->AddRegisterableDomain(kTestRegisterableDomain1); 1406 builder->AddRegisterableDomain(kTestRegisterableDomain1);
1520 base::Callback<bool(const GURL&)> filter = builder->BuildGeneralFilter(); 1407 base::Callback<bool(const GURL&)> filter = builder->BuildGeneralFilter();
1521 1408
1522 EXPECT_CALL( 1409 EXPECT_CALL(
1523 *tester.download_manager(), 1410 *tester.download_manager(),
1524 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); 1411 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _));
1525 1412
1526 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(), 1413 BlockUntilOriginDataRemoved(base::Time(), base::Time::Max(),
1527 BrowsingDataRemover::REMOVE_DOWNLOADS, 1414 { &content::kBrowsingDataTypeDownloads },
1528 std::move(builder)); 1415 std::move(builder));
1529 } 1416 }
1530 1417
1531 class MultipleTasksObserver { 1418 class MultipleTasksObserver {
1532 public: 1419 public:
1533 // A simple implementation of BrowsingDataRemover::Observer. 1420 // A simple implementation of BrowsingDataRemover::Observer.
1534 // MultipleTasksObserver will use several instances of Target to test 1421 // MultipleTasksObserver will use several instances of Target to test
1535 // that completion callbacks are returned to the correct one. 1422 // that completion callbacks are returned to the correct one.
1536 class Target : public BrowsingDataRemover::Observer { 1423 class Target : public BrowsingDataRemover::Observer {
1537 public: 1424 public:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1592 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST)); 1479 BrowsingDataFilterBuilder::Create(BrowsingDataFilterBuilder::BLACKLIST));
1593 filter_builder_2->AddRegisterableDomain("example.com"); 1480 filter_builder_2->AddRegisterableDomain("example.com");
1594 1481
1595 MultipleTasksObserver observer(remover); 1482 MultipleTasksObserver observer(remover);
1596 BrowsingDataRemoverCompletionInhibitor completion_inhibitor; 1483 BrowsingDataRemoverCompletionInhibitor completion_inhibitor;
1597 1484
1598 // Test several tasks with various configuration of masks, filters, and target 1485 // Test several tasks with various configuration of masks, filters, and target
1599 // observers. 1486 // observers.
1600 std::list<BrowsingDataRemoverImpl::RemovalTask> tasks; 1487 std::list<BrowsingDataRemoverImpl::RemovalTask> tasks;
1601 tasks.emplace_back(base::Time(), base::Time::Max(), 1488 tasks.emplace_back(base::Time(), base::Time::Max(),
1602 BrowsingDataRemover::REMOVE_HISTORY, 1489 Mask({ &content::kBrowsingDataTypeCookies }),
1603 BrowsingDataHelper::UNPROTECTED_WEB, 1490 BrowsingDataHelper::UNPROTECTED_WEB,
1604 BrowsingDataFilterBuilder::Create( 1491 BrowsingDataFilterBuilder::Create(
1605 BrowsingDataFilterBuilder::BLACKLIST), 1492 BrowsingDataFilterBuilder::BLACKLIST),
1606 observer.target_a()); 1493 observer.target_a());
1607 tasks.emplace_back(base::Time(), base::Time::Max(), 1494 tasks.emplace_back(base::Time(), base::Time::Max(),
1608 BrowsingDataRemover::REMOVE_COOKIES, 1495 Mask({ &content::kBrowsingDataTypeCookies }),
1609 BrowsingDataHelper::PROTECTED_WEB, 1496 BrowsingDataHelper::PROTECTED_WEB,
1610 BrowsingDataFilterBuilder::Create( 1497 BrowsingDataFilterBuilder::Create(
1611 BrowsingDataFilterBuilder::BLACKLIST), 1498 BrowsingDataFilterBuilder::BLACKLIST),
1612 nullptr); 1499 nullptr);
1613 tasks.emplace_back( 1500 tasks.emplace_back(
1614 base::Time::Now(), base::Time::Max(), 1501 base::Time::Now(), base::Time::Max(),
1615 BrowsingDataRemover::REMOVE_PASSWORDS, BrowsingDataHelper::ALL, 1502 Mask({ &content::kBrowsingDataTypeDownloads }), BrowsingDataHelper::ALL,
1616 BrowsingDataFilterBuilder::Create( 1503 BrowsingDataFilterBuilder::Create(
1617 BrowsingDataFilterBuilder::BLACKLIST), 1504 BrowsingDataFilterBuilder::BLACKLIST),
1618 observer.target_b()); 1505 observer.target_b());
1619 tasks.emplace_back( 1506 tasks.emplace_back(
1620 base::Time(), base::Time::UnixEpoch(), 1507 base::Time(), base::Time::UnixEpoch(),
1621 BrowsingDataRemover::REMOVE_WEBSQL, 1508 Mask({ &content::kBrowsingDataTypeWebSQL }),
1622 BrowsingDataHelper::UNPROTECTED_WEB, 1509 BrowsingDataHelper::UNPROTECTED_WEB,
1623 std::move(filter_builder_1), 1510 std::move(filter_builder_1),
1624 observer.target_b()); 1511 observer.target_b());
1625 tasks.emplace_back( 1512 tasks.emplace_back(
1626 base::Time::UnixEpoch(), base::Time::Now(), 1513 base::Time::UnixEpoch(), base::Time::Now(),
1627 BrowsingDataRemover::REMOVE_CHANNEL_IDS, 1514 Mask({ &content::kBrowsingDataTypeChannelIDs }),
1628 BrowsingDataHelper::ALL, 1515 BrowsingDataHelper::ALL,
1629 std::move(filter_builder_2), 1516 std::move(filter_builder_2),
1630 nullptr); 1517 nullptr);
1631 1518
1632 for (BrowsingDataRemoverImpl::RemovalTask& task : tasks) { 1519 for (BrowsingDataRemoverImpl::RemovalTask& task : tasks) {
1633 // All tasks can be directly translated to a RemoveInternal() call. Since 1520 // All tasks can be directly translated to a RemoveInternal() call. Since
1634 // that is a private method, we must call the four public versions of 1521 // that is a private method, we must call the four public versions of
1635 // Remove.* instead. This also serves as a test that those methods are all 1522 // Remove.* instead. This also serves as a test that those methods are all
1636 // correctly reduced to RemoveInternal(). 1523 // correctly reduced to RemoveInternal().
1637 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) { 1524 if (!task.observer && task.filter_builder->IsEmptyBlacklist()) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the 1566 // The previous test, BrowsingDataRemoverTest.MultipleTasks, tests that the
1680 // tasks are not mixed up and they are executed in a correct order. However, 1567 // tasks are not mixed up and they are executed in a correct order. However,
1681 // the completion inhibitor kept synchronizing the execution in order to verify 1568 // the completion inhibitor kept synchronizing the execution in order to verify
1682 // the parameters. This test demonstrates that even running the tasks without 1569 // the parameters. This test demonstrates that even running the tasks without
1683 // inhibition is executed correctly and doesn't crash. 1570 // inhibition is executed correctly and doesn't crash.
1684 TEST_F(BrowsingDataRemoverImplTest, MultipleTasksInQuickSuccession) { 1571 TEST_F(BrowsingDataRemoverImplTest, MultipleTasksInQuickSuccession) {
1685 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>( 1572 BrowsingDataRemoverImpl* remover = static_cast<BrowsingDataRemoverImpl*>(
1686 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext())); 1573 BrowsingDataRemoverFactory::GetForBrowserContext(GetBrowserContext()));
1687 EXPECT_FALSE(remover->is_removing()); 1574 EXPECT_FALSE(remover->is_removing());
1688 1575
1689 int test_removal_masks[] = { 1576 std::set<const BrowsingDataType*> test_removal_masks[] = {
1690 BrowsingDataRemover::REMOVE_COOKIES, 1577 { &content::kBrowsingDataTypeCookies },
1691 BrowsingDataRemover::REMOVE_PASSWORDS, 1578 { &content::kBrowsingDataTypeChannelIDs },
1692 BrowsingDataRemover::REMOVE_COOKIES, 1579 { &content::kBrowsingDataTypeCookies },
1693 BrowsingDataRemover::REMOVE_COOKIES, 1580 { &content::kBrowsingDataTypeCookies },
1694 BrowsingDataRemover::REMOVE_COOKIES, 1581 { &content::kBrowsingDataTypeCookies },
1695 BrowsingDataRemover::REMOVE_HISTORY, 1582 { &content::kBrowsingDataTypeDownloads },
1696 BrowsingDataRemover::REMOVE_HISTORY, 1583 { &content::kBrowsingDataTypeDownloads },
1697 BrowsingDataRemover::REMOVE_HISTORY, 1584 { &content::kBrowsingDataTypeDownloads },
1698 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, 1585 { &content::kBrowsingDataTypeCookies,
1699 BrowsingDataRemover::REMOVE_COOKIES | BrowsingDataRemover::REMOVE_HISTORY, 1586 &content::kBrowsingDataTypeDownloads },
1700 BrowsingDataRemover::REMOVE_COOKIES | 1587 { &content::kBrowsingDataTypeCookies,
1701 BrowsingDataRemover::REMOVE_HISTORY | 1588 &content::kBrowsingDataTypeDownloads },
1702 BrowsingDataRemover::REMOVE_PASSWORDS, 1589 { &content::kBrowsingDataTypeCookies,
1703 BrowsingDataRemover::REMOVE_PASSWORDS, 1590 &content::kBrowsingDataTypeDownloads,
1704 BrowsingDataRemover::REMOVE_PASSWORDS, 1591 &content::kBrowsingDataTypeChannelIDs },
1592 { &content::kBrowsingDataTypeChannelIDs },
1593 { &content::kBrowsingDataTypeChannelIDs },
1705 }; 1594 };
1706 1595
1707 for (int removal_mask : test_removal_masks) { 1596 for (const std::set<const BrowsingDataType*>& removal_mask
1597 : test_removal_masks) {
1708 remover->Remove(base::Time(), base::Time::Max(), removal_mask, 1598 remover->Remove(base::Time(), base::Time::Max(), removal_mask,
1709 BrowsingDataHelper::UNPROTECTED_WEB); 1599 BrowsingDataHelper::UNPROTECTED_WEB);
1710 } 1600 }
1711 1601
1712 EXPECT_TRUE(remover->is_removing()); 1602 EXPECT_TRUE(remover->is_removing());
1713 1603
1714 // Add one more deletion and wait for it. 1604 // Add one more deletion and wait for it.
1715 BlockUntilBrowsingDataRemoved( 1605 BlockUntilBrowsingDataRemoved(
1716 base::Time(), base::Time::Max(), 1606 base::Time(), base::Time::Max(),
1717 BrowsingDataRemover::REMOVE_COOKIES, 1607 { &content::kBrowsingDataTypeCookies },
1718 BrowsingDataHelper::UNPROTECTED_WEB); 1608 BrowsingDataHelper::UNPROTECTED_WEB);
1719 1609
1720 EXPECT_FALSE(remover->is_removing()); 1610 EXPECT_FALSE(remover->is_removing());
1721 } 1611 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698