From 87d0ea2fcb652a40381c605c89c8d49aade4ab6f Mon Sep 17 00:00:00 2001 From: Bob Silverberg Date: Mon, 29 Aug 2016 15:10:38 -0400 Subject: [PATCH] Bug 1297752 - Issue a warning when "*" is used as part of strict_min_version in a WebExtension manifest.json. r=kmag MozReview-Commit-ID: 9BKjBe2Gigo --HG-- extra : rebase_source : 1aabd1d437b5ed4ea1a829eacc98c6f1aa008b90 --- .../extensions/internal/XPIProvider.jsm | 5 +++ .../xpcshell/test_webextension_install.js | 31 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/toolkit/mozapps/extensions/internal/XPIProvider.jsm b/toolkit/mozapps/extensions/internal/XPIProvider.jsm index a8837b62adb0..6976f4391c68 100644 --- a/toolkit/mozapps/extensions/internal/XPIProvider.jsm +++ b/toolkit/mozapps/extensions/internal/XPIProvider.jsm @@ -929,6 +929,11 @@ var loadManifestFromWebManifest = Task.async(function*(aUri) { 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; diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js index 040e844bdcef..c3bcbba145a0 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_webextension_install.js @@ -363,4 +363,35 @@ add_task(function* test_strict_min_max() { addon.uninstall(); flushAndRemove(addonDir); + + // * in min will generate a warning + 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"); + + 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(newId); + + notEqual(addon, null, "Add-on is installed"); + equal(addon.id, newId, "Add-on has the expected id"); + + addon.uninstall(); + flushAndRemove(addonDir); + } });