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
3 // found in the LICENSE file.
7 #include "base/json/json_string_value_serializer.h"
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h"
10 #include "base/prefs/pref_service.h"
11 #include "base/strings/pattern.h"
12 #include "base/strings/string_util.h"
13 #include "base/strings/stringprintf.h"
14 #include "base/values.h"
15 #include "chrome/browser/browsing_data/browsing_data_helper.h"
16 #include "chrome/browser/browsing_data/browsing_data_remover.h"
17 #include "chrome/browser/extensions/api/browsing_data/browsing_data_api.h"
18 #include "chrome/browser/extensions/extension_function_test_utils.h"
19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/ui/browser.h"
21 #include "chrome/common/pref_names.h"
22 #include "chrome/test/base/in_process_browser_test.h"
24 using extension_function_test_utils::RunFunctionAndReturnError
;
25 using extension_function_test_utils::RunFunctionAndReturnSingleResult
;
30 UNPROTECTED_WEB
= BrowsingDataHelper::UNPROTECTED_WEB
,
31 PROTECTED_WEB
= BrowsingDataHelper::PROTECTED_WEB
,
32 EXTENSION
= BrowsingDataHelper::EXTENSION
35 const char kRemoveEverythingArguments
[] = "[{\"since\": 1000}, {"
36 "\"appcache\": true, \"cache\": true, \"cookies\": true, "
37 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
38 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
39 "\"serverBoundCertificates\": true, \"passwords\": true, "
40 "\"pluginData\": true, \"serviceWorkers\": true, \"webSQL\": true"
44 class ExtensionBrowsingDataTest
: public InProcessBrowserTest
{
46 base::Time
GetBeginTime() {
47 return called_with_details_
->removal_begin
;
50 int GetRemovalMask() {
51 return called_with_details_
->removal_mask
;
54 int GetOriginTypeMask() {
55 return called_with_details_
->origin_type_mask
;
59 void SetUpOnMainThread() override
{
60 called_with_details_
.reset(new BrowsingDataRemover::NotificationDetails());
61 callback_subscription_
=
62 BrowsingDataRemover::RegisterOnBrowsingDataRemovedCallback(
63 base::Bind(&ExtensionBrowsingDataTest::NotifyWithDetails
,
64 base::Unretained(this)));
67 // Callback for browsing data removal events.
68 void NotifyWithDetails(
69 const BrowsingDataRemover::NotificationDetails
& details
) {
70 // We're not taking ownership of the details object, but storing a copy of
72 called_with_details_
.reset(
73 new BrowsingDataRemover::NotificationDetails(details
));
76 int GetAsMask(const base::DictionaryValue
* dict
, std::string path
,
79 EXPECT_TRUE(dict
->GetBoolean(path
, &result
)) << "for " << path
;
80 return result
? mask_value
: 0;
83 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
84 const std::string
& data_types
,
86 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
87 new BrowsingDataRemoveFunction();
88 SCOPED_TRACE(data_types
);
89 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
91 std::string("[{\"since\": 1},") + data_types
+ "]",
93 EXPECT_EQ(expected_mask
, GetRemovalMask());
94 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginTypeMask());
97 void RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
98 const std::string
& key
,
100 RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
101 std::string("{\"") + key
+ "\": true}", expected_mask
);
104 void RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
105 const std::string
& protectedStr
,
107 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
108 new BrowsingDataRemoveFunction();
109 SCOPED_TRACE(protectedStr
);
110 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
112 "[{\"originTypes\": " + protectedStr
+ "}, {\"cookies\": true}]",
114 EXPECT_EQ(expected_mask
, GetOriginTypeMask());
117 template<class ShortcutFunction
>
118 void RunAndCompareRemovalMask(int expected_mask
) {
119 scoped_refptr
<ShortcutFunction
> function
=
120 new ShortcutFunction();
121 SCOPED_TRACE(ShortcutFunction::function_name());
122 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
124 std::string("[{\"since\": 1}]"),
126 EXPECT_EQ(expected_mask
, GetRemovalMask());
127 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginTypeMask());
130 void SetSinceAndVerify(BrowsingDataRemover::TimePeriod since_pref
) {
131 PrefService
* prefs
= browser()->profile()->GetPrefs();
132 prefs
->SetInteger(prefs::kDeleteTimePeriod
, since_pref
);
134 scoped_refptr
<BrowsingDataSettingsFunction
> function
=
135 new BrowsingDataSettingsFunction();
136 SCOPED_TRACE("settings");
137 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
138 function
.get(), std::string("[]"), browser()));
140 base::DictionaryValue
* result
;
141 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
142 base::DictionaryValue
* options
;
143 EXPECT_TRUE(result
->GetDictionary("options", &options
));
145 EXPECT_TRUE(options
->GetDouble("since", &since
));
147 double expected_since
= 0;
148 if (since_pref
!= BrowsingDataRemover::EVERYTHING
) {
150 BrowsingDataRemover::CalculateBeginDeleteTime(since_pref
);
151 expected_since
= time
.ToJsTime();
153 // Even a synchronous function takes nonzero time, but the difference
154 // between when the function was called and now should be well under a
155 // second, so we'll make sure the requested start time is within 10 seconds.
156 // Since the smallest selectable period is an hour, that should be
158 EXPECT_LE(expected_since
, since
+ 10.0 * 1000.0);
161 void SetPrefsAndVerifySettings(int data_type_flags
,
162 int expected_origin_type_mask
,
163 int expected_removal_mask
) {
164 PrefService
* prefs
= browser()->profile()->GetPrefs();
165 prefs
->SetBoolean(prefs::kDeleteCache
,
166 !!(data_type_flags
& BrowsingDataRemover::REMOVE_CACHE
));
167 prefs
->SetBoolean(prefs::kDeleteCookies
,
168 !!(data_type_flags
& BrowsingDataRemover::REMOVE_COOKIES
));
169 prefs
->SetBoolean(prefs::kDeleteBrowsingHistory
,
170 !!(data_type_flags
& BrowsingDataRemover::REMOVE_HISTORY
));
171 prefs
->SetBoolean(prefs::kDeleteFormData
,
172 !!(data_type_flags
& BrowsingDataRemover::REMOVE_FORM_DATA
));
173 prefs
->SetBoolean(prefs::kDeleteDownloadHistory
,
174 !!(data_type_flags
& BrowsingDataRemover::REMOVE_DOWNLOADS
));
175 prefs
->SetBoolean(prefs::kDeleteHostedAppsData
,
177 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
));
178 prefs
->SetBoolean(prefs::kDeletePasswords
,
179 !!(data_type_flags
& BrowsingDataRemover::REMOVE_PASSWORDS
));
180 prefs
->SetBoolean(prefs::kClearPluginLSODataEnabled
,
181 !!(data_type_flags
& BrowsingDataRemover::REMOVE_PLUGIN_DATA
));
183 scoped_refptr
<BrowsingDataSettingsFunction
> function
=
184 new BrowsingDataSettingsFunction();
185 SCOPED_TRACE("settings");
186 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
187 function
.get(), std::string("[]"), browser()));
189 base::DictionaryValue
* result
;
190 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
192 base::DictionaryValue
* options
;
193 EXPECT_TRUE(result
->GetDictionary("options", &options
));
194 base::DictionaryValue
* origin_types
;
195 EXPECT_TRUE(options
->GetDictionary("originTypes", &origin_types
));
196 int origin_type_mask
= GetAsMask(origin_types
, "unprotectedWeb",
198 GetAsMask(origin_types
, "protectedWeb",
200 GetAsMask(origin_types
, "extension", EXTENSION
);
201 EXPECT_EQ(expected_origin_type_mask
, origin_type_mask
);
203 base::DictionaryValue
* data_to_remove
;
204 EXPECT_TRUE(result
->GetDictionary("dataToRemove", &data_to_remove
));
205 int removal_mask
= GetAsMask(data_to_remove
, "appcache",
206 BrowsingDataRemover::REMOVE_APPCACHE
) |
207 GetAsMask(data_to_remove
, "cache",
208 BrowsingDataRemover::REMOVE_CACHE
) |
209 GetAsMask(data_to_remove
, "cookies",
210 BrowsingDataRemover::REMOVE_COOKIES
|
211 BrowsingDataRemover::REMOVE_WEBRTC_IDENTITY
) |
212 GetAsMask(data_to_remove
, "downloads",
213 BrowsingDataRemover::REMOVE_DOWNLOADS
) |
214 GetAsMask(data_to_remove
, "fileSystems",
215 BrowsingDataRemover::REMOVE_FILE_SYSTEMS
) |
216 GetAsMask(data_to_remove
, "formData",
217 BrowsingDataRemover::REMOVE_FORM_DATA
) |
218 GetAsMask(data_to_remove
, "history",
219 BrowsingDataRemover::REMOVE_HISTORY
) |
220 GetAsMask(data_to_remove
, "indexedDB",
221 BrowsingDataRemover::REMOVE_INDEXEDDB
) |
222 GetAsMask(data_to_remove
, "localStorage",
223 BrowsingDataRemover::REMOVE_LOCAL_STORAGE
) |
224 GetAsMask(data_to_remove
, "pluginData",
225 BrowsingDataRemover::REMOVE_PLUGIN_DATA
) |
226 GetAsMask(data_to_remove
, "passwords",
227 BrowsingDataRemover::REMOVE_PASSWORDS
) |
228 GetAsMask(data_to_remove
, "serviceWorkers",
229 BrowsingDataRemover::REMOVE_SERVICE_WORKERS
) |
230 GetAsMask(data_to_remove
, "webSQL",
231 BrowsingDataRemover::REMOVE_WEBSQL
) |
232 GetAsMask(data_to_remove
, "serverBoundCertificates",
233 BrowsingDataRemover::REMOVE_CHANNEL_IDS
);
234 EXPECT_EQ(expected_removal_mask
, removal_mask
);
237 // The kAllowDeletingBrowserHistory pref must be set to false before this
239 void CheckRemovalPermitted(const std::string
& data_types
, bool permitted
) {
240 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
241 new BrowsingDataRemoveFunction();
242 std::string args
= "[{\"since\": 1}," + data_types
+ "]";
245 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
246 function
.get(), args
, browser())) << " for " << args
;
248 EXPECT_TRUE(base::MatchPattern(
249 RunFunctionAndReturnError(function
.get(), args
, browser()),
250 extension_browsing_data_api_constants::kDeleteProhibitedError
))
256 scoped_ptr
<BrowsingDataRemover::NotificationDetails
> called_with_details_
;
258 BrowsingDataRemover::CallbackSubscription callback_subscription_
;
264 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, OneAtATime
) {
265 BrowsingDataRemover::set_removing(true);
266 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
267 new BrowsingDataRemoveFunction();
268 EXPECT_TRUE(base::MatchPattern(
269 RunFunctionAndReturnError(function
.get(), kRemoveEverythingArguments
,
271 extension_browsing_data_api_constants::kOneAtATimeError
));
272 BrowsingDataRemover::set_removing(false);
274 EXPECT_EQ(base::Time(), GetBeginTime());
275 EXPECT_EQ(-1, GetRemovalMask());
278 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, RemovalProhibited
) {
279 PrefService
* prefs
= browser()->profile()->GetPrefs();
280 prefs
->SetBoolean(prefs::kAllowDeletingBrowserHistory
, false);
282 CheckRemovalPermitted("{\"appcache\": true}", true);
283 CheckRemovalPermitted("{\"cache\": true}", true);
284 CheckRemovalPermitted("{\"cookies\": true}", true);
285 CheckRemovalPermitted("{\"downloads\": true}", false);
286 CheckRemovalPermitted("{\"fileSystems\": true}", true);
287 CheckRemovalPermitted("{\"formData\": true}", true);
288 CheckRemovalPermitted("{\"history\": true}", false);
289 CheckRemovalPermitted("{\"indexedDB\": true}", true);
290 CheckRemovalPermitted("{\"localStorage\": true}", true);
291 CheckRemovalPermitted("{\"serverBoundCertificates\": true}", true);
292 CheckRemovalPermitted("{\"passwords\": true}", true);
293 CheckRemovalPermitted("{\"serviceWorkers\": true}", true);
294 CheckRemovalPermitted("{\"webSQL\": true}", true);
296 // The entire removal is prohibited if any part is.
297 CheckRemovalPermitted("{\"cache\": true, \"history\": true}", false);
298 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": true}", false);
300 // If a prohibited type is not selected, the removal is OK.
301 CheckRemovalPermitted("{\"history\": false}", true);
302 CheckRemovalPermitted("{\"downloads\": false}", true);
303 CheckRemovalPermitted("{\"cache\": true, \"history\": false}", true);
304 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": false}", true);
307 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, RemoveBrowsingDataAll
) {
308 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
309 new BrowsingDataRemoveFunction();
310 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(function
.get(),
311 kRemoveEverythingArguments
,
314 EXPECT_EQ(base::Time::FromDoubleT(1.0), GetBeginTime());
315 EXPECT_EQ((BrowsingDataRemover::REMOVE_SITE_DATA
|
316 BrowsingDataRemover::REMOVE_CACHE
|
317 BrowsingDataRemover::REMOVE_DOWNLOADS
|
318 BrowsingDataRemover::REMOVE_FORM_DATA
|
319 BrowsingDataRemover::REMOVE_HISTORY
|
320 BrowsingDataRemover::REMOVE_PASSWORDS
) &
321 // TODO(benwells): implement clearing of site usage data via the browsing
322 // data API. https://crbug.com/500801.
323 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA
&
324 // We can't remove plugin data inside a test profile.
325 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
, GetRemovalMask());
328 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, BrowsingDataOriginTypeMask
) {
329 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask("{}", 0);
331 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
332 "{\"unprotectedWeb\": true}", UNPROTECTED_WEB
);
333 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
334 "{\"protectedWeb\": true}", PROTECTED_WEB
);
335 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
336 "{\"extension\": true}", EXTENSION
);
338 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
339 "{\"unprotectedWeb\": true, \"protectedWeb\": true}",
340 UNPROTECTED_WEB
| PROTECTED_WEB
);
341 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
342 "{\"unprotectedWeb\": true, \"extension\": true}",
343 UNPROTECTED_WEB
| EXTENSION
);
344 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
345 "{\"protectedWeb\": true, \"extension\": true}",
346 PROTECTED_WEB
| EXTENSION
);
348 RunBrowsingDataRemoveFunctionAndCompareOriginTypeMask(
349 ("{\"unprotectedWeb\": true, \"protectedWeb\": true, "
350 "\"extension\": true}"),
351 UNPROTECTED_WEB
| PROTECTED_WEB
| EXTENSION
);
354 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
355 BrowsingDataRemovalMask
) {
356 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
357 "appcache", BrowsingDataRemover::REMOVE_APPCACHE
);
358 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
359 "cache", BrowsingDataRemover::REMOVE_CACHE
);
360 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
361 "cookies", BrowsingDataRemover::REMOVE_COOKIES
|
362 BrowsingDataRemover::REMOVE_WEBRTC_IDENTITY
);
363 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
364 "downloads", BrowsingDataRemover::REMOVE_DOWNLOADS
);
365 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
366 "fileSystems", BrowsingDataRemover::REMOVE_FILE_SYSTEMS
);
367 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
368 "formData", BrowsingDataRemover::REMOVE_FORM_DATA
);
369 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
370 "history", BrowsingDataRemover::REMOVE_HISTORY
);
371 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
372 "indexedDB", BrowsingDataRemover::REMOVE_INDEXEDDB
);
373 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
374 "localStorage", BrowsingDataRemover::REMOVE_LOCAL_STORAGE
);
375 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
376 "serverBoundCertificates",
377 BrowsingDataRemover::REMOVE_CHANNEL_IDS
);
378 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
379 "passwords", BrowsingDataRemover::REMOVE_PASSWORDS
);
380 // We can't remove plugin data inside a test profile.
381 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
382 "serviceWorkers", BrowsingDataRemover::REMOVE_SERVICE_WORKERS
);
383 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
384 "webSQL", BrowsingDataRemover::REMOVE_WEBSQL
);
387 // Test an arbitrary combination of data types.
388 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
389 BrowsingDataRemovalMaskCombination
) {
390 RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
391 "{\"appcache\": true, \"cookies\": true, \"history\": true}",
392 BrowsingDataRemover::REMOVE_APPCACHE
|
393 BrowsingDataRemover::REMOVE_COOKIES
|
394 BrowsingDataRemover::REMOVE_WEBRTC_IDENTITY
|
395 BrowsingDataRemover::REMOVE_HISTORY
);
398 // Make sure the remove() function accepts the format produced by settings().
399 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
400 BrowsingDataRemovalInputFromSettings
) {
401 PrefService
* prefs
= browser()->profile()->GetPrefs();
402 prefs
->SetBoolean(prefs::kDeleteCache
, true);
403 prefs
->SetBoolean(prefs::kDeleteBrowsingHistory
, true);
404 prefs
->SetBoolean(prefs::kDeleteDownloadHistory
, true);
405 prefs
->SetBoolean(prefs::kDeleteCookies
, false);
406 prefs
->SetBoolean(prefs::kDeleteFormData
, false);
407 prefs
->SetBoolean(prefs::kDeleteHostedAppsData
, false);
408 prefs
->SetBoolean(prefs::kDeletePasswords
, false);
409 prefs
->SetBoolean(prefs::kClearPluginLSODataEnabled
, false);
410 int expected_mask
= BrowsingDataRemover::REMOVE_CACHE
|
411 BrowsingDataRemover::REMOVE_DOWNLOADS
|
412 BrowsingDataRemover::REMOVE_HISTORY
;
414 // Scoping for the traces.
416 scoped_refptr
<BrowsingDataSettingsFunction
> settings_function
=
417 new BrowsingDataSettingsFunction();
418 SCOPED_TRACE("settings_json");
419 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
420 settings_function
.get(), std::string("[]"), browser()));
422 base::DictionaryValue
* result
;
423 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
424 base::DictionaryValue
* data_to_remove
;
425 EXPECT_TRUE(result
->GetDictionary("dataToRemove", &data_to_remove
));
427 JSONStringValueSerializer
serializer(&json
);
428 EXPECT_TRUE(serializer
.Serialize(*data_to_remove
));
431 scoped_refptr
<BrowsingDataRemoveFunction
> remove_function
=
432 new BrowsingDataRemoveFunction();
433 SCOPED_TRACE("remove_json");
434 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
435 remove_function
.get(),
436 std::string("[{\"since\": 1},") + json
+ "]",
438 EXPECT_EQ(expected_mask
, GetRemovalMask());
439 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginTypeMask());
443 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, ShortcutFunctionRemovalMask
) {
444 RunAndCompareRemovalMask
<BrowsingDataRemoveAppcacheFunction
>(
445 BrowsingDataRemover::REMOVE_APPCACHE
);
446 RunAndCompareRemovalMask
<BrowsingDataRemoveCacheFunction
>(
447 BrowsingDataRemover::REMOVE_CACHE
);
448 RunAndCompareRemovalMask
<BrowsingDataRemoveCookiesFunction
>(
449 BrowsingDataRemover::REMOVE_COOKIES
|
450 BrowsingDataRemover::REMOVE_CHANNEL_IDS
|
451 BrowsingDataRemover::REMOVE_WEBRTC_IDENTITY
);
452 RunAndCompareRemovalMask
<BrowsingDataRemoveDownloadsFunction
>(
453 BrowsingDataRemover::REMOVE_DOWNLOADS
);
454 RunAndCompareRemovalMask
<BrowsingDataRemoveFileSystemsFunction
>(
455 BrowsingDataRemover::REMOVE_FILE_SYSTEMS
);
456 RunAndCompareRemovalMask
<BrowsingDataRemoveFormDataFunction
>(
457 BrowsingDataRemover::REMOVE_FORM_DATA
);
458 RunAndCompareRemovalMask
<BrowsingDataRemoveHistoryFunction
>(
459 BrowsingDataRemover::REMOVE_HISTORY
);
460 RunAndCompareRemovalMask
<BrowsingDataRemoveIndexedDBFunction
>(
461 BrowsingDataRemover::REMOVE_INDEXEDDB
);
462 RunAndCompareRemovalMask
<BrowsingDataRemoveLocalStorageFunction
>(
463 BrowsingDataRemover::REMOVE_LOCAL_STORAGE
);
464 // We can't remove plugin data inside a test profile.
465 RunAndCompareRemovalMask
<BrowsingDataRemovePasswordsFunction
>(
466 BrowsingDataRemover::REMOVE_PASSWORDS
);
467 RunAndCompareRemovalMask
<BrowsingDataRemoveServiceWorkersFunction
>(
468 BrowsingDataRemover::REMOVE_SERVICE_WORKERS
);
469 RunAndCompareRemovalMask
<BrowsingDataRemoveWebSQLFunction
>(
470 BrowsingDataRemover::REMOVE_WEBSQL
);
473 // Test the processing of the 'delete since' preference.
474 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSince
) {
475 SetSinceAndVerify(BrowsingDataRemover::EVERYTHING
);
476 SetSinceAndVerify(BrowsingDataRemover::LAST_HOUR
);
477 SetSinceAndVerify(BrowsingDataRemover::LAST_DAY
);
478 SetSinceAndVerify(BrowsingDataRemover::LAST_WEEK
);
479 SetSinceAndVerify(BrowsingDataRemover::FOUR_WEEKS
);
482 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionEmpty
) {
483 SetPrefsAndVerifySettings(0, 0, 0);
486 // Test straightforward settings, mapped 1:1 to data types.
487 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSimple
) {
488 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_CACHE
, 0,
489 BrowsingDataRemover::REMOVE_CACHE
);
490 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_HISTORY
, 0,
491 BrowsingDataRemover::REMOVE_HISTORY
);
492 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_FORM_DATA
, 0,
493 BrowsingDataRemover::REMOVE_FORM_DATA
);
494 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_DOWNLOADS
, 0,
495 BrowsingDataRemover::REMOVE_DOWNLOADS
);
496 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_PASSWORDS
, 0,
497 BrowsingDataRemover::REMOVE_PASSWORDS
);
500 // Test cookie and app data settings.
501 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSiteData
) {
502 int site_data_no_usage
= BrowsingDataRemover::REMOVE_SITE_DATA
&
503 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA
;
504 int site_data_no_plugins
= site_data_no_usage
&
505 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
;
507 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES
,
509 site_data_no_plugins
);
510 SetPrefsAndVerifySettings(
511 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
,
513 site_data_no_plugins
);
514 SetPrefsAndVerifySettings(
515 BrowsingDataRemover::REMOVE_COOKIES
|
516 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
,
517 PROTECTED_WEB
| UNPROTECTED_WEB
,
518 site_data_no_plugins
);
519 SetPrefsAndVerifySettings(
520 BrowsingDataRemover::REMOVE_COOKIES
|
521 BrowsingDataRemover::REMOVE_PLUGIN_DATA
,
526 // Test an arbitrary assortment of settings.
527 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionAssorted
) {
528 int site_data_no_plugins
= BrowsingDataRemover::REMOVE_SITE_DATA
&
529 ~BrowsingDataRemover::REMOVE_SITE_USAGE_DATA
&
530 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
;
532 SetPrefsAndVerifySettings(
533 BrowsingDataRemover::REMOVE_COOKIES
|
534 BrowsingDataRemover::REMOVE_HISTORY
|
535 BrowsingDataRemover::REMOVE_DOWNLOADS
,
537 site_data_no_plugins
|
538 BrowsingDataRemover::REMOVE_HISTORY
|
539 BrowsingDataRemover::REMOVE_DOWNLOADS
);