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/string_util.h"
12 #include "base/strings/stringprintf.h"
13 #include "base/values.h"
14 #include "chrome/browser/browsing_data/browsing_data_helper.h"
15 #include "chrome/browser/browsing_data/browsing_data_remover.h"
16 #include "chrome/browser/chrome_notification_types.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"
23 #include "content/public/browser/notification_service.h"
25 using extension_function_test_utils::RunFunctionAndReturnError
;
26 using extension_function_test_utils::RunFunctionAndReturnSingleResult
;
31 UNPROTECTED_WEB
= BrowsingDataHelper::UNPROTECTED_WEB
,
32 PROTECTED_WEB
= BrowsingDataHelper::PROTECTED_WEB
,
33 EXTENSION
= BrowsingDataHelper::EXTENSION
36 const char kRemoveEverythingArguments
[] = "[{\"since\": 1000}, {"
37 "\"appcache\": true, \"cache\": true, \"cookies\": true, "
38 "\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
39 "\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
40 "\"serverBoundCertificates\": true, \"passwords\": true, "
41 "\"pluginData\": true, \"webSQL\": true"
45 class ExtensionBrowsingDataTest
: public InProcessBrowserTest
,
46 public content::NotificationObserver
{
48 base::Time
GetBeginTime() {
49 return called_with_details_
->removal_begin
;
52 int GetRemovalMask() {
53 return called_with_details_
->removal_mask
;
56 int GetOriginSetMask() {
57 return called_with_details_
->origin_set_mask
;
61 virtual void SetUpOnMainThread() OVERRIDE
{
62 called_with_details_
.reset(new BrowsingDataRemover::NotificationDetails());
63 registrar_
.Add(this, chrome::NOTIFICATION_BROWSING_DATA_REMOVED
,
64 content::Source
<Profile
>(browser()->profile()));
67 // content::NotificationObserver implementation.
68 virtual void Observe(int type
,
69 const content::NotificationSource
& source
,
70 const content::NotificationDetails
& details
) OVERRIDE
{
71 DCHECK_EQ(type
, chrome::NOTIFICATION_BROWSING_DATA_REMOVED
);
73 // We're not taking ownership of the details object, but storing a copy of
75 called_with_details_
.reset(new BrowsingDataRemover::NotificationDetails(
76 *content::Details
<BrowsingDataRemover::NotificationDetails
>(
80 int GetAsMask(const base::DictionaryValue
* dict
, std::string path
,
83 EXPECT_TRUE(dict
->GetBoolean(path
, &result
)) << "for " << path
;
84 return result
? mask_value
: 0;
87 void RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
88 const std::string
& data_types
,
90 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
91 new BrowsingDataRemoveFunction();
92 SCOPED_TRACE(data_types
);
93 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
95 std::string("[{\"since\": 1},") + data_types
+ "]",
97 EXPECT_EQ(expected_mask
, GetRemovalMask());
98 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginSetMask());
101 void RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
102 const std::string
& key
,
104 RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
105 std::string("{\"") + key
+ "\": true}", expected_mask
);
108 void RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
109 const std::string
& protectedStr
,
111 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
112 new BrowsingDataRemoveFunction();
113 SCOPED_TRACE(protectedStr
);
114 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
116 "[{\"originTypes\": " + protectedStr
+ "}, {\"cookies\": true}]",
118 EXPECT_EQ(expected_mask
, GetOriginSetMask());
121 template<class ShortcutFunction
>
122 void RunAndCompareRemovalMask(int expected_mask
) {
123 scoped_refptr
<ShortcutFunction
> function
=
124 new ShortcutFunction();
125 SCOPED_TRACE(ShortcutFunction::function_name());
126 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
128 std::string("[{\"since\": 1}]"),
130 EXPECT_EQ(expected_mask
, GetRemovalMask());
131 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginSetMask());
134 void SetSinceAndVerify(BrowsingDataRemover::TimePeriod since_pref
) {
135 PrefService
* prefs
= browser()->profile()->GetPrefs();
136 prefs
->SetInteger(prefs::kDeleteTimePeriod
, since_pref
);
138 scoped_refptr
<BrowsingDataSettingsFunction
> function
=
139 new BrowsingDataSettingsFunction();
140 SCOPED_TRACE("settings");
141 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
142 function
.get(), std::string("[]"), browser()));
144 base::DictionaryValue
* result
;
145 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
146 base::DictionaryValue
* options
;
147 EXPECT_TRUE(result
->GetDictionary("options", &options
));
149 EXPECT_TRUE(options
->GetDouble("since", &since
));
151 double expected_since
= 0;
152 if (since_pref
!= BrowsingDataRemover::EVERYTHING
) {
154 BrowsingDataRemover::CalculateBeginDeleteTime(since_pref
);
155 expected_since
= time
.ToJsTime();
157 // Even a synchronous function takes nonzero time, but the difference
158 // between when the function was called and now should be well under a
159 // second, so we'll make sure the requested start time is within 10 seconds.
160 // Since the smallest selectable period is an hour, that should be
162 EXPECT_LE(expected_since
, since
+ 10.0 * 1000.0);
165 void SetPrefsAndVerifySettings(int data_type_flags
,
166 int expected_origin_set_mask
,
167 int expected_removal_mask
) {
168 PrefService
* prefs
= browser()->profile()->GetPrefs();
169 prefs
->SetBoolean(prefs::kDeleteCache
,
170 !!(data_type_flags
& BrowsingDataRemover::REMOVE_CACHE
));
171 prefs
->SetBoolean(prefs::kDeleteCookies
,
172 !!(data_type_flags
& BrowsingDataRemover::REMOVE_COOKIES
));
173 prefs
->SetBoolean(prefs::kDeleteBrowsingHistory
,
174 !!(data_type_flags
& BrowsingDataRemover::REMOVE_HISTORY
));
175 prefs
->SetBoolean(prefs::kDeleteFormData
,
176 !!(data_type_flags
& BrowsingDataRemover::REMOVE_FORM_DATA
));
177 prefs
->SetBoolean(prefs::kDeleteDownloadHistory
,
178 !!(data_type_flags
& BrowsingDataRemover::REMOVE_DOWNLOADS
));
179 prefs
->SetBoolean(prefs::kDeleteHostedAppsData
,
181 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
));
182 prefs
->SetBoolean(prefs::kDeletePasswords
,
183 !!(data_type_flags
& BrowsingDataRemover::REMOVE_PASSWORDS
));
184 prefs
->SetBoolean(prefs::kClearPluginLSODataEnabled
,
185 !!(data_type_flags
& BrowsingDataRemover::REMOVE_PLUGIN_DATA
));
187 scoped_refptr
<BrowsingDataSettingsFunction
> function
=
188 new BrowsingDataSettingsFunction();
189 SCOPED_TRACE("settings");
190 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
191 function
.get(), std::string("[]"), browser()));
193 base::DictionaryValue
* result
;
194 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
196 base::DictionaryValue
* options
;
197 EXPECT_TRUE(result
->GetDictionary("options", &options
));
198 base::DictionaryValue
* origin_types
;
199 EXPECT_TRUE(options
->GetDictionary("originTypes", &origin_types
));
200 int origin_set_mask
= GetAsMask(origin_types
, "unprotectedWeb",
202 GetAsMask(origin_types
, "protectedWeb",
204 GetAsMask(origin_types
, "extension", EXTENSION
);
205 EXPECT_EQ(expected_origin_set_mask
, origin_set_mask
);
207 base::DictionaryValue
* data_to_remove
;
208 EXPECT_TRUE(result
->GetDictionary("dataToRemove", &data_to_remove
));
209 int removal_mask
= GetAsMask(data_to_remove
, "appcache",
210 BrowsingDataRemover::REMOVE_APPCACHE
) |
211 GetAsMask(data_to_remove
, "cache",
212 BrowsingDataRemover::REMOVE_CACHE
) |
213 GetAsMask(data_to_remove
, "cookies",
214 BrowsingDataRemover::REMOVE_COOKIES
) |
215 GetAsMask(data_to_remove
, "downloads",
216 BrowsingDataRemover::REMOVE_DOWNLOADS
) |
217 GetAsMask(data_to_remove
, "fileSystems",
218 BrowsingDataRemover::REMOVE_FILE_SYSTEMS
) |
219 GetAsMask(data_to_remove
, "formData",
220 BrowsingDataRemover::REMOVE_FORM_DATA
) |
221 GetAsMask(data_to_remove
, "history",
222 BrowsingDataRemover::REMOVE_HISTORY
) |
223 GetAsMask(data_to_remove
, "indexedDB",
224 BrowsingDataRemover::REMOVE_INDEXEDDB
) |
225 GetAsMask(data_to_remove
, "localStorage",
226 BrowsingDataRemover::REMOVE_LOCAL_STORAGE
) |
227 GetAsMask(data_to_remove
, "pluginData",
228 BrowsingDataRemover::REMOVE_PLUGIN_DATA
) |
229 GetAsMask(data_to_remove
, "passwords",
230 BrowsingDataRemover::REMOVE_PASSWORDS
) |
231 GetAsMask(data_to_remove
, "webSQL",
232 BrowsingDataRemover::REMOVE_WEBSQL
) |
233 GetAsMask(data_to_remove
, "serverBoundCertificates",
234 BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS
);
235 EXPECT_EQ(expected_removal_mask
, removal_mask
);
238 // The kAllowDeletingBrowserHistory pref must be set to false before this
240 void CheckRemovalPermitted(const std::string
& data_types
, bool permitted
) {
241 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
242 new BrowsingDataRemoveFunction();
243 std::string args
= "[{\"since\": 1}," + data_types
+ "]";
246 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
247 function
.get(), args
, browser())) << " for " << args
;
249 EXPECT_TRUE(MatchPattern(
250 RunFunctionAndReturnError(function
.get(), args
, browser()),
251 extension_browsing_data_api_constants::kDeleteProhibitedError
))
257 scoped_ptr
<BrowsingDataRemover::NotificationDetails
> called_with_details_
;
258 content::NotificationRegistrar registrar_
;
263 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, OneAtATime
) {
264 BrowsingDataRemover::set_removing(true);
265 scoped_refptr
<BrowsingDataRemoveFunction
> function
=
266 new BrowsingDataRemoveFunction();
268 MatchPattern(RunFunctionAndReturnError(
269 function
.get(), kRemoveEverythingArguments
, browser()),
270 extension_browsing_data_api_constants::kOneAtATimeError
));
271 BrowsingDataRemover::set_removing(false);
273 EXPECT_EQ(base::Time(), GetBeginTime());
274 EXPECT_EQ(-1, GetRemovalMask());
277 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, RemovalProhibited
) {
278 PrefService
* prefs
= browser()->profile()->GetPrefs();
279 prefs
->SetBoolean(prefs::kAllowDeletingBrowserHistory
, false);
281 CheckRemovalPermitted("{\"appcache\": true}", true);
282 CheckRemovalPermitted("{\"cache\": true}", true);
283 CheckRemovalPermitted("{\"cookies\": true}", true);
284 CheckRemovalPermitted("{\"downloads\": true}", false);
285 CheckRemovalPermitted("{\"fileSystems\": true}", true);
286 CheckRemovalPermitted("{\"formData\": true}", true);
287 CheckRemovalPermitted("{\"history\": true}", false);
288 CheckRemovalPermitted("{\"indexedDB\": true}", true);
289 CheckRemovalPermitted("{\"localStorage\": true}", true);
290 CheckRemovalPermitted("{\"serverBoundCertificates\": true}", true);
291 CheckRemovalPermitted("{\"passwords\": true}", true);
292 CheckRemovalPermitted("{\"webSQL\": true}", true);
294 // The entire removal is prohibited if any part is.
295 CheckRemovalPermitted("{\"cache\": true, \"history\": true}", false);
296 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": true}", false);
298 // If a prohibited type is not selected, the removal is OK.
299 CheckRemovalPermitted("{\"history\": false}", true);
300 CheckRemovalPermitted("{\"downloads\": false}", true);
301 CheckRemovalPermitted("{\"cache\": true, \"history\": false}", true);
302 CheckRemovalPermitted("{\"cookies\": true, \"downloads\": false}", true);
305 // Use-after-free, see http://crbug.com/116522
306 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
307 DISABLED_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 // We can't remove plugin data inside a test profile.
322 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
, GetRemovalMask());
325 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, BrowsingDataOriginSetMask
) {
326 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask("{}", 0);
328 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
329 "{\"unprotectedWeb\": true}", UNPROTECTED_WEB
);
330 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
331 "{\"protectedWeb\": true}", PROTECTED_WEB
);
332 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
333 "{\"extension\": true}", EXTENSION
);
335 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
336 "{\"unprotectedWeb\": true, \"protectedWeb\": true}",
337 UNPROTECTED_WEB
| PROTECTED_WEB
);
338 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
339 "{\"unprotectedWeb\": true, \"extension\": true}",
340 UNPROTECTED_WEB
| EXTENSION
);
341 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
342 "{\"protectedWeb\": true, \"extension\": true}",
343 PROTECTED_WEB
| EXTENSION
);
345 RunBrowsingDataRemoveFunctionAndCompareOriginSetMask(
346 ("{\"unprotectedWeb\": true, \"protectedWeb\": true, "
347 "\"extension\": true}"),
348 UNPROTECTED_WEB
| PROTECTED_WEB
| EXTENSION
);
351 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
352 FLAKY_BrowsingDataRemovalMask
) {
353 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
354 "appcache", BrowsingDataRemover::REMOVE_APPCACHE
);
355 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
356 "cache", BrowsingDataRemover::REMOVE_CACHE
);
357 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
358 "cookies", BrowsingDataRemover::REMOVE_COOKIES
);
359 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
360 "downloads", BrowsingDataRemover::REMOVE_DOWNLOADS
);
361 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
362 "fileSystems", BrowsingDataRemover::REMOVE_FILE_SYSTEMS
);
363 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
364 "formData", BrowsingDataRemover::REMOVE_FORM_DATA
);
365 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
366 "history", BrowsingDataRemover::REMOVE_HISTORY
);
367 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
368 "indexedDB", BrowsingDataRemover::REMOVE_INDEXEDDB
);
369 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
370 "localStorage", BrowsingDataRemover::REMOVE_LOCAL_STORAGE
);
371 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
372 "serverBoundCertificates",
373 BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS
);
374 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
375 "passwords", BrowsingDataRemover::REMOVE_PASSWORDS
);
376 // We can't remove plugin data inside a test profile.
377 RunBrowsingDataRemoveWithKeyAndCompareRemovalMask(
378 "webSQL", BrowsingDataRemover::REMOVE_WEBSQL
);
381 // Test an arbitrary combination of data types.
382 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
383 BrowsingDataRemovalMaskCombination
) {
384 RunBrowsingDataRemoveFunctionAndCompareRemovalMask(
385 "{\"appcache\": true, \"cookies\": true, \"history\": true}",
386 BrowsingDataRemover::REMOVE_APPCACHE
|
387 BrowsingDataRemover::REMOVE_COOKIES
|
388 BrowsingDataRemover::REMOVE_HISTORY
);
391 // Make sure the remove() function accepts the format produced by settings().
392 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
,
393 BrowsingDataRemovalInputFromSettings
) {
394 PrefService
* prefs
= browser()->profile()->GetPrefs();
395 prefs
->SetBoolean(prefs::kDeleteCache
, true);
396 prefs
->SetBoolean(prefs::kDeleteBrowsingHistory
, true);
397 prefs
->SetBoolean(prefs::kDeleteDownloadHistory
, true);
398 prefs
->SetBoolean(prefs::kDeleteCookies
, false);
399 prefs
->SetBoolean(prefs::kDeleteFormData
, false);
400 prefs
->SetBoolean(prefs::kDeleteHostedAppsData
, false);
401 prefs
->SetBoolean(prefs::kDeletePasswords
, false);
402 prefs
->SetBoolean(prefs::kClearPluginLSODataEnabled
, false);
403 int expected_mask
= BrowsingDataRemover::REMOVE_CACHE
|
404 BrowsingDataRemover::REMOVE_DOWNLOADS
|
405 BrowsingDataRemover::REMOVE_HISTORY
;
407 // Scoping for the traces.
409 scoped_refptr
<BrowsingDataSettingsFunction
> settings_function
=
410 new BrowsingDataSettingsFunction();
411 SCOPED_TRACE("settings_json");
412 scoped_ptr
<base::Value
> result_value(RunFunctionAndReturnSingleResult(
413 settings_function
.get(), std::string("[]"), browser()));
415 base::DictionaryValue
* result
;
416 EXPECT_TRUE(result_value
->GetAsDictionary(&result
));
417 base::DictionaryValue
* data_to_remove
;
418 EXPECT_TRUE(result
->GetDictionary("dataToRemove", &data_to_remove
));
420 JSONStringValueSerializer
serializer(&json
);
421 EXPECT_TRUE(serializer
.Serialize(*data_to_remove
));
424 scoped_refptr
<BrowsingDataRemoveFunction
> remove_function
=
425 new BrowsingDataRemoveFunction();
426 SCOPED_TRACE("remove_json");
427 EXPECT_EQ(NULL
, RunFunctionAndReturnSingleResult(
428 remove_function
.get(),
429 std::string("[{\"since\": 1},") + json
+ "]",
431 EXPECT_EQ(expected_mask
, GetRemovalMask());
432 EXPECT_EQ(UNPROTECTED_WEB
, GetOriginSetMask());
436 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, ShortcutFunctionRemovalMask
) {
437 RunAndCompareRemovalMask
<BrowsingDataRemoveAppcacheFunction
>(
438 BrowsingDataRemover::REMOVE_APPCACHE
);
439 RunAndCompareRemovalMask
<BrowsingDataRemoveCacheFunction
>(
440 BrowsingDataRemover::REMOVE_CACHE
);
441 RunAndCompareRemovalMask
<BrowsingDataRemoveCookiesFunction
>(
442 BrowsingDataRemover::REMOVE_COOKIES
|
443 BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS
);
444 RunAndCompareRemovalMask
<BrowsingDataRemoveDownloadsFunction
>(
445 BrowsingDataRemover::REMOVE_DOWNLOADS
);
446 RunAndCompareRemovalMask
<BrowsingDataRemoveFileSystemsFunction
>(
447 BrowsingDataRemover::REMOVE_FILE_SYSTEMS
);
448 RunAndCompareRemovalMask
<BrowsingDataRemoveFormDataFunction
>(
449 BrowsingDataRemover::REMOVE_FORM_DATA
);
450 RunAndCompareRemovalMask
<BrowsingDataRemoveHistoryFunction
>(
451 BrowsingDataRemover::REMOVE_HISTORY
);
452 RunAndCompareRemovalMask
<BrowsingDataRemoveIndexedDBFunction
>(
453 BrowsingDataRemover::REMOVE_INDEXEDDB
);
454 RunAndCompareRemovalMask
<BrowsingDataRemoveLocalStorageFunction
>(
455 BrowsingDataRemover::REMOVE_LOCAL_STORAGE
);
456 // We can't remove plugin data inside a test profile.
457 RunAndCompareRemovalMask
<BrowsingDataRemovePasswordsFunction
>(
458 BrowsingDataRemover::REMOVE_PASSWORDS
);
459 RunAndCompareRemovalMask
<BrowsingDataRemoveWebSQLFunction
>(
460 BrowsingDataRemover::REMOVE_WEBSQL
);
463 // Test the processing of the 'delete since' preference.
464 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSince
) {
465 SetSinceAndVerify(BrowsingDataRemover::EVERYTHING
);
466 SetSinceAndVerify(BrowsingDataRemover::LAST_HOUR
);
467 SetSinceAndVerify(BrowsingDataRemover::LAST_DAY
);
468 SetSinceAndVerify(BrowsingDataRemover::LAST_WEEK
);
469 SetSinceAndVerify(BrowsingDataRemover::FOUR_WEEKS
);
472 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionEmpty
) {
473 SetPrefsAndVerifySettings(0, 0, 0);
476 // Test straightforward settings, mapped 1:1 to data types.
477 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSimple
) {
478 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_CACHE
, 0,
479 BrowsingDataRemover::REMOVE_CACHE
);
480 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_HISTORY
, 0,
481 BrowsingDataRemover::REMOVE_HISTORY
);
482 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_FORM_DATA
, 0,
483 BrowsingDataRemover::REMOVE_FORM_DATA
);
484 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_DOWNLOADS
, 0,
485 BrowsingDataRemover::REMOVE_DOWNLOADS
);
486 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_PASSWORDS
, 0,
487 BrowsingDataRemover::REMOVE_PASSWORDS
);
490 // Test cookie and app data settings.
491 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionSiteData
) {
492 int site_data_no_plugins
= BrowsingDataRemover::REMOVE_SITE_DATA
&
493 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
;
495 SetPrefsAndVerifySettings(BrowsingDataRemover::REMOVE_COOKIES
,
497 site_data_no_plugins
);
498 SetPrefsAndVerifySettings(
499 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
,
501 site_data_no_plugins
);
502 SetPrefsAndVerifySettings(
503 BrowsingDataRemover::REMOVE_COOKIES
|
504 BrowsingDataRemover::REMOVE_HOSTED_APP_DATA_TESTONLY
,
505 PROTECTED_WEB
| UNPROTECTED_WEB
,
506 site_data_no_plugins
);
507 SetPrefsAndVerifySettings(
508 BrowsingDataRemover::REMOVE_COOKIES
|
509 BrowsingDataRemover::REMOVE_PLUGIN_DATA
,
511 BrowsingDataRemover::REMOVE_SITE_DATA
);
514 // Test an arbitrary assortment of settings.
515 IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest
, SettingsFunctionAssorted
) {
516 int site_data_no_plugins
= BrowsingDataRemover::REMOVE_SITE_DATA
&
517 ~BrowsingDataRemover::REMOVE_PLUGIN_DATA
;
519 SetPrefsAndVerifySettings(
520 BrowsingDataRemover::REMOVE_COOKIES
|
521 BrowsingDataRemover::REMOVE_HISTORY
|
522 BrowsingDataRemover::REMOVE_DOWNLOADS
,
524 site_data_no_plugins
|
525 BrowsingDataRemover::REMOVE_HISTORY
|
526 BrowsingDataRemover::REMOVE_DOWNLOADS
);