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
--- 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: {