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

Unified Diff: chrome/browser/extensions/extension_service_unittest.cc

Issue 9320021: Fix crash in ExtensionService::InitializePermissions(). (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: add the test data Created 8 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service_unittest.cc
diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc
index b434fe71fbf8388f134b5aa4e4ffbd1b647de655..99a89cb1a2a4919ca8f2949fc441922c6a873f91 100644
--- a/chrome/browser/extensions/extension_service_unittest.cc
+++ b/chrome/browser/extensions/extension_service_unittest.cc
@@ -98,6 +98,7 @@ const char* const page_action = "obcimlgaoabeegjmmpldobjndiealpln";
const char* const theme_crx = "iamefpfkojoapidjnbafmgkgncegbkad";
const char* const theme2_crx = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf";
const char* const permissions_crx = "eagpmdpfmaekmmcejjbmjoecnejeiiin";
+const char* const unpacked = "cbcdidchbppangcjoddlpdjlenngjldk";
struct ExtensionsOrder {
bool operator()(const Extension* a, const Extension* b) {
@@ -1895,6 +1896,50 @@ TEST_F(ExtensionServiceTest, LoadLocalizedTheme) {
EXPECT_EQ("description", theme->description());
}
+// Tests that we can change the ID of an unpacked extension by adding a key
+// to its manifest.
+TEST_F(ExtensionServiceTest, UnpackedExtensionCanChangeID) {
+ InitializeEmptyExtensionService();
+
+ ScopedTempDir temp;
+ ASSERT_TRUE(temp.CreateUniqueTempDir());
+
+ FilePath extension_path = temp.path();
+ FilePath manifest_path = extension_path.Append(Extension::kManifestFilename);
+ FilePath manifest_no_key = data_dir_.
+ AppendASCII("unpacked").
+ AppendASCII("manifest_no_key.json");
+
+ FilePath manifest_with_key = data_dir_.
+ AppendASCII("unpacked").
+ AppendASCII("manifest_with_key.json");
+
+ ASSERT_TRUE(file_util::PathExists(manifest_no_key));
+ ASSERT_TRUE(file_util::PathExists(manifest_with_key));
+
+ // Load the unpacked extension with no key.
+ file_util::CopyFile(manifest_no_key, manifest_path);
+ extensions::UnpackedInstaller::Create(service_)->Load(extension_path);
+
+ loop_.RunAllPending();
+ EXPECT_EQ(0u, GetErrors().size());
+ ASSERT_EQ(1u, loaded_.size());
+ EXPECT_EQ(1u, service_->extensions()->size());
+
+ // Add the key to the manifest.
+ file_util::CopyFile(manifest_with_key, manifest_path);
+ loaded_.clear();
+
+ // Reload the extensions.
+ service_->ReloadExtensions();
+ const Extension* extension = service_->GetExtensionById(unpacked, false);
+ EXPECT_EQ(unpacked, extension->id());
+ ASSERT_EQ(1u, loaded_.size());
+
+ // TODO(jstritar): Right now this just makes sure we don't crash and burn, but
+ // we should also test that preferences are preserved.
+}
+
TEST_F(ExtensionServiceTest, InstallLocalizedTheme) {
InitializeEmptyExtensionService();
FilePath theme_path = data_dir_
« no previous file with comments | « no previous file | chrome/browser/extensions/installed_loader.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698