diff --git a/mobile/android/geckoview/api.txt b/mobile/android/geckoview/api.txt index 7533a5953d2b..b1302f3fc4b0 100644 --- a/mobile/android/geckoview/api.txt +++ b/mobile/android/geckoview/api.txt @@ -2145,7 +2145,6 @@ package org.mozilla.geckoview { field public static final int ERROR_POSTPONED = -101; field public static final int ERROR_SIGNEDSTATE_REQUIRED = -5; field public static final int ERROR_UNEXPECTED_ADDON_TYPE = -6; - field public static final int ERROR_UNEXPECTED_ADDON_VERSION = -9; field public static final int ERROR_USER_CANCELED = -100; } diff --git a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java index 2bb1aaa85bdf..672ea57c94c1 100644 --- a/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java +++ b/mobile/android/geckoview/src/main/java/org/mozilla/geckoview/WebExtension.java @@ -1525,8 +1525,6 @@ public class WebExtension { public static final int ERROR_SIGNEDSTATE_REQUIRED = -5; /** The downloaded extension had a different type than expected. */ public static final int ERROR_UNEXPECTED_ADDON_TYPE = -6; - /** The downloaded extension had a different version than expected */ - public static final int ERROR_UNEXPECTED_ADDON_VERSION = -9; /** The extension did not have the expected ID. */ public static final int ERROR_INCORRECT_ID = -7; /** The extension did not have the expected ID. */ @@ -1574,7 +1572,6 @@ public class WebExtension { ErrorCodes.ERROR_FILE_ACCESS, ErrorCodes.ERROR_SIGNEDSTATE_REQUIRED, ErrorCodes.ERROR_UNEXPECTED_ADDON_TYPE, - ErrorCodes.ERROR_UNEXPECTED_ADDON_VERSION, ErrorCodes.ERROR_INCORRECT_ID, ErrorCodes.ERROR_INVALID_DOMAIN, ErrorCodes.ERROR_USER_CANCELED, diff --git a/toolkit/mozapps/extensions/AddonManager.jsm b/toolkit/mozapps/extensions/AddonManager.jsm index f525710f9053..2bd5f3c6d4e0 100644 --- a/toolkit/mozapps/extensions/AddonManager.jsm +++ b/toolkit/mozapps/extensions/AddonManager.jsm @@ -3819,8 +3819,6 @@ var AddonManager = { ["ERROR_INCORRECT_ID", -7], // The addon install_origins does not list the 3rd party domain. ["ERROR_INVALID_DOMAIN", -8], - // Updates only: The downloaded add-on had a different version than expected. - ["ERROR_UNEXPECTED_ADDON_VERSION", -9], ]), // The update check timed out ERROR_TIMEOUT: -1, diff --git a/toolkit/mozapps/extensions/internal/XPIInstall.jsm b/toolkit/mozapps/extensions/internal/XPIInstall.jsm index 1f7a9b5b26be..b9b61bc3200e 100644 --- a/toolkit/mozapps/extensions/internal/XPIInstall.jsm +++ b/toolkit/mozapps/extensions/internal/XPIInstall.jsm @@ -1277,8 +1277,7 @@ class AddonInstall { * @param {object} [options.icons] * Optional icons for the add-on * @param {string} [options.version] - * The expected version for the add-on. - * Required for updates, i.e. when existingAddon is set. + * An optional version for the add-on * @param {Object?} [options.telemetryInfo] * An optional object which provides details about the installation source * included in the addon manager telemetry events. @@ -1614,13 +1613,6 @@ class AddonInstall { `Refusing to change addon type from ${this.existingAddon.type} to ${this.addon.type}`, ]); } - - if (this.version !== this.addon.version) { - return Promise.reject([ - AddonManager.ERROR_UNEXPECTED_ADDON_VERSION, - `Expected addon version ${this.version} instead of ${this.addon.version}` - ]); - } } if (XPIDatabase.mustSign(this.addon.type)) { @@ -2218,8 +2210,7 @@ var DownloadAddonInstall = class extends AddonInstall { * @param {Object} [options.icons] * Optional icons for the add-on * @param {string} [options.version] - * The expected version for the add-on. - * Required for updates, i.e. when existingAddon is set. + * An optional version for the add-on * @param {function(string) : Promise} [options.promptHandler] * A callback to prompt the user before installing. * @param {boolean} [options.sendCookies] diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateversion.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateversion.js deleted file mode 100644 index 63e71341f4e5..000000000000 --- a/toolkit/mozapps/extensions/test/xpcshell/test_updateversion.js +++ /dev/null @@ -1,101 +0,0 @@ -/* Any copyright is dedicated to the Public Domain. - * http://creativecommons.org/publicdomain/zero/1.0/ - */ - -// The test extension uses an insecure update url. -Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); - -let server = AddonTestUtils.createHttpServer({ hosts: ["example.com"] }); - -async function serverRegisterUpdate({ id, version, actualVersion }) { - let xpi = await createTempWebExtensionFile({ - manifest: { - version: actualVersion, - applications: { gecko: { id } }, - }, - }); - - server.registerFile("/addon.xpi", xpi); - AddonTestUtils.registerJSON(server, "/update.json", { - addons: { - [id]: { - updates: [{ version, update_link: "http://example.com/addon.xpi" }], - }, - }, - }); -} - -add_task(async function setup() { - await ExtensionTestUtils.startAddonManager(); -}); - -add_task(async function test_update_version_mismatch() { - const ID = "updateversion@tests.mozilla.org"; - await promiseInstallWebExtension({ - manifest: { - version: "1.0", - applications: { - gecko: { - id: ID, - update_url: "http://example.com/update.json", - }, - }, - }, - }); - - await serverRegisterUpdate({ - id: ID, - version: "2.00", - actualVersion: "2.000", - }); - - let addon = await promiseAddonByID(ID); - Assert.notEqual(addon, null); - Assert.equal(addon.version, "1.0"); - - let update = await promiseFindAddonUpdates( - addon, - AddonManager.UPDATE_WHEN_USER_REQUESTED - ); - let install = update.updateAvailable; - Assert.notEqual(install, false, "Found available update"); - Assert.equal(install.version, "2.00"); - Assert.equal(install.state, AddonManager.STATE_AVAILABLE); - Assert.equal(install.existingAddon, addon); - - await Assert.rejects( - install.install(), - err => install.error == AddonManager.ERROR_UNEXPECTED_ADDON_VERSION, - "Should refuse installation when downloaded version does not match" - ); - - await addon.uninstall(); -}); - -add_task(async function test_update_version_empty() { - const ID = "updateversionempty@tests.mozilla.org"; - await serverRegisterUpdate({ id: ID, version: "", actualVersion: "1.0" }); - - await promiseInstallWebExtension({ - manifest: { - version: "0", - applications: { - gecko: { - id: ID, - update_url: "http://example.com/update.json", - }, - }, - }, - }); - let addon = await promiseAddonByID(ID); - Assert.notEqual(addon, null); - Assert.equal(addon.version, "0"); - let update = await promiseFindAddonUpdates( - addon, - AddonManager.UPDATE_WHEN_USER_REQUESTED - ); - // The only item in the updates array has version "" (empty). This should not - // be offered as an available update because it is certainly not newer. - Assert.equal(update.updateAvailable, false, "No update found"); - await addon.uninstall(); -}); diff --git a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini index 9b4a6692aef2..a6b07902a53d 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini +++ b/toolkit/mozapps/extensions/test/xpcshell/xpcshell.ini @@ -180,7 +180,6 @@ tags = webextensions [test_updatecheck_errors.js] [test_updatecheck_json.js] [test_updateid.js] -[test_updateversion.js] [test_upgrade.js] head = head_addons.js head_compat.js run-sequentially = Uses global XCurProcD dir.