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

Side by Side Diff: chrome/browser/extensions/api/browsing_data/browsing_data_test.cc

Issue 2664253006: Clears out external protocol data when cookies and site data is cleared. (Closed)
Patch Set: a Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (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 <memory> 5 #include <memory>
6 #include <string> 6 #include <string>
7 7
8 #include "base/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/strings/pattern.h" 10 #include "base/strings/pattern.h"
(...skipping 23 matching lines...) Expand all
34 EXTENSION = BrowsingDataHelper::EXTENSION 34 EXTENSION = BrowsingDataHelper::EXTENSION
35 }; 35 };
36 36
37 const char kRemoveEverythingArguments[] = 37 const char kRemoveEverythingArguments[] =
38 "[{\"since\": 1000}, {" 38 "[{\"since\": 1000}, {"
39 "\"appcache\": true, \"cache\": true, \"cookies\": true, " 39 "\"appcache\": true, \"cache\": true, \"cookies\": true, "
40 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, " 40 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
41 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, " 41 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
42 "\"serverBoundCertificates\": true, \"passwords\": true, " 42 "\"serverBoundCertificates\": true, \"passwords\": true, "
43 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, " 43 "\"pluginData\": true, \"serviceWorkers\": true, \"cacheStorage\": true, "
44 "\"webSQL\": true" 44 "\"webSQL\": true, \"externalProtocolData\": true"
45 "}]"; 45 "}]";
46 46
47 class ExtensionBrowsingDataTest : public InProcessBrowserTest { 47 class ExtensionBrowsingDataTest : public InProcessBrowserTest {
48 public: 48 public:
49 const base::Time& GetBeginTime() { 49 const base::Time& GetBeginTime() {
50 return remover_->GetLastUsedBeginTime(); 50 return remover_->GetLastUsedBeginTime();
51 } 51 }
52 52
53 int GetRemovalMask() { 53 int GetRemovalMask() {
54 return remover_->GetLastUsedRemovalMask(); 54 return remover_->GetLastUsedRemovalMask();
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 BrowsingDataRemover::REMOVE_PLUGIN_DATA) | 214 BrowsingDataRemover::REMOVE_PLUGIN_DATA) |
215 GetAsMask(data_to_remove, "passwords", 215 GetAsMask(data_to_remove, "passwords",
216 BrowsingDataRemover::REMOVE_PASSWORDS) | 216 BrowsingDataRemover::REMOVE_PASSWORDS) |
217 GetAsMask(data_to_remove, "serviceWorkers", 217 GetAsMask(data_to_remove, "serviceWorkers",
218 BrowsingDataRemover::REMOVE_SERVICE_WORKERS) | 218 BrowsingDataRemover::REMOVE_SERVICE_WORKERS) |
219 GetAsMask(data_to_remove, "cacheStorage", 219 GetAsMask(data_to_remove, "cacheStorage",
220 BrowsingDataRemover::REMOVE_CACHE_STORAGE) | 220 BrowsingDataRemover::REMOVE_CACHE_STORAGE) |
221 GetAsMask(data_to_remove, "webSQL", 221 GetAsMask(data_to_remove, "webSQL",
222 BrowsingDataRemover::REMOVE_WEBSQL) | 222 BrowsingDataRemover::REMOVE_WEBSQL) |
223 GetAsMask(data_to_remove, "serverBoundCertificates", 223 GetAsMask(data_to_remove, "serverBoundCertificates",
224 BrowsingDataRemover::REMOVE_CHANNEL_IDS); 224 BrowsingDataRemover::REMOVE_CHANNEL_IDS) |
225 GetAsMask(data_to_remove, "externalProtocolData",
226 BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA);
227
225 EXPECT_EQ(expected_removal_mask, removal_mask); 228 EXPECT_EQ(expected_removal_mask, removal_mask);
226 } 229 }
227 230
228 // The kAllowDeletingBrowserHistory pref must be set to false before this 231 // The kAllowDeletingBrowserHistory pref must be set to false before this
229 // is called. 232 // is called.
230 void CheckRemovalPermitted(const std::string& data_types, bool permitted) { 233 void CheckRemovalPermitted(const std::string& data_types, bool permitted) {
231 scoped_refptr<BrowsingDataRemoveFunction> function = 234 scoped_refptr<BrowsingDataRemoveFunction> function =
232 new BrowsingDataRemoveFunction(); 235 new BrowsingDataRemoveFunction();
233 std::string args = "[{\"since\": 1}," + data_types + "]"; 236 std::string args = "[{\"since\": 1}," + data_types + "]";
234 237
(...skipping 26 matching lines...) Expand all
261 CheckRemovalPermitted("{\"fileSystems\": true}", true); 264 CheckRemovalPermitted("{\"fileSystems\": true}", true);
262 CheckRemovalPermitted("{\"formData\": true}", true); 265 CheckRemovalPermitted("{\"formData\": true}", true);
263 CheckRemovalPermitted("{\"history\": true}", false); 266 CheckRemovalPermitted("{\"history\": true}", false);
264 CheckRemovalPermitted("{\"indexedDB\": true}", true); 267 CheckRemovalPermitted("{\"indexedDB\": true}", true);
265 CheckRemovalPermitted("{\"localStorage\": true}", true); 268 CheckRemovalPermitted("{\"localStorage\": true}", true);
266 CheckRemovalPermitted("{\"serverBoundCertificates\": true}", true); 269 CheckRemovalPermitted("{\"serverBoundCertificates\": true}", true);
267 CheckRemovalPermitted("{\"passwords\": true}", true); 270 CheckRemovalPermitted("{\"passwords\": true}", true);
268 CheckRemovalPermitted("{\"serviceWorkers\": true}", true); 271 CheckRemovalPermitted("{\"serviceWorkers\": true}", true);
269 CheckRemovalPermitted("{\"cacheStorage\": true}", true); 272 CheckRemovalPermitted("{\"cacheStorage\": true}", true);
270 CheckRemovalPermitted("{\"webSQL\": true}", true); 273 CheckRemovalPermitted("{\"webSQL\": true}", true);
274 CheckRemovalPermitted("{\"externalProtocolData\": true}", true);
271 275
272 // The entire removal is prohibited if any part is. 276 // The entire removal is prohibited if any part is.
273 CheckRemovalPermitted("{\"cache\": true, \"history\": true}", false); 277 CheckRemovalPermitted("{\"cache\": true, \"history\": true}", false);
274 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": true}", false); 278 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": true}", false);
275 279
276 // If a prohibited type is not selected, the removal is OK. 280 // If a prohibited type is not selected, the removal is OK.
277 CheckRemovalPermitted("{\"history\": false}", true); 281 CheckRemovalPermitted("{\"history\": false}", true);
278 CheckRemovalPermitted("{\"downloads\": false}", true); 282 CheckRemovalPermitted("{\"downloads\": false}", true);
279 CheckRemovalPermitted("{\"cache\": true, \"history\": false}", true); 283 CheckRemovalPermitted("{\"cache\": true, \"history\": false}", true);
280 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": false}", true); 284 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": false}", true);
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 BrowsingDataRemover::REMOVE_CHANNEL_IDS); 360 BrowsingDataRemover::REMOVE_CHANNEL_IDS);
357 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( 361 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
358 "passwords", BrowsingDataRemover::REMOVE_PASSWORDS); 362 "passwords", BrowsingDataRemover::REMOVE_PASSWORDS);
359 // We can't remove plugin data inside a test profile. 363 // We can't remove plugin data inside a test profile.
360 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( 364 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
361 "serviceWorkers", BrowsingDataRemover::REMOVE_SERVICE_WORKERS); 365 "serviceWorkers", BrowsingDataRemover::REMOVE_SERVICE_WORKERS);
362 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( 366 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
363 "cacheStorage", BrowsingDataRemover::REMOVE_CACHE_STORAGE); 367 "cacheStorage", BrowsingDataRemover::REMOVE_CACHE_STORAGE);
364 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask( 368 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
365 "webSQL", BrowsingDataRemover::REMOVE_WEBSQL); 369 "webSQL", BrowsingDataRemover::REMOVE_WEBSQL);
370 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
371 "externalProtocolData",
372 BrowsingDataRemover::REMOVE_EXTERNAL_PROTOCOL_DATA);
366 } 373 }
367 374
368 // Test an arbitrary combination of data types. 375 // Test an arbitrary combination of data types.
369 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, 376 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest,
370 BrowsingDataRemovalMaskCombination) { 377 BrowsingDataRemovalMaskCombination) {
371 RunBrowsingDataRemoveFunctionAndCompareRemovalMask( 378 RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
372 "{\"appcache\": true, \"cookies\": true, \"history\": true}", 379 "{\"appcache\": true, \"cookies\": true, \"history\": true}",
373 BrowsingDataRemover::REMOVE_APPCACHE | 380 BrowsingDataRemover::REMOVE_APPCACHE |
374 BrowsingDataRemover::REMOVE_COOKIES | 381 BrowsingDataRemover::REMOVE_COOKIES |
375 BrowsingDataRemover::REMOVE_HISTORY); 382 BrowsingDataRemover::REMOVE_HISTORY);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 521
515 SetPrefsAndVerifySettings( 522 SetPrefsAndVerifySettings(
516 BrowsingDataRemover::REMOVE_COOKIES | 523 BrowsingDataRemover::REMOVE_COOKIES |
517 BrowsingDataRemover::REMOVE_HISTORY | 524 BrowsingDataRemover::REMOVE_HISTORY |
518 BrowsingDataRemover::REMOVE_DOWNLOADS, 525 BrowsingDataRemover::REMOVE_DOWNLOADS,
519 UNPROTECTED_WEB, 526 UNPROTECTED_WEB,
520 site_data_no_plugins_durable_usage | 527 site_data_no_plugins_durable_usage |
521 BrowsingDataRemover::REMOVE_HISTORY | 528 BrowsingDataRemover::REMOVE_HISTORY |
522 BrowsingDataRemover::REMOVE_DOWNLOADS); 529 BrowsingDataRemover::REMOVE_DOWNLOADS);
523 } 530 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698