| Index: chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
|
| diff --git a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
|
| index 267d6628a6b48df95e803a3263e7bfe7116ebf88..f27404484d4017b8873b6d9d95e80eddd2b31ea2 100644
|
| --- a/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
|
| +++ b/chrome/browser/extensions/api/browsing_data/browsing_data_test.cc
|
| @@ -11,6 +11,7 @@
|
| #include "base/string_util.h"
|
| #include "base/stringprintf.h"
|
| #include "base/values.h"
|
| +#include "chrome/browser/browsing_data_helper.h"
|
| #include "chrome/browser/browsing_data_remover.h"
|
| #include "chrome/browser/extensions/extension_function_test_utils.h"
|
| #include "chrome/browser/profiles/profile.h"
|
| @@ -32,6 +33,18 @@ const char kRemoveEverythingArguments[] = "[{\"since\": 1000}, {"
|
| "\"webSQL\": true"
|
| "}]";
|
|
|
| +const char kRemoveEverythingProtectedArguments[] = "[{"
|
| + "\"since\": 1000,"
|
| + "\"origin_types\": [\"unprotected_web\", \"protected_web\"]"
|
| + "},{"
|
| + "\"appcache\": true, \"cache\": true, \"cookies\": true, "
|
| + "\"downloads\": true, \"fileSystems\": true, \"formData\": true, "
|
| + "\"history\": true, \"indexedDB\": true, \"localStorage\": true, "
|
| + "\"serverBoundCerts\": true, \"passwords\": true, \"pluginData\": true, "
|
| + "\"webSQL\": true"
|
| + "}]";
|
| +
|
| +
|
| class ExtensionBrowsingDataTest : public InProcessBrowserTest,
|
| public content::NotificationObserver {
|
| public:
|
| @@ -43,6 +56,10 @@ class ExtensionBrowsingDataTest : public InProcessBrowserTest,
|
| return called_with_details_->removal_mask;
|
| }
|
|
|
| + int GetOriginSetMask() {
|
| + return called_with_details_->origin_set_mask;
|
| + }
|
| +
|
| protected:
|
| virtual void SetUpOnMainThread() {
|
| called_with_details_.reset(new BrowsingDataRemover::NotificationDetails());
|
| @@ -67,14 +84,25 @@ class ExtensionBrowsingDataTest : public InProcessBrowserTest,
|
| details).ptr()));
|
| }
|
|
|
| - void RunRemoveBrowsingDataFunctionAndCompareMask(const std::string& key,
|
| - int expected_mask) {
|
| + void RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| + const std::string& key,
|
| + int expected_mask) {
|
| SCOPED_TRACE(key);
|
| EXPECT_EQ(NULL, RunFunctionAndReturnResult(new RemoveBrowsingDataFunction(),
|
| std::string("[{\"since\": 1}, {\"") + key + "\": true}]", browser()));
|
| EXPECT_EQ(expected_mask, GetRemovalMask());
|
| }
|
|
|
| + void RunRemoveBrowsingDataFunctionAndCompareOriginSetMask(
|
| + const std::string& protectedStr,
|
| + int expected_mask) {
|
| + SCOPED_TRACE(protectedStr);
|
| + EXPECT_EQ(NULL, RunFunctionAndReturnResult(new RemoveBrowsingDataFunction(),
|
| + "[{\"origin_types\": " + protectedStr + "}, {\"cookies\": true}]",
|
| + browser()));
|
| + EXPECT_EQ(expected_mask, GetOriginSetMask());
|
| + }
|
| +
|
| private:
|
| scoped_ptr<BrowsingDataRemover::NotificationDetails> called_with_details_;
|
| content::NotificationRegistrar registrar_;
|
| @@ -113,30 +141,43 @@ IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest,
|
| ~BrowsingDataRemover::REMOVE_PLUGIN_DATA, GetRemovalMask());
|
| }
|
|
|
| -IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, RemoveBrowsingDataMask) {
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| +IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, BrowsingDataOriginSetMask) {
|
| + RunRemoveBrowsingDataFunctionAndCompareOriginSetMask(
|
| + "[\"unprotected_web\"]", BrowsingDataHelper::UNPROTECTED_WEB);
|
| + RunRemoveBrowsingDataFunctionAndCompareOriginSetMask(
|
| + "[\"protected_web\"]", BrowsingDataHelper::PROTECTED_WEB);
|
| + RunRemoveBrowsingDataFunctionAndCompareOriginSetMask(
|
| + "[\"unprotected_web\", \"protected_web\"]",
|
| + BrowsingDataHelper::UNPROTECTED_WEB | BrowsingDataHelper::PROTECTED_WEB);
|
| + RunRemoveBrowsingDataFunctionAndCompareOriginSetMask(
|
| + "[\"protected_web\", \"unprotected_web\"]",
|
| + BrowsingDataHelper::UNPROTECTED_WEB | BrowsingDataHelper::PROTECTED_WEB);
|
| +}
|
| +
|
| +IN_PROC_BROWSER_TEST_F(ExtensionBrowsingDataTest, BrowsingDataRemovalMask) {
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "appcache", BrowsingDataRemover::REMOVE_APPCACHE);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "cache", BrowsingDataRemover::REMOVE_CACHE);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "cookies", BrowsingDataRemover::REMOVE_COOKIES);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "downloads", BrowsingDataRemover::REMOVE_DOWNLOADS);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "fileSystems", BrowsingDataRemover::REMOVE_FILE_SYSTEMS);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "formData", BrowsingDataRemover::REMOVE_FORM_DATA);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "history", BrowsingDataRemover::REMOVE_HISTORY);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "indexedDB", BrowsingDataRemover::REMOVE_INDEXEDDB);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "localStorage", BrowsingDataRemover::REMOVE_LOCAL_STORAGE);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "serverBoundCerts", BrowsingDataRemover::REMOVE_SERVER_BOUND_CERTS);
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "passwords", BrowsingDataRemover::REMOVE_PASSWORDS);
|
| // We can't remove plugin data inside a test profile.
|
| - RunRemoveBrowsingDataFunctionAndCompareMask(
|
| + RunRemoveBrowsingDataFunctionAndCompareRemovalMask(
|
| "webSQL", BrowsingDataRemover::REMOVE_WEBSQL);
|
| }
|
|
|