Bug 1297752 - Issue a warning when "*" is used as part of strict_min_version in a WebExtension manifest.json, r=kmag a=lizzard
authorBob Silverberg <bsilverberg@mozilla.com>
Fri, 02 Sep 2016 14:39:00 -0400
changeset 348048 4b4cc630c39914a480dc04ef773ee17ed01baf42
parent 348047 3a0fd1bb116a3b79b6f33462a04144818b550ee9
child 348049 0bfa87408e2ead5b1a6d745cf0d02ccdb7b1d68a
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag, lizzard
bugs1297752
milestone50.0a2
Bug 1297752 - Issue a warning when "*" is used as part of strict_min_version in a WebExtension manifest.json, r=kmag a=lizzard Uplift to beta
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
@@ -907,16 +907,21 @@ var loadManifestFromWebManifest = Task.a
     throw new Error("Extension is invalid");
 
   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");
+  }
+
   let addon = new AddonInternal();
   addon.id = bss.id;
   addon.version = manifest.version;
   addon.type = "webextension";
   addon.unpack = false;
   addon.strictCompatibility = true;
   addon.bootstrap = true;
   addon.hasBinaryComponents = false;
--- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
+++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js
@@ -194,8 +194,53 @@ add_task(function* test_two_ids() {
 
   let addon = yield promiseAddonByID(BAD_ID);
   do_check_eq(addon, null);
   addon = yield promiseAddonByID(GOOD_ID);
   do_check_neq(addon, null);
 
   addon.uninstall();
 });
+
+add_task(function* strict_min_star() {
+  const addonId = "strict_min_max@tests.mozilla.org";
+  const MANIFEST = {
+    name: "strict min star test",
+    description: "test strict min with star",
+    manifest_version: 2,
+    version: "1.0",
+  };
+
+  function flushAndRemove(file) {
+    // flush JAR cache and remove the file
+    Services.obs.notifyObservers(file, "flush-cache-entry", null);
+    file.remove(true);
+  }
+
+  // * in min will generate a warning
+  for (let version of ["0.*", "0.*.0"]) {
+    let apps = {
+      applications: {
+        gecko: {
+          id: addonId,
+          strict_min_version: version,
+        },
+      },
+    }
+    let testManifest = Object.assign(apps, MANIFEST);
+
+    let addonDir = writeWebManifestForExtension(testManifest, gTmpD,
+                                                "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");
+
+    let addon = yield promiseAddonByID(addonId);
+
+    notEqual(addon, null, "Add-on is installed");
+    equal(addon.id, addonId, "Add-on has the expected id");
+
+    addon.uninstall();
+    flushAndRemove(addonDir);
+  }
+});