Bug 1298923 - Prevent installation of an extension when "*" is used as part of strict_min_version in a WebExtension manifest.json, r?kmag draft
authorBob Silverberg <bsilverberg@mozilla.com>
Thu, 01 Sep 2016 14:46:38 -0400
changeset 412712 8275c5bcb421665dd4835fdec7555e96609ec65d
parent 411657 938ce16be25f9c551c19ef8938e8717ed3d41ff5
child 531061 1e073bd52e5622338a9fee3771a1ddbcc6485569
push id29250
push userbmo:bob.silverberg@gmail.com
push dateMon, 12 Sep 2016 18:56:10 +0000
reviewerskmag
bugs1298923
milestone51.0a1
Bug 1298923 - Prevent installation of an extension when "*" is used as part of strict_min_version in a WebExtension manifest.json, r?kmag MozReview-Commit-ID: BeHU7ZPB1NG
toolkit/mozapps/extensions/internal/XPIProvider.jsm
toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
--- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm
+++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm
@@ -926,17 +926,17 @@ var loadManifestFromWebManifest = Task.a
   let bss = (manifest.browser_specific_settings && manifest.browser_specific_settings.gecko)
       || (manifest.applications && manifest.applications.gecko) || {};
   if (manifest.browser_specific_settings && manifest.applications) {
     logger.warn("Ignoring applications property in manifest");
   }
 
   // A * is illegal in strict_min_version
   if (bss.strict_min_version && bss.strict_min_version.split(".").some(part => part == "*")) {
-    logger.warn("The use of '*' in strict_min_version is deprecated");
+    throw new Error("The use of '*' in strict_min_version is invalid");
   }
 
   let addon = new AddonInternal();
   addon.id = bss.id;
   addon.version = manifest.version;
   addon.type = "webextension";
   addon.unpack = false;
   addon.strictCompatibility = true;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -409,44 +409,40 @@ add_task(function* test_strict_min_max()
   addon = yield promiseAddonByID(newId);
 
   notEqual(addon, null, "Add-on is installed");
   equal(addon.id, newId, "Installed add-on has the expected ID");
 
   addon.uninstall();
   flushAndRemove(addonDir);
 
-  // * in min will generate a warning
+  // * in min will throw an error
   for (let version of ["0.*", "0.*.0"]) {
     newId = "strict_min_star@tests.mozilla.org";
     let apps = {
       applications: {
         gecko: {
           id: newId,
           strict_min_version: version,
         },
       },
     }
+
     let testManifest = Object.assign(apps, MANIFEST);
 
     let addonDir = yield promiseWriteWebManifestForExtension(testManifest, gTmpD,
-                                            "strict_min_star");
+                                                             "strict_min_star");
 
-    let { messages } = yield promiseConsoleOutput(function* () {
-      yield AddonManager.installTemporaryAddon(addonDir);
-    });
-    ok(messages.some(msg => msg.message.includes("The use of '*' in strict_min_version is deprecated")),
-       "Deprecation warning for strict_min_version with '*' was generated");
+    yield Assert.rejects(
+      AddonManager.installTemporaryAddon(addonDir),
+      /The use of '\*' in strict_min_version is invalid/,
+      "loading an extension with a * in strict_min_version throws an exception");
 
     let addon = yield promiseAddonByID(newId);
-
-    notEqual(addon, null, "Add-on is installed");
-    equal(addon.id, newId, "Add-on has the expected id");
-
-    addon.uninstall();
+    equal(addon, null, "Add-on is not installed");
     flushAndRemove(addonDir);
   }
 
   // incompatible extension but with compatibility checking off
   newId = "checkCompatibility@tests.mozilla.org";
   apps = {
     applications: {
       gecko: {