Bug 953156 - Stop unregistering add-on chrome manifests at app shutdown; r=Unfocused
☠☠ backed out by 2f8927b0f01c ☠ ☠
authorGeoff Lankow <geoff@darktrojan.net>
Fri, 27 Dec 2013 11:39:28 +1300
changeset 162346 f3f667c17c26d92a477a5c70cda430bf697adbf2
parent 162345 5734ebc705fdeab0f0590f48e2ba8218b6949c75
child 162347 34b3cb13258b5a4af8e9304f9e0fb629f574dfa1
push idunknown
push userunknown
push dateunknown
reviewersUnfocused
bugs953156
milestone29.0a1
Bug 953156 - Stop unregistering add-on chrome manifests at app shutdown; r=Unfocused
toolkit/mozapps/extensions/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_bug953156.js
toolkit/mozapps/extensions/test/xpcshell/test_langpack.js
toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
--- a/toolkit/mozapps/extensions/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/XPIProvider.jsm
@@ -4286,17 +4286,17 @@ var XPIProvider = {
       try {
         this.bootstrapScopes[aId][aMethod](params, aReason);
       }
       catch (e) {
         WARN("Exception running bootstrap method " + aMethod + " on " + aId, e);
       }
     }
     finally {
-      if (aMethod == "shutdown") {
+      if (aMethod == "shutdown" && aReason != BOOTSTRAP_REASONS.APP_SHUTDOWN) {
         LOG("Removing manifest for " + aFile.path);
         Components.manager.removeBootstrappedManifestLocation(aFile);
       }
       this.setTelemetry(aId, aMethod + "_MS", new Date() - timeStart);
     }
   },
 
   /**
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_bug953156.js
@@ -0,0 +1,51 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+function run_test() {
+  do_test_pending();
+  createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2");
+  startupManager();
+
+  prepare_test({ }, [
+    "onNewInstall"
+  ]);
+
+  AddonManager.getInstallForFile(do_get_addon("test_bug675371"), function(install) {
+    ensure_test_completed();
+
+    do_check_neq(install, null);
+
+    prepare_test({
+      "bug675371@tests.mozilla.org": [
+        ["onInstalling", false],
+        "onInstalled"
+      ]
+    }, [
+      "onInstallStarted",
+      "onInstallEnded"
+    ], callback_soon(check_test));
+    install.install();
+  });
+}
+
+function check_test() {
+  AddonManager.getAddonByID("bug675371@tests.mozilla.org", do_exception_wrap(function(addon) {
+    do_check_neq(addon, null);
+    do_check_true(addon.isActive);
+
+    // Tests that chrome.manifest is registered when the addon is installed.
+    var target = { active: false };
+    Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
+    do_check_true(target.active);
+
+    shutdownManager();
+
+    // Tests that chrome.manifest remains registered at app shutdown.
+    target.active = false;
+    Services.scriptloader.loadSubScript("chrome://bug675371/content/test.js", target);
+    do_check_true(target.active);
+
+    do_execute_soon(do_test_finished);
+  }));
+}
--- a/toolkit/mozapps/extensions/test/xpcshell/test_langpack.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_langpack.js
@@ -22,16 +22,22 @@ registerDirectory("XREUSysExt", userExtD
 const distroDir = gProfD.clone();
 distroDir.append("distribution");
 distroDir.append("extensions");
 registerDirectory("XREAppDist", distroDir.parent);
 
 var chrome = Components.classes["@mozilla.org/chrome/chrome-registry;1"]
   .getService(Components.interfaces.nsIXULChromeRegistry);
 
+function do_unregister_manifest() {
+  let path = profileDir.clone();
+  path.append("langpack-x-testing@tests.mozilla.org.xpi");
+  Components.manager.removeBootstrappedManifestLocation(path);
+}
+
 function do_check_locale_not_registered(provider) {
   let didThrow = false;
   try {
     chrome.getSelectedLocale(provider);
   } catch (e) {
     didThrow = true;
   }
   do_check_true(didThrow);
@@ -198,16 +204,17 @@ function run_test_4() {
       do_execute_soon(run_test_5);
     });
   });
 }
 
 // Tests that a restart shuts down and restarts the add-on
 function run_test_5() {
   shutdownManager();
+  do_unregister_manifest();
   // check chrome reg that language pack is not registered
   do_check_locale_not_registered("test-langpack");
   startupManager(false);
   // check chrome reg that language pack is registered
   do_check_eq(chrome.getSelectedLocale("test-langpack"), "x-testing");
 
   AddonManager.getAddonByID("langpack-x-testing@tests.mozilla.org", function(b1) {
     do_check_neq(b1, null);
@@ -274,16 +281,17 @@ function run_test_8() {
     do_check_false(b1.userDisabled);
     do_check_true(b1.isActive);
     // check chrome reg that language pack is registered
     do_check_eq(chrome.getSelectedLocale("test-langpack"), "x-testing");
     do_check_true(b1.hasResource("install.rdf"));
     do_check_false(b1.hasResource("bootstrap.js"));
 
     shutdownManager();
+    do_unregister_manifest();
     // check chrome reg that language pack is not registered
     do_check_locale_not_registered("test-langpack");
     startupManager(false);
     // check chrome reg that language pack is registered
     do_check_eq(chrome.getSelectedLocale("test-langpack"), "x-testing");
 
     AddonManager.getAddonByID("langpack-x-testing@tests.mozilla.org", function(b2) {
       prepare_test({
@@ -315,16 +323,17 @@ function run_test_9() {
     do_check_false(b1.userDisabled);
     do_check_true(b1.isActive);
     // check chrome reg that language pack is registered
     do_check_eq(chrome.getSelectedLocale("test-langpack"), "x-testing");
     do_check_true(b1.hasResource("install.rdf"));
     do_check_false(b1.hasResource("bootstrap.js"));
 
     shutdownManager();
+    do_unregister_manifest();
     // check chrome reg that language pack is not registered
     do_check_locale_not_registered("test-langpack");
     startupManager(false);
     // check chrome reg that language pack is registered
     do_check_eq(chrome.getSelectedLocale("test-langpack"), "x-testing");
 
     do_test_finished();
   }));
--- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
+++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell-shared.ini
@@ -135,16 +135,17 @@ fail-if = os == "android"
 [test_bug619730.js]
 [test_bug620837.js]
 [test_bug655254.js]
 [test_bug659772.js]
 [test_bug675371.js]
 [test_bug740612.js]
 [test_bug753900.js]
 [test_bug757663.js]
+[test_bug953156.js]
 [test_cacheflush.js]
 [test_checkcompatibility.js]
 [test_childprocess.js]
 [test_ChromeManifestParser.js]
 [test_compatoverrides.js]
 [test_corrupt.js]
 [test_corrupt_strictcompat.js]
 [test_corruptfile.js]