OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 5 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <set> | 10 #include <set> |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/bind.h" | 14 #include "base/bind.h" |
15 #include "base/bind_helpers.h" | 15 #include "base/bind_helpers.h" |
16 #include "base/files/file_path.h" | 16 #include "base/files/file_path.h" |
17 #include "base/files/file_util.h" | 17 #include "base/files/file_util.h" |
18 #include "base/guid.h" | 18 #include "base/guid.h" |
19 #include "base/macros.h" | 19 #include "base/macros.h" |
20 #include "base/memory/scoped_ptr.h" | 20 #include "base/memory/scoped_ptr.h" |
21 #include "base/message_loop/message_loop.h" | 21 #include "base/message_loop/message_loop.h" |
22 #include "base/run_loop.h" | 22 #include "base/run_loop.h" |
23 #include "base/strings/utf_string_conversions.h" | 23 #include "base/strings/utf_string_conversions.h" |
24 #include "base/task/cancelable_task_tracker.h" | 24 #include "base/task/cancelable_task_tracker.h" |
25 #include "build/build_config.h" | 25 #include "build/build_config.h" |
26 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 26 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 27 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 28 #include "chrome/browser/browsing_data/browsing_data_filter_builder.h" |
28 #include "chrome/browser/browsing_data/browsing_data_helper.h" | 29 #include "chrome/browser/browsing_data/browsing_data_helper.h" |
29 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" | 30 #include "chrome/browser/browsing_data/browsing_data_remover_factory.h" |
30 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" | 31 #include "chrome/browser/browsing_data/browsing_data_remover_test_util.h" |
31 #include "chrome/browser/browsing_data/origin_filter_builder.h" | 32 #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
32 #include "chrome/browser/domain_reliability/service_factory.h" | 33 #include "chrome/browser/domain_reliability/service_factory.h" |
33 #include "chrome/browser/download/chrome_download_manager_delegate.h" | 34 #include "chrome/browser/download/chrome_download_manager_delegate.h" |
34 #include "chrome/browser/favicon/favicon_service_factory.h" | 35 #include "chrome/browser/favicon/favicon_service_factory.h" |
35 #include "chrome/browser/history/history_service_factory.h" | 36 #include "chrome/browser/history/history_service_factory.h" |
36 #include "chrome/browser/password_manager/password_store_factory.h" | 37 #include "chrome/browser/password_manager/password_store_factory.h" |
37 #include "chrome/browser/safe_browsing/safe_browsing_service.h" | 38 #include "chrome/browser/safe_browsing/safe_browsing_service.h" |
38 #include "chrome/common/pref_names.h" | 39 #include "chrome/common/pref_names.h" |
39 #include "chrome/test/base/testing_browser_process.h" | 40 #include "chrome/test/base/testing_browser_process.h" |
40 #include "chrome/test/base/testing_profile.h" | 41 #include "chrome/test/base/testing_profile.h" |
41 #include "components/autofill/core/browser/autofill_profile.h" | 42 #include "components/autofill/core/browser/autofill_profile.h" |
42 #include "components/autofill/core/browser/autofill_test_utils.h" | 43 #include "components/autofill/core/browser/autofill_test_utils.h" |
43 #include "components/autofill/core/browser/credit_card.h" | 44 #include "components/autofill/core/browser/credit_card.h" |
44 #include "components/autofill/core/browser/personal_data_manager.h" | 45 #include "components/autofill/core/browser/personal_data_manager.h" |
45 #include "components/autofill/core/browser/personal_data_manager_observer.h" | 46 #include "components/autofill/core/browser/personal_data_manager_observer.h" |
46 #include "components/bookmarks/browser/bookmark_model.h" | 47 #include "components/bookmarks/browser/bookmark_model.h" |
47 #include "components/bookmarks/test/bookmark_test_helpers.h" | 48 #include "components/bookmarks/test/bookmark_test_helpers.h" |
| 49 #include "components/content_settings/core/browser/host_content_settings_map.h" |
| 50 #include "components/content_settings/core/common/content_settings.h" |
| 51 #include "components/content_settings/core/common/content_settings_pattern.h" |
48 #include "components/domain_reliability/clear_mode.h" | 52 #include "components/domain_reliability/clear_mode.h" |
49 #include "components/domain_reliability/monitor.h" | 53 #include "components/domain_reliability/monitor.h" |
50 #include "components/domain_reliability/service.h" | 54 #include "components/domain_reliability/service.h" |
51 #include "components/favicon/core/favicon_service.h" | 55 #include "components/favicon/core/favicon_service.h" |
52 #include "components/history/core/browser/history_service.h" | 56 #include "components/history/core/browser/history_service.h" |
53 #include "components/omnibox/browser/omnibox_pref_names.h" | 57 #include "components/omnibox/browser/omnibox_pref_names.h" |
54 #include "components/password_manager/core/browser/mock_password_store.h" | 58 #include "components/password_manager/core/browser/mock_password_store.h" |
55 #include "components/password_manager/core/browser/password_manager_test_utils.h
" | 59 #include "components/password_manager/core/browser/password_manager_test_utils.h
" |
56 #include "components/password_manager/core/browser/password_store_consumer.h" | 60 #include "components/password_manager/core/browser/password_store_consumer.h" |
57 #include "components/prefs/testing_pref_service.h" | 61 #include "components/prefs/testing_pref_service.h" |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 using testing::Invoke; | 113 using testing::Invoke; |
110 using testing::Matcher; | 114 using testing::Matcher; |
111 using testing::MakeMatcher; | 115 using testing::MakeMatcher; |
112 using testing::MatcherInterface; | 116 using testing::MatcherInterface; |
113 using testing::MatchResultListener; | 117 using testing::MatchResultListener; |
114 using testing::Return; | 118 using testing::Return; |
115 using testing::WithArgs; | 119 using testing::WithArgs; |
116 | 120 |
117 namespace { | 121 namespace { |
118 | 122 |
119 const char kTestOrigin1[] = "http://host1:1/"; | 123 const char kTestOrigin1[] = "http://host1.com:1/"; |
120 const char kTestOrigin2[] = "http://host2:1/"; | 124 const char kTestRegisterableDomain1[] = "host1.com"; |
121 const char kTestOrigin3[] = "http://host3:1/"; | 125 const char kTestOrigin2[] = "http://host2.com:1/"; |
| 126 const char kTestOrigin3[] = "http://host3.com:1/"; |
| 127 const char kTestRegisterableDomain3[] = "host3.com"; |
| 128 const char kTestOrigin4[] = "https://host3.com:1/"; |
122 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; | 129 const char kTestOriginExt[] = "chrome-extension://abcdefghijklmnopqrstuvwxyz/"; |
123 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; | 130 const char kTestOriginDevTools[] = "chrome-devtools://abcdefghijklmnopqrstuvw/"; |
124 | 131 |
125 // For Autofill. | 132 // For Autofill. |
126 const char kChromeOrigin[] = "Chrome settings"; | 133 const char kChromeOrigin[] = "Chrome settings"; |
127 const char kWebOrigin[] = "https://www.example.com/"; | 134 const char kWebOrigin[] = "https://www.example.com/"; |
128 | 135 |
129 const GURL kOrigin1(kTestOrigin1); | 136 const GURL kOrigin1(kTestOrigin1); |
130 const GURL kOrigin2(kTestOrigin2); | 137 const GURL kOrigin2(kTestOrigin2); |
131 const GURL kOrigin3(kTestOrigin3); | 138 const GURL kOrigin3(kTestOrigin3); |
| 139 const GURL kOrigin4(kTestOrigin4); |
132 const GURL kOriginExt(kTestOriginExt); | 140 const GURL kOriginExt(kTestOriginExt); |
133 const GURL kOriginDevTools(kTestOriginDevTools); | 141 const GURL kOriginDevTools(kTestOriginDevTools); |
134 | 142 |
135 const base::FilePath::CharType kDomStorageOrigin1[] = | 143 const base::FilePath::CharType kDomStorageOrigin1[] = |
136 FILE_PATH_LITERAL("http_host1_1.localstorage"); | 144 FILE_PATH_LITERAL("http_host1_1.localstorage"); |
137 | 145 |
138 const base::FilePath::CharType kDomStorageOrigin2[] = | 146 const base::FilePath::CharType kDomStorageOrigin2[] = |
139 FILE_PATH_LITERAL("http_host2_1.localstorage"); | 147 FILE_PATH_LITERAL("http_host2_1.localstorage"); |
140 | 148 |
141 const base::FilePath::CharType kDomStorageOrigin3[] = | 149 const base::FilePath::CharType kDomStorageOrigin3[] = |
142 FILE_PATH_LITERAL("http_host3_1.localstorage"); | 150 FILE_PATH_LITERAL("http_host3_1.localstorage"); |
143 | 151 |
144 const base::FilePath::CharType kDomStorageExt[] = FILE_PATH_LITERAL( | 152 const base::FilePath::CharType kDomStorageExt[] = FILE_PATH_LITERAL( |
145 "chrome-extension_abcdefghijklmnopqrstuvwxyz_0.localstorage"); | 153 "chrome-extension_abcdefghijklmnopqrstuvwxyz_0.localstorage"); |
146 | 154 |
| 155 bool MatchPrimaryPattern(const ContentSettingsPattern& expected_primary, |
| 156 const ContentSettingsPattern& primary_pattern, |
| 157 const ContentSettingsPattern& secondary_pattern) { |
| 158 return expected_primary == primary_pattern; |
| 159 } |
| 160 |
147 #if defined(OS_CHROMEOS) | 161 #if defined(OS_CHROMEOS) |
148 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { | 162 void FakeDBusCall(const chromeos::BoolDBusMethodCallback& callback) { |
149 base::MessageLoop::current()->PostTask( | 163 base::MessageLoop::current()->PostTask( |
150 FROM_HERE, | 164 FROM_HERE, |
151 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); | 165 base::Bind(callback, chromeos::DBUS_METHOD_CALL_SUCCESS, true)); |
152 } | 166 } |
153 #endif | 167 #endif |
154 | 168 |
155 struct StoragePartitionRemovalData { | 169 struct StoragePartitionRemovalData { |
156 uint32_t remove_mask = 0; | 170 uint32_t remove_mask = 0; |
157 uint32_t quota_storage_remove_mask = 0; | 171 uint32_t quota_storage_remove_mask = 0; |
158 GURL remove_origin; | |
159 base::Time remove_begin; | 172 base::Time remove_begin; |
160 base::Time remove_end; | 173 base::Time remove_end; |
161 StoragePartition::OriginMatcherFunction origin_matcher; | 174 StoragePartition::OriginMatcherFunction origin_matcher; |
| 175 StoragePartition::CookieMatcherFunction cookie_matcher; |
162 | 176 |
163 StoragePartitionRemovalData() {} | 177 StoragePartitionRemovalData() {} |
164 }; | 178 }; |
165 | 179 |
| 180 net::CanonicalCookie CreateCookieWithHost(const GURL& source) { |
| 181 return net::CanonicalCookie( |
| 182 source, "A", "1", source.host(), "/", base::Time::Now(), |
| 183 base::Time::Now(), base::Time::Now(), false, false, |
| 184 net::CookieSameSite::DEFAULT_MODE, net::COOKIE_PRIORITY_MEDIUM); |
| 185 } |
| 186 |
166 class TestStoragePartition : public StoragePartition { | 187 class TestStoragePartition : public StoragePartition { |
167 public: | 188 public: |
168 TestStoragePartition() {} | 189 TestStoragePartition() {} |
169 ~TestStoragePartition() override {} | 190 ~TestStoragePartition() override {} |
170 | 191 |
171 // content::StoragePartition implementation. | 192 // content::StoragePartition implementation. |
172 base::FilePath GetPath() override { return base::FilePath(); } | 193 base::FilePath GetPath() override { return base::FilePath(); } |
173 net::URLRequestContextGetter* GetURLRequestContext() override { | 194 net::URLRequestContextGetter* GetURLRequestContext() override { |
174 return nullptr; | 195 return nullptr; |
175 } | 196 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 uint32_t quota_storage_remove_mask, | 247 uint32_t quota_storage_remove_mask, |
227 const GURL& storage_origin, | 248 const GURL& storage_origin, |
228 const OriginMatcherFunction& origin_matcher, | 249 const OriginMatcherFunction& origin_matcher, |
229 const base::Time begin, | 250 const base::Time begin, |
230 const base::Time end, | 251 const base::Time end, |
231 const base::Closure& callback) override { | 252 const base::Closure& callback) override { |
232 // Store stuff to verify parameters' correctness later. | 253 // Store stuff to verify parameters' correctness later. |
233 storage_partition_removal_data_.remove_mask = remove_mask; | 254 storage_partition_removal_data_.remove_mask = remove_mask; |
234 storage_partition_removal_data_.quota_storage_remove_mask = | 255 storage_partition_removal_data_.quota_storage_remove_mask = |
235 quota_storage_remove_mask; | 256 quota_storage_remove_mask; |
236 storage_partition_removal_data_.remove_origin = storage_origin; | |
237 storage_partition_removal_data_.remove_begin = begin; | 257 storage_partition_removal_data_.remove_begin = begin; |
238 storage_partition_removal_data_.remove_end = end; | 258 storage_partition_removal_data_.remove_end = end; |
239 storage_partition_removal_data_.origin_matcher = origin_matcher; | 259 storage_partition_removal_data_.origin_matcher = origin_matcher; |
240 | 260 |
241 BrowserThread::PostTask( | 261 BrowserThread::PostTask( |
242 BrowserThread::UI, | 262 BrowserThread::UI, |
243 FROM_HERE, | 263 FROM_HERE, |
244 base::Bind(&TestStoragePartition::AsyncRunCallback, | 264 base::Bind(&TestStoragePartition::AsyncRunCallback, |
245 base::Unretained(this), callback)); | 265 base::Unretained(this), callback)); |
246 } | 266 } |
247 | 267 |
| 268 void ClearData(uint32_t remove_mask, |
| 269 uint32_t quota_storage_remove_mask, |
| 270 const OriginMatcherFunction& origin_matcher, |
| 271 const CookieMatcherFunction& cookie_matcher, |
| 272 const base::Time begin, |
| 273 const base::Time end, |
| 274 const base::Closure& callback) override { |
| 275 // Store stuff to verify parameters' correctness later. |
| 276 storage_partition_removal_data_.remove_mask = remove_mask; |
| 277 storage_partition_removal_data_.quota_storage_remove_mask = |
| 278 quota_storage_remove_mask; |
| 279 storage_partition_removal_data_.remove_begin = begin; |
| 280 storage_partition_removal_data_.remove_end = end; |
| 281 storage_partition_removal_data_.origin_matcher = origin_matcher; |
| 282 storage_partition_removal_data_.cookie_matcher = cookie_matcher; |
| 283 |
| 284 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 285 base::Bind(&TestStoragePartition::AsyncRunCallback, |
| 286 base::Unretained(this), callback)); |
| 287 } |
| 288 |
248 void Flush() override {} | 289 void Flush() override {} |
249 | 290 |
250 StoragePartitionRemovalData GetStoragePartitionRemovalData() { | 291 StoragePartitionRemovalData GetStoragePartitionRemovalData() { |
251 return storage_partition_removal_data_; | 292 return storage_partition_removal_data_; |
252 } | 293 } |
253 | 294 |
254 private: | 295 private: |
255 void AsyncRunCallback(const base::Closure& callback) { | 296 void AsyncRunCallback(const base::Closure& callback) { |
256 callback.Run(); | 297 callback.Run(); |
257 } | 298 } |
(...skipping 749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1007 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1048 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
1008 remover->Remove(BrowsingDataRemover::Period(period), remove_mask, | 1049 remover->Remove(BrowsingDataRemover::Period(period), remove_mask, |
1009 origin_type_mask); | 1050 origin_type_mask); |
1010 completion_observer.BlockUntilCompletion(); | 1051 completion_observer.BlockUntilCompletion(); |
1011 | 1052 |
1012 // Save so we can verify later. | 1053 // Save so we can verify later. |
1013 storage_partition_removal_data_ = | 1054 storage_partition_removal_data_ = |
1014 storage_partition.GetStoragePartitionRemovalData(); | 1055 storage_partition.GetStoragePartitionRemovalData(); |
1015 } | 1056 } |
1016 | 1057 |
1017 void BlockUntilOriginDataRemoved(BrowsingDataRemover::TimePeriod period, | 1058 void BlockUntilOriginDataRemoved( |
1018 int remove_mask, | 1059 BrowsingDataRemover::TimePeriod period, |
1019 const GURL& remove_origin) { | 1060 int remove_mask, |
| 1061 const BrowsingDataFilterBuilder& filter_builder) { |
1020 BrowsingDataRemover* remover = | 1062 BrowsingDataRemover* remover = |
1021 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); | 1063 BrowsingDataRemoverFactory::GetForBrowserContext(profile_.get()); |
1022 TestStoragePartition storage_partition; | 1064 TestStoragePartition storage_partition; |
1023 remover->OverrideStoragePartitionForTesting(&storage_partition); | 1065 remover->OverrideStoragePartitionForTesting(&storage_partition); |
1024 | 1066 |
1025 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); | 1067 called_with_details_.reset(new BrowsingDataRemover::NotificationDetails()); |
1026 | 1068 |
1027 BrowsingDataRemoverCompletionObserver completion_observer(remover); | 1069 BrowsingDataRemoverCompletionObserver completion_observer(remover); |
1028 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, | 1070 remover->RemoveImpl(BrowsingDataRemover::Period(period), remove_mask, |
1029 remove_origin, BrowsingDataHelper::UNPROTECTED_WEB); | 1071 filter_builder, BrowsingDataHelper::UNPROTECTED_WEB); |
1030 completion_observer.BlockUntilCompletion(); | 1072 completion_observer.BlockUntilCompletion(); |
1031 | 1073 |
1032 // Save so we can verify later. | 1074 // Save so we can verify later. |
1033 storage_partition_removal_data_ = | 1075 storage_partition_removal_data_ = |
1034 storage_partition.GetStoragePartitionRemovalData(); | 1076 storage_partition.GetStoragePartitionRemovalData(); |
1035 } | 1077 } |
1036 | 1078 |
1037 TestingProfile* GetProfile() { | 1079 TestingProfile* GetProfile() { |
1038 return profile_.get(); | 1080 return profile_.get(); |
1039 } | 1081 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 | 1171 |
1130 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1172 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1131 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1173 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1132 | 1174 |
1133 // Verify that storage partition was instructed to remove the cookies. | 1175 // Verify that storage partition was instructed to remove the cookies. |
1134 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1176 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1135 EXPECT_EQ(removal_data.remove_mask, | 1177 EXPECT_EQ(removal_data.remove_mask, |
1136 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1178 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1137 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1179 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1138 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1180 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1139 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1140 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1181 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1141 } | 1182 } |
1142 | 1183 |
1143 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { | 1184 TEST_F(BrowsingDataRemoverTest, RemoveCookieLastHour) { |
1144 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1185 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
1145 BrowsingDataRemover::REMOVE_COOKIES, | 1186 BrowsingDataRemover::REMOVE_COOKIES, |
1146 false); | 1187 false); |
1147 | 1188 |
1148 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1189 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1149 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1190 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1150 | 1191 |
1151 // Verify that storage partition was instructed to remove the cookies. | 1192 // Verify that storage partition was instructed to remove the cookies. |
1152 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1193 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1153 EXPECT_EQ(removal_data.remove_mask, | 1194 EXPECT_EQ(removal_data.remove_mask, |
1154 StoragePartition::REMOVE_DATA_MASK_COOKIES); | 1195 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
1155 // Removing with time period other than EVERYTHING should not clear | 1196 // Removing with time period other than EVERYTHING should not clear |
1156 // persistent storage data. | 1197 // persistent storage data. |
1157 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1198 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1158 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1199 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1159 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1160 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1200 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1161 } | 1201 } |
1162 | 1202 |
| 1203 TEST_F(BrowsingDataRemoverTest, RemoveCookiesDomainBlacklist) { |
| 1204 BrowsingDataFilterBuilder filter(BrowsingDataFilterBuilder::BLACKLIST); |
| 1205 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
| 1206 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
| 1207 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 1208 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1209 |
| 1210 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1211 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1212 |
| 1213 // Verify that storage partition was instructed to remove the cookies. |
| 1214 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
| 1215 EXPECT_EQ(removal_data.remove_mask, |
| 1216 StoragePartition::REMOVE_DATA_MASK_COOKIES); |
| 1217 // Removing with time period other than EVERYTHING should not clear |
| 1218 // persistent storage data. |
| 1219 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
| 1220 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
| 1221 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
| 1222 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1223 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1224 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1225 // Even though it's a different origin, it's the same domain. |
| 1226 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
| 1227 |
| 1228 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin1))); |
| 1229 EXPECT_TRUE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin2))); |
| 1230 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin3))); |
| 1231 // This is false, because this is the same domain as 3, just with a different |
| 1232 // scheme. |
| 1233 EXPECT_FALSE(removal_data.cookie_matcher.Run(CreateCookieWithHost(kOrigin4))); |
| 1234 } |
| 1235 |
1163 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { | 1236 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForever) { |
1164 RemoveSafeBrowsingCookieTester tester; | 1237 RemoveSafeBrowsingCookieTester tester; |
1165 | 1238 |
1166 tester.AddCookie(); | 1239 tester.AddCookie(); |
1167 ASSERT_TRUE(tester.ContainsCookie()); | 1240 ASSERT_TRUE(tester.ContainsCookie()); |
1168 | 1241 |
1169 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1242 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
1170 BrowsingDataRemover::REMOVE_COOKIES, false); | 1243 BrowsingDataRemover::REMOVE_COOKIES, false); |
1171 | 1244 |
1172 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1245 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
(...skipping 10 matching lines...) Expand all Loading... |
1183 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, | 1256 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_HOUR, |
1184 BrowsingDataRemover::REMOVE_COOKIES, false); | 1257 BrowsingDataRemover::REMOVE_COOKIES, false); |
1185 | 1258 |
1186 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); | 1259 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
1187 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1260 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1188 // Removing with time period other than EVERYTHING should not clear safe | 1261 // Removing with time period other than EVERYTHING should not clear safe |
1189 // browsing cookies. | 1262 // browsing cookies. |
1190 EXPECT_TRUE(tester.ContainsCookie()); | 1263 EXPECT_TRUE(tester.ContainsCookie()); |
1191 } | 1264 } |
1192 | 1265 |
| 1266 TEST_F(BrowsingDataRemoverTest, RemoveSafeBrowsingCookieForeverWithPredicate) { |
| 1267 RemoveSafeBrowsingCookieTester tester; |
| 1268 |
| 1269 tester.AddCookie(); |
| 1270 ASSERT_TRUE(tester.ContainsCookie()); |
| 1271 BrowsingDataFilterBuilder filter(BrowsingDataFilterBuilder::BLACKLIST); |
| 1272 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
| 1273 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1274 BrowsingDataRemover::REMOVE_COOKIES, filter); |
| 1275 |
| 1276 EXPECT_EQ(BrowsingDataRemover::REMOVE_COOKIES, GetRemovalMask()); |
| 1277 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 1278 EXPECT_TRUE(tester.ContainsCookie()); |
| 1279 |
| 1280 BrowsingDataFilterBuilder filter2(BrowsingDataFilterBuilder::WHITELIST); |
| 1281 filter2.AddRegisterableDomain(kTestRegisterableDomain1); |
| 1282 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
| 1283 BrowsingDataRemover::REMOVE_COOKIES, filter2); |
| 1284 EXPECT_FALSE(tester.ContainsCookie()); |
| 1285 } |
| 1286 |
1193 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { | 1287 TEST_F(BrowsingDataRemoverTest, RemoveChannelIDForever) { |
1194 RemoveChannelIDTester tester(GetProfile()); | 1288 RemoveChannelIDTester tester(GetProfile()); |
1195 | 1289 |
1196 tester.AddChannelID(kTestOrigin1); | 1290 tester.AddChannelID(kTestOrigin1); |
1197 EXPECT_EQ(0, tester.ssl_config_changed_count()); | 1291 EXPECT_EQ(0, tester.ssl_config_changed_count()); |
1198 EXPECT_EQ(1, tester.ChannelIDCount()); | 1292 EXPECT_EQ(1, tester.ChannelIDCount()); |
1199 | 1293 |
1200 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 1294 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
1201 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); | 1295 BrowsingDataRemover::REMOVE_CHANNEL_IDS, false); |
1202 | 1296 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1242 | 1336 |
1243 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1337 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1244 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1338 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1245 | 1339 |
1246 // Verify that storage partition was instructed to remove the data correctly. | 1340 // Verify that storage partition was instructed to remove the data correctly. |
1247 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1341 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1248 EXPECT_EQ(removal_data.remove_mask, | 1342 EXPECT_EQ(removal_data.remove_mask, |
1249 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1343 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1250 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1344 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1251 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1345 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1252 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1253 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1346 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1254 | 1347 |
1255 // Check origin matcher. | 1348 // Check origin matcher. |
1256 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1349 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
1257 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1350 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1258 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1351 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1259 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1352 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1260 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1353 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1261 } | 1354 } |
1262 | 1355 |
(...skipping 11 matching lines...) Expand all Loading... |
1274 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1367 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1275 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | | 1368 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB | |
1276 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); | 1369 BrowsingDataHelper::PROTECTED_WEB, GetOriginTypeMask()); |
1277 | 1370 |
1278 // Verify that storage partition was instructed to remove the data correctly. | 1371 // Verify that storage partition was instructed to remove the data correctly. |
1279 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1372 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1280 EXPECT_EQ(removal_data.remove_mask, | 1373 EXPECT_EQ(removal_data.remove_mask, |
1281 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1374 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1282 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1375 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1283 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1376 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1284 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1285 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1377 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1286 | 1378 |
1287 // Check origin matcher all http origin will match since we specified | 1379 // Check origin matcher all http origin will match since we specified |
1288 // both protected and unprotected. | 1380 // both protected and unprotected. |
1289 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1381 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1290 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1382 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1291 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1383 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1292 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1384 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1293 } | 1385 } |
1294 | 1386 |
1295 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { | 1387 TEST_F(BrowsingDataRemoverTest, RemoveLocalStorageForLastWeek) { |
1296 #if defined(ENABLE_EXTENSIONS) | 1388 #if defined(ENABLE_EXTENSIONS) |
1297 CreateMockPolicy(); | 1389 CreateMockPolicy(); |
1298 #endif | 1390 #endif |
1299 | 1391 |
1300 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, | 1392 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::LAST_WEEK, |
1301 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, | 1393 BrowsingDataRemover::REMOVE_LOCAL_STORAGE, |
1302 false); | 1394 false); |
1303 | 1395 |
1304 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); | 1396 EXPECT_EQ(BrowsingDataRemover::REMOVE_LOCAL_STORAGE, GetRemovalMask()); |
1305 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1397 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1306 | 1398 |
1307 // Verify that storage partition was instructed to remove the data correctly. | 1399 // Verify that storage partition was instructed to remove the data correctly. |
1308 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1400 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1309 EXPECT_EQ(removal_data.remove_mask, | 1401 EXPECT_EQ(removal_data.remove_mask, |
1310 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); | 1402 StoragePartition::REMOVE_DATA_MASK_LOCAL_STORAGE); |
1311 // Persistent storage won't be deleted. | 1403 // Persistent storage won't be deleted. |
1312 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1404 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1313 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); | 1405 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT); |
1314 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1315 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1406 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1316 | 1407 |
1317 // Check origin matcher. | 1408 // Check origin matcher. |
1318 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1409 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1319 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1410 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1320 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1411 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1321 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 1412 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1322 } | 1413 } |
1323 | 1414 |
1324 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { | 1415 TEST_F(BrowsingDataRemoverTest, RemoveHistoryForever) { |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1601 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1511 EXPECT_EQ(removal_data.remove_mask, | 1602 EXPECT_EQ(removal_data.remove_mask, |
1512 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1603 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1513 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1604 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1514 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1605 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1515 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1606 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1516 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1607 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1517 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1608 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1518 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1609 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1519 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1610 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1520 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1521 } | 1611 } |
1522 | 1612 |
1523 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { | 1613 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyTemporary) { |
1524 #if defined(ENABLE_EXTENSIONS) | 1614 #if defined(ENABLE_EXTENSIONS) |
1525 CreateMockPolicy(); | 1615 CreateMockPolicy(); |
1526 #endif | 1616 #endif |
1527 | 1617 |
1528 BlockUntilBrowsingDataRemoved( | 1618 BlockUntilBrowsingDataRemoved( |
1529 BrowsingDataRemover::EVERYTHING, | 1619 BrowsingDataRemover::EVERYTHING, |
1530 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1620 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
(...skipping 18 matching lines...) Expand all Loading... |
1549 | 1639 |
1550 EXPECT_EQ(removal_data.remove_mask, | 1640 EXPECT_EQ(removal_data.remove_mask, |
1551 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1641 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1552 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1642 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1553 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1643 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1554 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1644 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1555 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1645 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1556 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1646 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1557 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1647 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1558 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1648 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1559 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1560 | 1649 |
1561 // Check that all related origin data would be removed, that is, origin | 1650 // Check that all related origin data would be removed, that is, origin |
1562 // matcher would match these origin. | 1651 // matcher would match these origin. |
1563 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1652 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1564 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1653 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1565 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1654 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1566 } | 1655 } |
1567 | 1656 |
1568 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { | 1657 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverOnlyPersistent) { |
1569 #if defined(ENABLE_EXTENSIONS) | 1658 #if defined(ENABLE_EXTENSIONS) |
(...skipping 24 matching lines...) Expand all Loading... |
1594 | 1683 |
1595 EXPECT_EQ(removal_data.remove_mask, | 1684 EXPECT_EQ(removal_data.remove_mask, |
1596 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1685 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1597 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1686 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1598 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1687 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1599 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1688 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1600 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1689 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1601 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1690 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1602 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1691 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1603 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1692 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1604 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1605 | 1693 |
1606 // Check that all related origin data would be removed, that is, origin | 1694 // Check that all related origin data would be removed, that is, origin |
1607 // matcher would match these origin. | 1695 // matcher would match these origin. |
1608 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1696 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1609 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1697 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1610 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1698 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1611 } | 1699 } |
1612 | 1700 |
1613 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { | 1701 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverNeither) { |
1614 #if defined(ENABLE_EXTENSIONS) | 1702 #if defined(ENABLE_EXTENSIONS) |
(...skipping 24 matching lines...) Expand all Loading... |
1639 | 1727 |
1640 EXPECT_EQ(removal_data.remove_mask, | 1728 EXPECT_EQ(removal_data.remove_mask, |
1641 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1729 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1642 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1730 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1643 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1731 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1644 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1732 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1645 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1733 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1646 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1734 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1647 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1735 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1648 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1736 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1649 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1650 | 1737 |
1651 // Check that all related origin data would be removed, that is, origin | 1738 // Check that all related origin data would be removed, that is, origin |
1652 // matcher would match these origin. | 1739 // matcher would match these origin. |
1653 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1740 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1654 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1741 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1655 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1742 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1656 } | 1743 } |
1657 | 1744 |
1658 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { | 1745 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForeverSpecificOrigin) { |
| 1746 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::WHITELIST); |
| 1747 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
1659 // Remove Origin 1. | 1748 // Remove Origin 1. |
1660 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 1749 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
1661 BrowsingDataRemover::REMOVE_APPCACHE | | 1750 BrowsingDataRemover::REMOVE_APPCACHE | |
1662 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1751 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1663 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1752 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1664 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1753 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1665 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1754 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1666 BrowsingDataRemover::REMOVE_WEBSQL, | 1755 BrowsingDataRemover::REMOVE_WEBSQL, |
1667 kOrigin1); | 1756 builder); |
1668 | 1757 |
1669 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 1758 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
1670 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1759 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1671 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1760 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1672 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1761 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1673 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1762 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1674 BrowsingDataRemover::REMOVE_WEBSQL, | 1763 BrowsingDataRemover::REMOVE_WEBSQL, |
1675 GetRemovalMask()); | 1764 GetRemovalMask()); |
1676 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1765 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1677 | 1766 |
1678 // Verify storage partition related stuffs. | 1767 // Verify storage partition related stuffs. |
1679 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1768 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1680 | 1769 |
1681 EXPECT_EQ(removal_data.remove_mask, | 1770 EXPECT_EQ(removal_data.remove_mask, |
1682 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1771 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1683 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1772 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1684 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1773 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1685 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1774 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1686 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1775 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1687 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1776 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1688 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1777 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1689 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1778 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1690 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | 1779 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
| 1780 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1781 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
| 1782 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin4, mock_policy())); |
1691 } | 1783 } |
1692 | 1784 |
1693 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { | 1785 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastHour) { |
1694 BlockUntilBrowsingDataRemoved( | 1786 BlockUntilBrowsingDataRemoved( |
1695 BrowsingDataRemover::LAST_HOUR, | 1787 BrowsingDataRemover::LAST_HOUR, |
1696 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1788 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1697 BrowsingDataRemover::REMOVE_WEBSQL | | 1789 BrowsingDataRemover::REMOVE_WEBSQL | |
1698 BrowsingDataRemover::REMOVE_APPCACHE | | 1790 BrowsingDataRemover::REMOVE_APPCACHE | |
1699 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1791 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1700 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1792 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
(...skipping 18 matching lines...) Expand all Loading... |
1719 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1811 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1720 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1812 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1721 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1813 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1722 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1814 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1723 | 1815 |
1724 // Persistent data would be left out since we are not removing from | 1816 // Persistent data would be left out since we are not removing from |
1725 // beginning of time. | 1817 // beginning of time. |
1726 uint32_t expected_quota_mask = | 1818 uint32_t expected_quota_mask = |
1727 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1819 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1728 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1820 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1729 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1730 // Check removal begin time. | 1821 // Check removal begin time. |
1731 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1822 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1732 } | 1823 } |
1733 | 1824 |
1734 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { | 1825 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedDataForLastWeek) { |
1735 BlockUntilBrowsingDataRemoved( | 1826 BlockUntilBrowsingDataRemoved( |
1736 BrowsingDataRemover::LAST_WEEK, | 1827 BrowsingDataRemover::LAST_WEEK, |
1737 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1828 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1738 BrowsingDataRemover::REMOVE_WEBSQL | | 1829 BrowsingDataRemover::REMOVE_WEBSQL | |
1739 BrowsingDataRemover::REMOVE_APPCACHE | | 1830 BrowsingDataRemover::REMOVE_APPCACHE | |
(...skipping 20 matching lines...) Expand all Loading... |
1760 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1851 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1761 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1852 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1762 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1853 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1763 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1854 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1764 | 1855 |
1765 // Persistent data would be left out since we are not removing from | 1856 // Persistent data would be left out since we are not removing from |
1766 // beginning of time. | 1857 // beginning of time. |
1767 uint32_t expected_quota_mask = | 1858 uint32_t expected_quota_mask = |
1768 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; | 1859 ~StoragePartition::QUOTA_MANAGED_STORAGE_MASK_PERSISTENT; |
1769 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); | 1860 EXPECT_EQ(removal_data.quota_storage_remove_mask, expected_quota_mask); |
1770 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1771 // Check removal begin time. | 1861 // Check removal begin time. |
1772 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); | 1862 EXPECT_EQ(removal_data.remove_begin, GetBeginTime()); |
1773 } | 1863 } |
1774 | 1864 |
1775 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { | 1865 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedUnprotectedOrigins) { |
1776 #if defined(ENABLE_EXTENSIONS) | 1866 #if defined(ENABLE_EXTENSIONS) |
1777 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1867 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1778 // Protect kOrigin1. | 1868 // Protect kOrigin1. |
1779 policy->AddProtected(kOrigin1.GetOrigin()); | 1869 policy->AddProtected(kOrigin1.GetOrigin()); |
1780 #endif | 1870 #endif |
(...skipping 22 matching lines...) Expand all Loading... |
1803 | 1893 |
1804 EXPECT_EQ(removal_data.remove_mask, | 1894 EXPECT_EQ(removal_data.remove_mask, |
1805 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1895 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1806 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1896 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1807 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1897 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1808 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1898 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1809 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1899 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1810 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1900 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1811 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1901 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1812 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1902 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1813 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1814 | 1903 |
1815 // Check OriginMatcherFunction. | 1904 // Check OriginMatcherFunction. |
1816 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1905 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
1817 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1906 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1818 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1907 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1819 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1908 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1820 } | 1909 } |
1821 | 1910 |
1822 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { | 1911 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedSpecificOrigin) { |
1823 #if defined(ENABLE_EXTENSIONS) | 1912 #if defined(ENABLE_EXTENSIONS) |
1824 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1913 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1825 // Protect kOrigin1. | 1914 // Protect kOrigin1. |
1826 policy->AddProtected(kOrigin1.GetOrigin()); | 1915 policy->AddProtected(kOrigin1.GetOrigin()); |
1827 #endif | 1916 #endif |
1828 | 1917 |
| 1918 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::WHITELIST); |
| 1919 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
| 1920 |
1829 // Try to remove kOrigin1. Expect failure. | 1921 // Try to remove kOrigin1. Expect failure. |
1830 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 1922 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
1831 BrowsingDataRemover::REMOVE_APPCACHE | | 1923 BrowsingDataRemover::REMOVE_APPCACHE | |
1832 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1924 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1833 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1925 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1834 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1926 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1835 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1927 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1836 BrowsingDataRemover::REMOVE_WEBSQL, | 1928 BrowsingDataRemover::REMOVE_WEBSQL, |
1837 kOrigin1); | 1929 builder); |
1838 | 1930 |
1839 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | | 1931 EXPECT_EQ(BrowsingDataRemover::REMOVE_APPCACHE | |
1840 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | | 1932 BrowsingDataRemover::REMOVE_SERVICE_WORKERS | |
1841 BrowsingDataRemover::REMOVE_CACHE_STORAGE | | 1933 BrowsingDataRemover::REMOVE_CACHE_STORAGE | |
1842 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | | 1934 BrowsingDataRemover::REMOVE_FILE_SYSTEMS | |
1843 BrowsingDataRemover::REMOVE_INDEXEDDB | | 1935 BrowsingDataRemover::REMOVE_INDEXEDDB | |
1844 BrowsingDataRemover::REMOVE_WEBSQL, | 1936 BrowsingDataRemover::REMOVE_WEBSQL, |
1845 GetRemovalMask()); | 1937 GetRemovalMask()); |
1846 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 1938 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
1847 | 1939 |
1848 // Verify storage partition related stuffs. | 1940 // Verify storage partition related stuffs. |
1849 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); | 1941 StoragePartitionRemovalData removal_data = GetStoragePartitionRemovalData(); |
1850 | 1942 |
1851 EXPECT_EQ(removal_data.remove_mask, | 1943 EXPECT_EQ(removal_data.remove_mask, |
1852 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1944 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1853 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1945 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1854 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1946 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1855 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1947 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1856 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1948 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1857 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1949 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1858 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 1950 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1859 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 1951 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1860 EXPECT_EQ(removal_data.remove_origin, kOrigin1); | |
1861 | 1952 |
1862 // Check OriginMatcherFunction. | 1953 // Check OriginMatcherFunction. |
1863 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), | 1954 EXPECT_EQ(ShouldRemoveForProtectedOriginOne(), |
1864 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 1955 removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1865 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 1956 // Since we use the matcher function to validate origins now, this should |
1866 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 1957 // return false for the origins we're not trying to clear. |
| 1958 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
| 1959 EXPECT_FALSE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1867 } | 1960 } |
1868 | 1961 |
1869 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { | 1962 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedProtectedOrigins) { |
1870 #if defined(ENABLE_EXTENSIONS) | 1963 #if defined(ENABLE_EXTENSIONS) |
1871 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); | 1964 MockExtensionSpecialStoragePolicy* policy = CreateMockPolicy(); |
1872 // Protect kOrigin1. | 1965 // Protect kOrigin1. |
1873 policy->AddProtected(kOrigin1.GetOrigin()); | 1966 policy->AddProtected(kOrigin1.GetOrigin()); |
1874 #endif | 1967 #endif |
1875 | 1968 |
1876 // Try to remove kOrigin1. Expect success. | 1969 // Try to remove kOrigin1. Expect success. |
(...skipping 22 matching lines...) Expand all Loading... |
1899 | 1992 |
1900 EXPECT_EQ(removal_data.remove_mask, | 1993 EXPECT_EQ(removal_data.remove_mask, |
1901 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 1994 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1902 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 1995 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1903 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 1996 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1904 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 1997 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1905 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 1998 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1906 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 1999 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1907 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 2000 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1908 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 2001 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1909 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1910 | 2002 |
1911 // Check OriginMatcherFunction, |kOrigin1| would match mask since we | 2003 // Check OriginMatcherFunction, |kOrigin1| would match mask since we |
1912 // would have 'protected' specified in origin_type_mask. | 2004 // would have 'protected' specified in origin_type_mask. |
1913 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); | 2005 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin1, mock_policy())); |
1914 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); | 2006 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin2, mock_policy())); |
1915 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); | 2007 EXPECT_TRUE(removal_data.origin_matcher.Run(kOrigin3, mock_policy())); |
1916 } | 2008 } |
1917 | 2009 |
1918 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { | 2010 TEST_F(BrowsingDataRemoverTest, RemoveQuotaManagedIgnoreExtensionsAndDevTools) { |
1919 #if defined(ENABLE_EXTENSIONS) | 2011 #if defined(ENABLE_EXTENSIONS) |
(...skipping 24 matching lines...) Expand all Loading... |
1944 | 2036 |
1945 EXPECT_EQ(removal_data.remove_mask, | 2037 EXPECT_EQ(removal_data.remove_mask, |
1946 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | | 2038 StoragePartition::REMOVE_DATA_MASK_FILE_SYSTEMS | |
1947 StoragePartition::REMOVE_DATA_MASK_WEBSQL | | 2039 StoragePartition::REMOVE_DATA_MASK_WEBSQL | |
1948 StoragePartition::REMOVE_DATA_MASK_APPCACHE | | 2040 StoragePartition::REMOVE_DATA_MASK_APPCACHE | |
1949 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | | 2041 StoragePartition::REMOVE_DATA_MASK_SERVICE_WORKERS | |
1950 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | | 2042 StoragePartition::REMOVE_DATA_MASK_CACHE_STORAGE | |
1951 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); | 2043 StoragePartition::REMOVE_DATA_MASK_INDEXEDDB); |
1952 EXPECT_EQ(removal_data.quota_storage_remove_mask, | 2044 EXPECT_EQ(removal_data.quota_storage_remove_mask, |
1953 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); | 2045 StoragePartition::QUOTA_MANAGED_STORAGE_MASK_ALL); |
1954 EXPECT_TRUE(removal_data.remove_origin.is_empty()); | |
1955 | 2046 |
1956 // Check that extension and devtools data wouldn't be removed, that is, | 2047 // Check that extension and devtools data wouldn't be removed, that is, |
1957 // origin matcher would not match these origin. | 2048 // origin matcher would not match these origin. |
1958 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); | 2049 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginExt, mock_policy())); |
1959 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); | 2050 EXPECT_FALSE(removal_data.origin_matcher.Run(kOriginDevTools, mock_policy())); |
1960 } | 2051 } |
1961 | 2052 |
1962 TEST_F(BrowsingDataRemoverTest, OriginBasedHistoryRemoval) { | 2053 TEST_F(BrowsingDataRemoverTest, TimeBasedHistoryRemoval) { |
1963 RemoveHistoryTester tester; | 2054 RemoveHistoryTester tester; |
1964 ASSERT_TRUE(tester.Init(GetProfile())); | 2055 ASSERT_TRUE(tester.Init(GetProfile())); |
1965 | 2056 |
1966 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | |
1967 | |
1968 tester.AddHistory(kOrigin1, base::Time::Now()); | |
1969 tester.AddHistory(kOrigin2, two_hours_ago); | |
1970 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | |
1971 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | |
1972 | |
1973 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | |
1974 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | |
1975 | |
1976 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | |
1977 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | |
1978 | |
1979 // Nothing should have been deleted. | |
1980 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | |
1981 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin2)); | |
1982 } | |
1983 | |
1984 TEST_F(BrowsingDataRemoverTest, OriginAndTimeBasedHistoryRemoval) { | |
1985 RemoveHistoryTester tester; | |
1986 ASSERT_TRUE(tester.Init(GetProfile())); | |
1987 | |
1988 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); | 2057 base::Time two_hours_ago = base::Time::Now() - base::TimeDelta::FromHours(2); |
1989 | 2058 |
1990 tester.AddHistory(kOrigin1, base::Time::Now()); | 2059 tester.AddHistory(kOrigin1, base::Time::Now()); |
1991 tester.AddHistory(kOrigin2, two_hours_ago); | 2060 tester.AddHistory(kOrigin2, two_hours_ago); |
1992 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2061 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin1)); |
1993 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2062 ASSERT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
1994 | 2063 |
| 2064 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::BLACKLIST); |
1995 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, | 2065 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
1996 BrowsingDataRemover::REMOVE_HISTORY, kOrigin2); | 2066 BrowsingDataRemover::REMOVE_HISTORY, builder); |
1997 | 2067 |
1998 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); | 2068 EXPECT_EQ(BrowsingDataRemover::REMOVE_HISTORY, GetRemovalMask()); |
1999 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); | 2069 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
2000 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin1)); | 2070 EXPECT_FALSE(tester.HistoryContainsURL(kOrigin1)); |
2001 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); | 2071 EXPECT_TRUE(tester.HistoryContainsURL(kOrigin2)); |
2002 } | 2072 } |
2003 | 2073 |
2004 // Verify that clearing autofill form data works. | 2074 // Verify that clearing autofill form data works. |
2005 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { | 2075 TEST_F(BrowsingDataRemoverTest, AutofillRemovalLastHour) { |
2006 GetProfile()->CreateWebDataService(); | 2076 GetProfile()->CreateWebDataService(); |
2007 RemoveAutofillTester tester(GetProfile()); | 2077 RemoveAutofillTester tester(GetProfile()); |
2008 | 2078 |
2009 ASSERT_FALSE(tester.HasProfile()); | 2079 ASSERT_FALSE(tester.HasProfile()); |
2010 tester.AddProfilesAndCards(); | 2080 tester.AddProfilesAndCards(); |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2221 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { | 2291 TEST_F(BrowsingDataRemoverTest, DISABLED_DomainReliability_NoMonitor) { |
2222 BlockUntilBrowsingDataRemoved( | 2292 BlockUntilBrowsingDataRemoved( |
2223 BrowsingDataRemover::EVERYTHING, | 2293 BrowsingDataRemover::EVERYTHING, |
2224 BrowsingDataRemover::REMOVE_HISTORY | | 2294 BrowsingDataRemover::REMOVE_HISTORY | |
2225 BrowsingDataRemover::REMOVE_COOKIES, false); | 2295 BrowsingDataRemover::REMOVE_COOKIES, false); |
2226 } | 2296 } |
2227 | 2297 |
2228 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { | 2298 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByTimeOnly) { |
2229 RemoveDownloadsTester tester(GetProfile()); | 2299 RemoveDownloadsTester tester(GetProfile()); |
2230 base::Callback<bool(const GURL&)> filter = | 2300 base::Callback<bool(const GURL&)> filter = |
2231 OriginFilterBuilder::BuildNoopFilter(); | 2301 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2232 | 2302 |
2233 EXPECT_CALL( | 2303 EXPECT_CALL( |
2234 *tester.download_manager(), | 2304 *tester.download_manager(), |
2235 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2305 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2236 | 2306 |
2237 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2307 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
2238 BrowsingDataRemover::REMOVE_DOWNLOADS, false); | 2308 BrowsingDataRemover::REMOVE_DOWNLOADS, false); |
2239 } | 2309 } |
2240 | 2310 |
2241 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { | 2311 TEST_F(BrowsingDataRemoverTest, RemoveDownloadsByOrigin) { |
2242 RemoveDownloadsTester tester(GetProfile()); | 2312 RemoveDownloadsTester tester(GetProfile()); |
2243 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); | 2313 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::WHITELIST); |
2244 builder.AddOrigin(url::Origin(kOrigin1)); | 2314 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2245 base::Callback<bool(const GURL&)> filter = builder.BuildSameOriginFilter(); | 2315 base::Callback<bool(const GURL&)> filter = builder.BuildSameDomainFilter(); |
2246 | 2316 |
2247 EXPECT_CALL( | 2317 EXPECT_CALL( |
2248 *tester.download_manager(), | 2318 *tester.download_manager(), |
2249 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); | 2319 RemoveDownloadsByURLAndTime(ProbablySameFilter(filter), _, _)); |
2250 | 2320 |
2251 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 2321 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
2252 BrowsingDataRemover::REMOVE_DOWNLOADS, kOrigin1); | 2322 BrowsingDataRemover::REMOVE_DOWNLOADS, builder); |
2253 } | 2323 } |
2254 | 2324 |
2255 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { | 2325 TEST_F(BrowsingDataRemoverTest, RemovePasswordStatistics) { |
2256 RemovePasswordsTester tester(GetProfile()); | 2326 RemovePasswordsTester tester(GetProfile()); |
2257 | 2327 |
2258 EXPECT_CALL(*tester.store(), RemoveStatisticsCreatedBetweenImpl( | 2328 EXPECT_CALL(*tester.store(), RemoveStatisticsCreatedBetweenImpl( |
2259 base::Time(), base::Time::Max())); | 2329 base::Time(), base::Time::Max())); |
2260 BlockUntilBrowsingDataRemoved( | 2330 BlockUntilBrowsingDataRemoved( |
2261 BrowsingDataRemover::EVERYTHING, | 2331 BrowsingDataRemover::EVERYTHING, |
2262 BrowsingDataRemover::REMOVE_HISTORY, false); | 2332 BrowsingDataRemover::REMOVE_HISTORY, false); |
2263 } | 2333 } |
2264 | 2334 |
2265 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { | 2335 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByTimeOnly) { |
2266 RemovePasswordsTester tester(GetProfile()); | 2336 RemovePasswordsTester tester(GetProfile()); |
2267 base::Callback<bool(const GURL&)> filter = | 2337 base::Callback<bool(const GURL&)> filter = |
2268 OriginFilterBuilder::BuildNoopFilter(); | 2338 BrowsingDataFilterBuilder::BuildNoopFilter(); |
2269 | 2339 |
2270 EXPECT_CALL(*tester.store(), | 2340 EXPECT_CALL(*tester.store(), |
2271 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2341 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2272 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2342 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2273 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2343 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
2274 BrowsingDataRemover::REMOVE_PASSWORDS, false); | 2344 BrowsingDataRemover::REMOVE_PASSWORDS, false); |
2275 } | 2345 } |
2276 | 2346 |
2277 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { | 2347 TEST_F(BrowsingDataRemoverTest, RemovePasswordsByOrigin) { |
2278 RemovePasswordsTester tester(GetProfile()); | 2348 RemovePasswordsTester tester(GetProfile()); |
2279 OriginFilterBuilder builder(OriginFilterBuilder::WHITELIST); | 2349 BrowsingDataFilterBuilder builder(BrowsingDataFilterBuilder::WHITELIST); |
2280 builder.AddOrigin(url::Origin(kOrigin1)); | 2350 builder.AddRegisterableDomain(kTestRegisterableDomain1); |
2281 base::Callback<bool(const GURL&)> filter = builder.BuildSameOriginFilter(); | 2351 base::Callback<bool(const GURL&)> filter = builder.BuildSameDomainFilter(); |
2282 | 2352 |
2283 EXPECT_CALL(*tester.store(), | 2353 EXPECT_CALL(*tester.store(), |
2284 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) | 2354 RemoveLoginsByURLAndTimeImpl(ProbablySameFilter(filter), _, _)) |
2285 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2355 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2286 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, | 2356 BlockUntilOriginDataRemoved(BrowsingDataRemover::EVERYTHING, |
2287 BrowsingDataRemover::REMOVE_PASSWORDS, kOrigin1); | 2357 BrowsingDataRemover::REMOVE_PASSWORDS, builder); |
2288 } | 2358 } |
2289 | 2359 |
2290 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { | 2360 TEST_F(BrowsingDataRemoverTest, DisableAutoSignIn) { |
2291 RemovePasswordsTester tester(GetProfile()); | 2361 RemovePasswordsTester tester(GetProfile()); |
2292 | 2362 |
2293 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2363 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
2294 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2364 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2295 | 2365 |
2296 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2366 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
2297 BrowsingDataRemover::REMOVE_COOKIES, false); | 2367 BrowsingDataRemover::REMOVE_COOKIES, false); |
2298 } | 2368 } |
2299 | 2369 |
2300 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { | 2370 TEST_F(BrowsingDataRemoverTest, DisableAutoSignInAfterRemovingPasswords) { |
2301 RemovePasswordsTester tester(GetProfile()); | 2371 RemovePasswordsTester tester(GetProfile()); |
2302 | 2372 |
2303 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) | 2373 EXPECT_CALL(*tester.store(), RemoveLoginsByURLAndTimeImpl(_, _, _)) |
2304 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2374 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2305 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) | 2375 EXPECT_CALL(*tester.store(), DisableAutoSignInForAllLoginsImpl()) |
2306 .WillOnce(Return(password_manager::PasswordStoreChangeList())); | 2376 .WillOnce(Return(password_manager::PasswordStoreChangeList())); |
2307 | 2377 |
2308 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, | 2378 BlockUntilBrowsingDataRemoved(BrowsingDataRemover::EVERYTHING, |
2309 BrowsingDataRemover::REMOVE_COOKIES | | 2379 BrowsingDataRemover::REMOVE_COOKIES | |
2310 BrowsingDataRemover::REMOVE_PASSWORDS, | 2380 BrowsingDataRemover::REMOVE_PASSWORDS, |
2311 false); | 2381 false); |
2312 } | 2382 } |
| 2383 |
| 2384 TEST_F(BrowsingDataRemoverTest, RemoveContentSettingsWithBlacklist) { |
| 2385 // Add our settings. |
| 2386 HostContentSettingsMap* host_content_settings_map = |
| 2387 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2388 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2389 kOrigin1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2390 new base::DictionaryValue()); |
| 2391 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2392 kOrigin2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2393 new base::DictionaryValue()); |
| 2394 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2395 kOrigin3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2396 new base::DictionaryValue()); |
| 2397 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2398 kOrigin4, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2399 new base::DictionaryValue()); |
| 2400 |
| 2401 // Clear all except for origin1 and origin3. |
| 2402 BrowsingDataFilterBuilder filter(BrowsingDataFilterBuilder::BLACKLIST); |
| 2403 filter.AddRegisterableDomain(kTestRegisterableDomain1); |
| 2404 filter.AddRegisterableDomain(kTestRegisterableDomain3); |
| 2405 BlockUntilOriginDataRemoved(BrowsingDataRemover::LAST_HOUR, |
| 2406 BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, |
| 2407 filter); |
| 2408 |
| 2409 EXPECT_EQ(BrowsingDataRemover::REMOVE_SITE_USAGE_DATA, GetRemovalMask()); |
| 2410 EXPECT_EQ(BrowsingDataHelper::UNPROTECTED_WEB, GetOriginTypeMask()); |
| 2411 |
| 2412 // Verify we only have true, and they're origin1, origin3, and origin4. |
| 2413 ContentSettingsForOneType host_settings; |
| 2414 host_content_settings_map->GetSettingsForOneType( |
| 2415 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2416 EXPECT_EQ(3u, host_settings.size()); |
| 2417 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin1), |
| 2418 host_settings[0].primary_pattern) |
| 2419 << host_settings[0].primary_pattern.ToString(); |
| 2420 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin4), |
| 2421 host_settings[1].primary_pattern) |
| 2422 << host_settings[1].primary_pattern.ToString(); |
| 2423 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(kOrigin3), |
| 2424 host_settings[2].primary_pattern) |
| 2425 << host_settings[2].primary_pattern.ToString(); |
| 2426 } |
| 2427 |
| 2428 TEST_F(BrowsingDataRemoverTest, ClearWithPredicate) { |
| 2429 HostContentSettingsMap* host_content_settings_map = |
| 2430 HostContentSettingsMapFactory::GetForProfile(GetProfile()); |
| 2431 ContentSettingsForOneType host_settings; |
| 2432 |
| 2433 // Patterns with wildcards. |
| 2434 ContentSettingsPattern pattern = |
| 2435 ContentSettingsPattern::FromString("[*.]example.org"); |
| 2436 ContentSettingsPattern pattern2 = |
| 2437 ContentSettingsPattern::FromString("[*.]example.net"); |
| 2438 |
| 2439 // Patterns without wildcards. |
| 2440 GURL url1("https://www.google.com/"); |
| 2441 GURL url2("https://www.google.com/maps"); |
| 2442 GURL url3("http://www.google.com/maps"); |
| 2443 GURL url3_origin_only("http://www.google.com/"); |
| 2444 |
| 2445 host_content_settings_map->SetContentSettingCustomScope( |
| 2446 pattern2, ContentSettingsPattern::Wildcard(), |
| 2447 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), CONTENT_SETTING_BLOCK); |
| 2448 host_content_settings_map->SetContentSettingCustomScope( |
| 2449 pattern, ContentSettingsPattern::Wildcard(), CONTENT_SETTINGS_TYPE_IMAGES, |
| 2450 std::string(), CONTENT_SETTING_BLOCK); |
| 2451 host_content_settings_map->SetWebsiteSettingCustomScope( |
| 2452 pattern2, ContentSettingsPattern::Wildcard(), |
| 2453 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), |
| 2454 make_scoped_ptr(new base::DictionaryValue())); |
| 2455 |
| 2456 // First, test that we clear only IMAGES (not APP_BANNER), and pattern2. |
| 2457 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2458 host_content_settings_map, CONTENT_SETTINGS_TYPE_IMAGES, |
| 2459 base::Bind(&MatchPrimaryPattern, pattern2)); |
| 2460 host_content_settings_map->GetSettingsForOneType( |
| 2461 CONTENT_SETTINGS_TYPE_IMAGES, std::string(), &host_settings); |
| 2462 // |host_settings| contains default & block. |
| 2463 EXPECT_EQ(2U, host_settings.size()); |
| 2464 EXPECT_EQ(pattern, host_settings[0].primary_pattern); |
| 2465 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2466 EXPECT_EQ("*", host_settings[1].primary_pattern.ToString()); |
| 2467 EXPECT_EQ("*", host_settings[1].secondary_pattern.ToString()); |
| 2468 |
| 2469 host_content_settings_map->GetSettingsForOneType( |
| 2470 CONTENT_SETTINGS_TYPE_APP_BANNER, std::string(), &host_settings); |
| 2471 // |host_settings| contains block. |
| 2472 EXPECT_EQ(1U, host_settings.size()); |
| 2473 EXPECT_EQ(pattern2, host_settings[0].primary_pattern); |
| 2474 EXPECT_EQ("*", host_settings[0].secondary_pattern.ToString()); |
| 2475 |
| 2476 // Next, test that we do correct pattern matching w/ an origin policy item. |
| 2477 // We verify that we have no settings stored. |
| 2478 host_content_settings_map->GetSettingsForOneType( |
| 2479 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2480 EXPECT_EQ(0u, host_settings.size()); |
| 2481 // Add settings. |
| 2482 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2483 url1, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2484 new base::DictionaryValue()); |
| 2485 // This setting should override the one above, as it's the same origin. |
| 2486 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2487 url2, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2488 new base::DictionaryValue()); |
| 2489 host_content_settings_map->SetWebsiteSettingDefaultScope( |
| 2490 url3, GURL(), CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), |
| 2491 new base::DictionaryValue()); |
| 2492 // Verify we only have two. |
| 2493 host_content_settings_map->GetSettingsForOneType( |
| 2494 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2495 EXPECT_EQ(2u, host_settings.size()); |
| 2496 |
| 2497 // Clear the http one, which we should be able to do w/ the origin only, as |
| 2498 // the scope of CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT is |
| 2499 // REQUESTING_ORIGIN_ONLY_SCOPE. |
| 2500 ContentSettingsPattern http_pattern = |
| 2501 ContentSettingsPattern::FromURLNoWildcard(url3_origin_only); |
| 2502 BrowsingDataRemover::ClearSettingsForOneTypeWithPredicate( |
| 2503 host_content_settings_map, CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, |
| 2504 base::Bind(&MatchPrimaryPattern, http_pattern)); |
| 2505 // Verify we only have one, and it's url1. |
| 2506 host_content_settings_map->GetSettingsForOneType( |
| 2507 CONTENT_SETTINGS_TYPE_SITE_ENGAGEMENT, std::string(), &host_settings); |
| 2508 EXPECT_EQ(1u, host_settings.size()); |
| 2509 EXPECT_EQ(ContentSettingsPattern::FromURLNoWildcard(url1), |
| 2510 host_settings[0].primary_pattern); |
| 2511 } |
OLD | NEW |