diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 02:09:42 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-01 02:09:42 +0000 |
commit | 654512b4c7e02401af2ce207d678c683841eedb6 (patch) | |
tree | d856c557204c2ebbc94a5f4c7d8106b1ab5ffc41 /chrome/browser/extensions/extensions_service_unittest.cc | |
parent | 07598d6736b8d612b1f68eaf2066ab15776293da (diff) | |
download | chromium_src-654512b4c7e02401af2ce207d678c683841eedb6.zip chromium_src-654512b4c7e02401af2ce207d678c683841eedb6.tar.gz chromium_src-654512b4c7e02401af2ce207d678c683841eedb6.tar.bz2 |
Protect local storage created by extension apps.
BUG=49228
TEST=ExtensionsServiceTest.InstallAppsAndCheckStorageProtection
TEST=DatabaseTrackerTest.*
Review URL: http://codereview.chromium.org/3256003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58108 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/extensions_service_unittest.cc')
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 819a6a2..bd92b0c 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -1267,6 +1267,49 @@ TEST_F(ExtensionsServiceTest, InstallAppsWithUnlimtedStorage) { EXPECT_TRUE(service_->unlimited_storage_map_.empty()); } +TEST_F(ExtensionsServiceTest, InstallAppsAndCheckStorageProtection) { + InitializeEmptyExtensionsService(); + EXPECT_TRUE(service_->extensions()->empty()); + EXPECT_TRUE(service_->protected_storage_map_.empty()); + + FilePath extensions_path; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extensions_path)); + extensions_path = extensions_path.AppendASCII("extensions"); + int pref_count = 0; + + PackAndInstallExtension(extensions_path.AppendASCII("app1"), true); + ValidatePrefKeyCount(++pref_count); + ASSERT_EQ(1u, service_->extensions()->size()); + Extension* extension = service_->extensions()->at(0); + EXPECT_TRUE(extension->is_app()); + const std::string id1 = extension->id(); + EXPECT_FALSE(service_->protected_storage_map_.empty()); + const GURL origin1(extension->GetFullLaunchURL().GetOrigin()); + ASSERT_EQ(1, service_->protected_storage_map_[origin1]); + + // App 4 has a different origin (maps.google.com). + PackAndInstallExtension(extensions_path.AppendASCII("app4"), true); + ValidatePrefKeyCount(++pref_count); + ASSERT_EQ(2u, service_->extensions()->size()); + extension = service_->extensions()->at(1); + const std::string id2 = extension->id(); + EXPECT_FALSE(service_->protected_storage_map_.empty()); + const GURL origin2(extension->GetFullLaunchURL().GetOrigin()); + ASSERT_NE(origin1, origin2); + ASSERT_EQ(1, service_->protected_storage_map_[origin2]); + + service_->UninstallExtension(id1, false); + loop_.RunAllPending(); + EXPECT_EQ(1u, service_->extensions()->size()); + EXPECT_FALSE(service_->protected_storage_map_.empty()); + + service_->UninstallExtension(id2, false); + loop_.RunAllPending(); + + EXPECT_TRUE(service_->extensions()->empty()); + EXPECT_TRUE(service_->protected_storage_map_.empty()); +} + // Test that when an extension version is reinstalled, nothing happens. TEST_F(ExtensionsServiceTest, Reinstall) { InitializeEmptyExtensionsService(); |