Bug 774990: Copying a profile with a disabled restartless add-on to a different directory causes extensions to fail to load. r=Unfocused, a=akeybl
authorDave Townsend <dtownsend@oxymoronical.com>
Mon, 30 Jul 2012 14:20:31 -0700
changeset 100390 d11eb233d8ec98ed4af14e915e9871b46df5afff
parent 100389 bd453c843c2187071385b2e1826c5f4a32a44231
child 100391 6932a40200a32345a232e5144cb8f25dac5f3d84
push id1197
push userdtownsend@mozilla.com
push dateMon, 30 Jul 2012 21:25:17 +0000
treeherdermozilla-beta@d11eb233d8ec [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersUnfocused, akeybl
bugs774990
milestone15.0
Bug 774990: Copying a profile with a disabled restartless add-on to a different directory causes extensions to fail to load. r=Unfocused, a=akeybl
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/head_addons.js
toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -2402,17 +2402,17 @@ var XPIProvider = {
       aOldAddon._descriptor = aAddonState.descriptor;
       aOldAddon.visible = !(aOldAddon.id in visibleAddons);
 
       // Update the database
       XPIDatabase.setAddonDescriptor(aOldAddon, aAddonState.descriptor);
       if (aOldAddon.visible) {
         visibleAddons[aOldAddon.id] = aOldAddon;
 
-        if (aOldAddon.bootstrap) {
+        if (aOldAddon.bootstrap && aOldAddon.active) {
           let bootstrap = oldBootstrappedAddons[aOldAddon.id];
           bootstrap.descriptor = aAddonState.descriptor;
           XPIProvider.bootstrappedAddons[aOldAddon.id] = bootstrap;
         }
 
         return true;
       }
 
--- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js
@@ -448,16 +448,18 @@ function loadAddonsList() {
 
 function isItemInAddonsList(aType, aDir, aId) {
   var path = aDir.clone();
   path.append(aId);
   var xpiPath = aDir.clone();
   xpiPath.append(aId + ".xpi");
   for (var i = 0; i < gAddonsList[aType].length; i++) {
     let file = gAddonsList[aType][i];
+    if (!file.exists())
+      do_throw("Non-existant path found in extensions.ini: " + file.path)
     if (file.isDirectory() && file.equals(path))
       return true;
     if (file.isFile() && file.equals(xpiPath))
       return true;
   }
   return false;
 }
 
--- a/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug655254.js
@@ -49,16 +49,24 @@ var addon1 = {
 function run_test() {
   do_test_pending();
 
   // Create and configure the HTTP server.
   testserver = new nsHttpServer();
   testserver.registerDirectory("/data/", do_get_file("data"));
   testserver.start(4444);
 
+  run_test_1();
+}
+
+function end_test() {
+  testserver.stop(do_test_finished);
+}
+
+function run_test_1() {
   var time = Date.now();
   var dir = writeInstallRDFForExtension(addon1, userDir);
   setExtensionModifiedTime(dir, time);
 
   manuallyInstall(do_get_addon("test_bug655254_2"), userDir, "addon2@tests.mozilla.org");
 
   startupManager();
 
@@ -105,15 +113,55 @@ function run_test() {
             do_check_true(isExtensionInAddonsList(userDir, a1.id));
 
             do_check_neq(a2, null);
             do_check_false(a2.appDisabled);
             do_check_true(a2.isActive);
             do_check_false(isExtensionInAddonsList(userDir, a2.id));
             do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
 
-            testserver.stop(do_test_finished);
+            run_test_2();
           });
         });
       }
     }, AddonManager.UPDATE_WHEN_USER_REQUESTED);
   });
 }
+
+//Set up the profile
+function run_test_2() {
+  AddonManager.getAddonByID("addon2@tests.mozilla.org", function(a2) {
+   do_check_neq(a2, null);
+   do_check_false(a2.appDisabled);
+   do_check_true(a2.isActive);
+   do_check_false(isExtensionInAddonsList(userDir, a2.id));
+   do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 1);
+
+   a2.userDisabled = true;
+   do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
+
+   shutdownManager();
+
+   userDir.parent.moveTo(gProfD, "extensions4");
+   userDir = gProfD.clone();
+   userDir.append("extensions4");
+   userDir.append(gAppInfo.ID);
+   do_check_true(userDir.exists());
+
+   startupManager(false);
+
+   AddonManager.getAddonsByIDs(["addon1@tests.mozilla.org",
+                                "addon2@tests.mozilla.org"], function([a1, a2]) {
+     do_check_neq(a1, null);
+     do_check_false(a1.appDisabled);
+     do_check_true(a1.isActive);
+     do_check_true(isExtensionInAddonsList(userDir, a1.id));
+
+     do_check_neq(a2, null);
+     do_check_true(a2.userDisabled);
+     do_check_false(a2.isActive);
+     do_check_false(isExtensionInAddonsList(userDir, a2.id));
+     do_check_eq(Services.prefs.getIntPref("bootstraptest.active_version"), 0);
+
+     end_test();
+   });
+  });
+}