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

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

Issue 2479593006: Move enable extensions define to a build flag. (Closed)
Patch Set: Merge Created 4 years, 1 month 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 (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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 #include "content/public/browser/browser_context.h" 73 #include "content/public/browser/browser_context.h"
74 #include "content/public/browser/cookie_store_factory.h" 74 #include "content/public/browser/cookie_store_factory.h"
75 #include "content/public/browser/dom_storage_context.h" 75 #include "content/public/browser/dom_storage_context.h"
76 #include "content/public/browser/local_storage_usage_info.h" 76 #include "content/public/browser/local_storage_usage_info.h"
77 #include "content/public/browser/permission_type.h" 77 #include "content/public/browser/permission_type.h"
78 #include "content/public/browser/storage_partition.h" 78 #include "content/public/browser/storage_partition.h"
79 #include "content/public/test/mock_download_manager.h" 79 #include "content/public/test/mock_download_manager.h"
80 #include "content/public/test/test_browser_thread.h" 80 #include "content/public/test/test_browser_thread.h"
81 #include "content/public/test/test_browser_thread_bundle.h" 81 #include "content/public/test/test_browser_thread_bundle.h"
82 #include "content/public/test/test_utils.h" 82 #include "content/public/test/test_utils.h"
83 #include "extensions/features/features.h"
83 #include "net/cookies/cookie_store.h" 84 #include "net/cookies/cookie_store.h"
84 #include "net/http/http_network_session.h" 85 #include "net/http/http_network_session.h"
85 #include "net/http/http_transaction_factory.h" 86 #include "net/http/http_transaction_factory.h"
86 #include "net/ssl/channel_id_service.h" 87 #include "net/ssl/channel_id_service.h"
87 #include "net/ssl/channel_id_store.h" 88 #include "net/ssl/channel_id_store.h"
88 #include "net/ssl/ssl_client_cert_type.h" 89 #include "net/ssl/ssl_client_cert_type.h"
89 #include "net/url_request/url_request_context.h" 90 #include "net/url_request/url_request_context.h"
90 #include "net/url_request/url_request_context_getter.h" 91 #include "net/url_request/url_request_context_getter.h"
91 #include "testing/gmock/include/gmock/gmock.h" 92 #include "testing/gmock/include/gmock/gmock.h"
92 #include "testing/gtest/include/gtest/gtest.h" 93 #include "testing/gtest/include/gtest/gtest.h"
93 #include "third_party/skia/include/core/SkBitmap.h" 94 #include "third_party/skia/include/core/SkBitmap.h"
94 #include "ui/gfx/favicon_size.h" 95 #include "ui/gfx/favicon_size.h"
95 #include "url/origin.h" 96 #include "url/origin.h"
96 97
97 #if BUILDFLAG(ANDROID_JAVA_UI) 98 #if BUILDFLAG(ANDROID_JAVA_UI)
98 #include "chrome/browser/android/webapps/webapp_registry.h" 99 #include "chrome/browser/android/webapps/webapp_registry.h"
99 #endif 100 #endif
100 101
101 #if defined(OS_CHROMEOS) 102 #if defined(OS_CHROMEOS)
102 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 103 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
103 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 104 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
104 #include "chrome/browser/chromeos/settings/cros_settings.h" 105 #include "chrome/browser/chromeos/settings/cros_settings.h"
105 #include "chrome/browser/chromeos/settings/device_settings_service.h" 106 #include "chrome/browser/chromeos/settings/device_settings_service.h"
106 #include "chromeos/dbus/dbus_thread_manager.h" 107 #include "chromeos/dbus/dbus_thread_manager.h"
107 #include "chromeos/dbus/mock_cryptohome_client.h" 108 #include "chromeos/dbus/mock_cryptohome_client.h"
108 #include "components/signin/core/account_id/account_id.h" 109 #include "components/signin/core/account_id/account_id.h"
109 #endif 110 #endif
110 111
111 #if defined(ENABLE_EXTENSIONS) 112 #if BUILDFLAG(ENABLE_EXTENSIONS)
112 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h" 113 #include "chrome/browser/extensions/mock_extension_special_storage_policy.h"
113 #endif 114 #endif
114 115
115 #if defined(ENABLE_PLUGINS) 116 #if defined(ENABLE_PLUGINS)
116 #include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h" 117 #include "chrome/browser/browsing_data/mock_browsing_data_flash_lso_helper.h"
117 #endif 118 #endif
118 119
119 class MockExtensionSpecialStoragePolicy; 120 class MockExtensionSpecialStoragePolicy;
120 121
121 using content::BrowserThread; 122 using content::BrowserThread;
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 1126
1126 #if BUILDFLAG(ANDROID_JAVA_UI) 1127 #if BUILDFLAG(ANDROID_JAVA_UI)
1127 remover_->OverrideWebappRegistryForTesting( 1128 remover_->OverrideWebappRegistryForTesting(
1128 std::unique_ptr<WebappRegistry>(new TestWebappRegistry())); 1129 std::unique_ptr<WebappRegistry>(new TestWebappRegistry()));
1129 #endif 1130 #endif
1130 } 1131 }
1131 1132
1132 ~BrowsingDataRemoverTest() override {} 1133 ~BrowsingDataRemoverTest() override {}
1133 1134
1134 void TearDown() override { 1135 void TearDown() override {
1135 #if defined(ENABLE_EXTENSIONS) 1136 #if BUILDFLAG(ENABLE_EXTENSIONS)
1136 mock_policy_ = nullptr; 1137 mock_policy_ = nullptr;
1137 #endif 1138 #endif
1138 1139
1139 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor 1140 // TestingProfile contains a DOMStorageContext. BrowserContext's destructor
1140 // posts a message to the WEBKIT thread to delete some of its member 1141 // posts a message to the WEBKIT thread to delete some of its member
1141 // variables. We need to ensure that the profile is destroyed, and that 1142 // variables. We need to ensure that the profile is destroyed, and that
1142 // the message loop is cleared out, before destroying the threads and loop. 1143 // the message loop is cleared out, before destroying the threads and loop.
1143 // Otherwise we leak memory. 1144 // Otherwise we leak memory.
1144 profile_.reset(); 1145 profile_.reset();
1145 base::RunLoop().RunUntilIdle(); 1146 base::RunLoop().RunUntilIdle();
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1206 1207
1207 int GetOriginTypeMask() { 1208 int GetOriginTypeMask() {
1208 return remover_->GetLastUsedOriginTypeMask(); 1209 return remover_->GetLastUsedOriginTypeMask();
1209 } 1210 }
1210 1211
1211 StoragePartitionRemovalData GetStoragePartitionRemovalData() { 1212 StoragePartitionRemovalData GetStoragePartitionRemovalData() {
1212 return storage_partition_removal_data_; 1213 return storage_partition_removal_data_;
1213 } 1214 }
1214 1215
1215 MockExtensionSpecialStoragePolicy* CreateMockPolicy() { 1216 MockExtensionSpecialStoragePolicy* CreateMockPolicy() {
1216 #if defined(ENABLE_EXTENSIONS) 1217 #if BUILDFLAG(ENABLE_EXTENSIONS)
1217 mock_policy_ = new MockExtensionSpecialStoragePolicy; 1218 mock_policy_ = new MockExtensionSpecialStoragePolicy;
1218 return mock_policy_.get(); 1219 return mock_policy_.get();
1219 #else 1220 #else
1220 NOTREACHED(); 1221 NOTREACHED();
1221 return nullptr; 1222 return nullptr;
1222 #endif 1223 #endif
1223 } 1224 }
1224 1225
1225 storage::SpecialStoragePolicy* mock_policy() { 1226 storage::SpecialStoragePolicy* mock_policy() {
1226 #if defined(ENABLE_EXTENSIONS) 1227 #if BUILDFLAG(ENABLE_EXTENSIONS)
1227 return mock_policy_.get(); 1228 return mock_policy_.get();
1228 #else 1229 #else
1229 return nullptr; 1230 return nullptr;
1230 #endif 1231 #endif
1231 } 1232 }
1232 1233
1233 // If |kOrigin1| is protected when extensions are enabled, the expected 1234 // If |kOrigin1| is protected when extensions are enabled, the expected
1234 // result for tests where the OriginMatcherFunction result is variable. 1235 // result for tests where the OriginMatcherFunction result is variable.
1235 bool ShouldRemoveForProtectedOriginOne() const { 1236 bool ShouldRemoveForProtectedOriginOne() const {
1236 #if defined(ENABLE_EXTENSIONS) 1237 #if BUILDFLAG(ENABLE_EXTENSIONS)
1237 return false; 1238 return false;
1238 #else 1239 #else
1239 return true; 1240 return true;
1240 #endif 1241 #endif
1241 } 1242 }
1242 1243
1243 const ClearDomainReliabilityTester& clear_domain_reliability_tester() { 1244 const ClearDomainReliabilityTester& clear_domain_reliability_tester() {
1244 return clear_domain_reliability_tester_; 1245 return clear_domain_reliability_tester_;
1245 } 1246 }
1246 1247
1247 private: 1248 private:
1248 // Cached pointer to BrowsingDataRemover for access to testing methods. 1249 // Cached pointer to BrowsingDataRemover for access to testing methods.
1249 BrowsingDataRemover* remover_; 1250 BrowsingDataRemover* remover_;
1250 1251
1251 content::TestBrowserThreadBundle thread_bundle_; 1252 content::TestBrowserThreadBundle thread_bundle_;
1252 std::unique_ptr<TestingProfile> profile_; 1253 std::unique_ptr<TestingProfile> profile_;
1253 1254
1254 StoragePartitionRemovalData storage_partition_removal_data_; 1255 StoragePartitionRemovalData storage_partition_removal_data_;
1255 1256
1256 #if defined(ENABLE_EXTENSIONS) 1257 #if BUILDFLAG(ENABLE_EXTENSIONS)
1257 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_; 1258 scoped_refptr<MockExtensionSpecialStoragePolicy> mock_policy_;
1258 #endif 1259 #endif
1259 1260
1260 // Needed to mock out DomainReliabilityService, even for unrelated tests. 1261 // Needed to mock out DomainReliabilityService, even for unrelated tests.
1261 ClearDomainReliabilityTester clear_domain_reliability_tester_; 1262 ClearDomainReliabilityTester clear_domain_reliability_tester_;
1262 1263
1263 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest); 1264 DISALLOW_COPY_AND_ASSIGN(BrowsingDataRemoverTest);
1264 }; 1265 };
1265 1266
1266 // Tests --------------------------------------------------------------------- 1267 // Tests ---------------------------------------------------------------------
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 BrowsingDataRemover::REMOVE_CHANNEL_IDS, 1441 BrowsingDataRemover::REMOVE_CHANNEL_IDS,
1441 filter_builder); 1442 filter_builder);
1442 1443
1443 EXPECT_EQ(1, tester.ChannelIDCount()); 1444 EXPECT_EQ(1, tester.ChannelIDCount());
1444 net::ChannelIDStore::ChannelIDList channel_ids; 1445 net::ChannelIDStore::ChannelIDList channel_ids;
1445 tester.GetChannelIDList(&channel_ids); 1446 tester.GetChannelIDList(&channel_ids);
1446 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier()); 1447 EXPECT_EQ(kTestRegisterableDomain3, channel_ids.front().server_identifier());
1447 } 1448 }
1448 1449
1449 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) { 1450 TEST_F(BrowsingDataRemoverTest, RemoveUnprotectedLocalStorageForever) {
1450 #if defined(ENABLE_EXTENSIONS) 1451 #if BUILDFLAG(ENABLE_EXTENSIONS)
1451 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 1452 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
1452 // Protect kOrigin1. 1453 // Protect kOrigin1.
1453 policy->AddProtected(kOrigin1.GetOrigin()); 1454 policy->AddProtected(kOrigin1.GetOrigin());
1454 #endif 1455 #endif
1455 1456
1456 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, 1457 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
1457 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, 1458 BrowsingDataRemover::REMOVE_LOCAL_STORAGE,
1458 false); 1459 false);
1459 1460
1460 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 1461 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
1461 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1462 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1462 1463
1463 // Verify that storage partition was instructed to remove the data correctly. 1464 // Verify that storage partition was instructed to remove the data correctly.
1464 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); 1465 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData();
1465 EXPECT_EQ(removal_data.remove_mask, 1466 EXPECT_EQ(removal_data.remove_mask,
1466 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); 1467 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE);
1467 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1468 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1468 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1469 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1469 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 1470 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
1470 1471
1471 // Check origin matcher. 1472 // Check origin matcher.
1472 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), 1473 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(),
1473 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1474 removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1474 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1475 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1475 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1476 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1476 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); 1477 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy()));
1477 } 1478 }
1478 1479
1479 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) { 1480 TEST_F(BrowsingDataRemoverTest, RemoveProtectedLocalStorageForever) {
1480 #if defined(ENABLE_EXTENSIONS) 1481 #if BUILDFLAG(ENABLE_EXTENSIONS)
1481 // Protect kOrigin1. 1482 // Protect kOrigin1.
1482 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 1483 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
1483 policy->AddProtected(kOrigin1.GetOrigin()); 1484 policy->AddProtected(kOrigin1.GetOrigin());
1484 #endif 1485 #endif
1485 1486
1486 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME, 1487 BlockUntilBrowsingDataRemoved(browsing_data::ALL_TIME,
1487 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, 1488 BrowsingDataRemover::REMOVE_LOCAL_STORAGE,
1488 true); 1489 true);
1489 1490
1490 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 1491 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
(...skipping 10 matching lines...) Expand all
1501 1502
1502 // Check origin matcher all http origin will match since we specified 1503 // Check origin matcher all http origin will match since we specified
1503 // both protected and unprotected. 1504 // both protected and unprotected.
1504 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1505 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1505 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1506 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1506 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1507 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1507 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); 1508 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy()));
1508 } 1509 }
1509 1510
1510 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { 1511 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) {
1511 #if defined(ENABLE_EXTENSIONS) 1512 #if BUILDFLAG(ENABLE_EXTENSIONS)
1512 CreateMockPolicy(); 1513 CreateMockPolicy();
1513 #endif 1514 #endif
1514 1515
1515 BlockUntilBrowsingDataRemoved(browsing_data::LAST_WEEK, 1516 BlockUntilBrowsingDataRemoved(browsing_data::LAST_WEEK,
1516 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, 1517 BrowsingDataRemover::REMOVE_LOCAL_STORAGE,
1517 false); 1518 false);
1518 1519
1519 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); 1520 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask());
1520 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); 1521 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask());
1521 1522
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 StoragePartition::REMOVE_DATA_MASK_WEBSQL | 1726 StoragePartition::REMOVE_DATA_MASK_WEBSQL |
1726 StoragePartition::REMOVE_DATA_MASK_APPCACHE | 1727 StoragePartition::REMOVE_DATA_MASK_APPCACHE |
1727 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | 1728 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS |
1728 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | 1729 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE |
1729 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); 1730 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB);
1730 EXPECT_EQ(removal_data.quota_storage_remove_mask, 1731 EXPECT_EQ(removal_data.quota_storage_remove_mask,
1731 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1732 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1732 } 1733 }
1733 1734
1734 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { 1735 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) {
1735 #if defined(ENABLE_EXTENSIONS) 1736 #if BUILDFLAG(ENABLE_EXTENSIONS)
1736 CreateMockPolicy(); 1737 CreateMockPolicy();
1737 #endif 1738 #endif
1738 1739
1739 BlockUntilBrowsingDataRemoved( 1740 BlockUntilBrowsingDataRemoved(
1740 browsing_data::ALL_TIME, 1741 browsing_data::ALL_TIME,
1741 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1742 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1742 BrowsingDataRemover::REMOVE_WEBSQL | 1743 BrowsingDataRemover::REMOVE_WEBSQL |
1743 BrowsingDataRemover::REMOVE_APPCACHE | 1744 BrowsingDataRemover::REMOVE_APPCACHE |
1744 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | 1745 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1745 BrowsingDataRemover::REMOVE_CACHE_STORAGE | 1746 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
(...skipping 23 matching lines...) Expand all
1769 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1770 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1770 1771
1771 // Check that all related origin data would be removed, that is, origin 1772 // Check that all related origin data would be removed, that is, origin
1772 // matcher would match these origin. 1773 // matcher would match these origin.
1773 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1774 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1774 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1775 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1775 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1776 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1776 } 1777 }
1777 1778
1778 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { 1779 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) {
1779 #if defined(ENABLE_EXTENSIONS) 1780 #if BUILDFLAG(ENABLE_EXTENSIONS)
1780 CreateMockPolicy(); 1781 CreateMockPolicy();
1781 #endif 1782 #endif
1782 1783
1783 BlockUntilBrowsingDataRemoved( 1784 BlockUntilBrowsingDataRemoved(
1784 browsing_data::ALL_TIME, 1785 browsing_data::ALL_TIME,
1785 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1786 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1786 BrowsingDataRemover::REMOVE_WEBSQL | 1787 BrowsingDataRemover::REMOVE_WEBSQL |
1787 BrowsingDataRemover::REMOVE_APPCACHE | 1788 BrowsingDataRemover::REMOVE_APPCACHE |
1788 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | 1789 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1789 BrowsingDataRemover::REMOVE_CACHE_STORAGE | 1790 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
(...skipping 23 matching lines...) Expand all
1813 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 1814 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
1814 1815
1815 // Check that all related origin data would be removed, that is, origin 1816 // Check that all related origin data would be removed, that is, origin
1816 // matcher would match these origin. 1817 // matcher would match these origin.
1817 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 1818 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
1818 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 1819 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
1819 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 1820 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
1820 } 1821 }
1821 1822
1822 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { 1823 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) {
1823 #if defined(ENABLE_EXTENSIONS) 1824 #if BUILDFLAG(ENABLE_EXTENSIONS)
1824 CreateMockPolicy(); 1825 CreateMockPolicy();
1825 #endif 1826 #endif
1826 1827
1827 BlockUntilBrowsingDataRemoved( 1828 BlockUntilBrowsingDataRemoved(
1828 browsing_data::ALL_TIME, 1829 browsing_data::ALL_TIME,
1829 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1830 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1830 BrowsingDataRemover::REMOVE_WEBSQL | 1831 BrowsingDataRemover::REMOVE_WEBSQL |
1831 BrowsingDataRemover::REMOVE_APPCACHE | 1832 BrowsingDataRemover::REMOVE_APPCACHE |
1832 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | 1833 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
1833 BrowsingDataRemover::REMOVE_CACHE_STORAGE | 1834 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
1978 // Persistent data would be left out since we are not removing from 1979 // Persistent data would be left out since we are not removing from
1979 // beginning of time. 1980 // beginning of time.
1980 uint32_t expected_quota_mask = 1981 uint32_t expected_quota_mask =
1981 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; 1982 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT;
1982 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); 1983 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask);
1983 // Check removal begin time. 1984 // Check removal begin time.
1984 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); 1985 EXPECT_EQ(removal_data.remove_begin, GetBeginTime());
1985 } 1986 }
1986 1987
1987 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { 1988 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) {
1988 #if defined(ENABLE_EXTENSIONS) 1989 #if BUILDFLAG(ENABLE_EXTENSIONS)
1989 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 1990 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
1990 // Protect kOrigin1. 1991 // Protect kOrigin1.
1991 policy->AddProtected(kOrigin1.GetOrigin()); 1992 policy->AddProtected(kOrigin1.GetOrigin());
1992 #endif 1993 #endif
1993 1994
1994 BlockUntilBrowsingDataRemoved( 1995 BlockUntilBrowsingDataRemoved(
1995 browsing_data::ALL_TIME, 1996 browsing_data::ALL_TIME,
1996 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 1997 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
1997 BrowsingDataRemover::REMOVE_WEBSQL | 1998 BrowsingDataRemover::REMOVE_WEBSQL |
1998 BrowsingDataRemover::REMOVE_APPCACHE | 1999 BrowsingDataRemover::REMOVE_APPCACHE |
(...skipping 25 matching lines...) Expand all
2024 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 2025 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
2025 2026
2026 // Check OriginMatcherFunction. 2027 // Check OriginMatcherFunction.
2027 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), 2028 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(),
2028 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 2029 removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
2029 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 2030 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
2030 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 2031 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
2031 } 2032 }
2032 2033
2033 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { 2034 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) {
2034 #if defined(ENABLE_EXTENSIONS) 2035 #if BUILDFLAG(ENABLE_EXTENSIONS)
2035 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 2036 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
2036 // Protect kOrigin1. 2037 // Protect kOrigin1.
2037 policy->AddProtected(kOrigin1.GetOrigin()); 2038 policy->AddProtected(kOrigin1.GetOrigin());
2038 #endif 2039 #endif
2039 2040
2040 RegistrableDomainFilterBuilder builder( 2041 RegistrableDomainFilterBuilder builder(
2041 RegistrableDomainFilterBuilder::WHITELIST); 2042 RegistrableDomainFilterBuilder::WHITELIST);
2042 builder.AddRegisterableDomain(kTestRegisterableDomain1); 2043 builder.AddRegisterableDomain(kTestRegisterableDomain1);
2043 2044
2044 // Try to remove kOrigin1. Expect failure. 2045 // Try to remove kOrigin1. Expect failure.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
2076 // Check OriginMatcherFunction. 2077 // Check OriginMatcherFunction.
2077 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), 2078 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(),
2078 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 2079 removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
2079 // Since we use the matcher function to validate origins now, this should 2080 // Since we use the matcher function to validate origins now, this should
2080 // return false for the origins we're not trying to clear. 2081 // return false for the origins we're not trying to clear.
2081 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 2082 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
2082 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 2083 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
2083 } 2084 }
2084 2085
2085 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { 2086 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) {
2086 #if defined(ENABLE_EXTENSIONS) 2087 #if BUILDFLAG(ENABLE_EXTENSIONS)
2087 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); 2088 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy();
2088 // Protect kOrigin1. 2089 // Protect kOrigin1.
2089 policy->AddProtected(kOrigin1.GetOrigin()); 2090 policy->AddProtected(kOrigin1.GetOrigin());
2090 #endif 2091 #endif
2091 2092
2092 // Try to remove kOrigin1. Expect success. 2093 // Try to remove kOrigin1. Expect success.
2093 BlockUntilBrowsingDataRemoved( 2094 BlockUntilBrowsingDataRemoved(
2094 browsing_data::ALL_TIME, 2095 browsing_data::ALL_TIME,
2095 BrowsingDataRemover::REMOVE_APPCACHE | 2096 BrowsingDataRemover::REMOVE_APPCACHE |
2096 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | 2097 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
(...skipping 27 matching lines...) Expand all
2124 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); 2125 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL);
2125 2126
2126 // Check OriginMatcherFunction, |kOrigin1| would match mask since we 2127 // Check OriginMatcherFunction, |kOrigin1| would match mask since we
2127 // would have 'protected' specified in origin_type_mask. 2128 // would have 'protected' specified in origin_type_mask.
2128 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); 2129 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy()));
2129 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); 2130 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy()));
2130 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); 2131 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy()));
2131 } 2132 }
2132 2133
2133 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { 2134 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) {
2134 #if defined(ENABLE_EXTENSIONS) 2135 #if BUILDFLAG(ENABLE_EXTENSIONS)
2135 CreateMockPolicy(); 2136 CreateMockPolicy();
2136 #endif 2137 #endif
2137 2138
2138 BlockUntilBrowsingDataRemoved( 2139 BlockUntilBrowsingDataRemoved(
2139 browsing_data::ALL_TIME, 2140 browsing_data::ALL_TIME,
2140 BrowsingDataRemover::REMOVE_APPCACHE | 2141 BrowsingDataRemover::REMOVE_APPCACHE |
2141 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | 2142 BrowsingDataRemover::REMOVE_SERVICE_WORKERS |
2142 BrowsingDataRemover::REMOVE_CACHE_STORAGE | 2143 BrowsingDataRemover::REMOVE_CACHE_STORAGE |
2143 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | 2144 BrowsingDataRemover::REMOVE_FILE_SYSTEMS |
2144 BrowsingDataRemover::REMOVE_INDEXEDDB | 2145 BrowsingDataRemover::REMOVE_INDEXEDDB |
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3035 EXPECT_TRUE(remover->is_removing()); 3036 EXPECT_TRUE(remover->is_removing());
3036 3037
3037 // Add one more deletion and wait for it. 3038 // Add one more deletion and wait for it.
3038 BlockUntilBrowsingDataRemoved( 3039 BlockUntilBrowsingDataRemoved(
3039 browsing_data::ALL_TIME, 3040 browsing_data::ALL_TIME,
3040 BrowsingDataRemover::REMOVE_COOKIES, 3041 BrowsingDataRemover::REMOVE_COOKIES,
3041 BrowsingDataHelper::UNPROTECTED_WEB); 3042 BrowsingDataHelper::UNPROTECTED_WEB);
3042 3043
3043 EXPECT_FALSE(remover->is_removing()); 3044 EXPECT_FALSE(remover->is_removing());
3044 } 3045 }
OLDNEW
« no previous file with comments | « chrome/browser/browsing_data/browsing_data_remover_factory.cc ('k') | chrome/browser/browsing_data/cookies_tree_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698