diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /toolkit/mozapps/extensions/test/xpcshell/test_updateid.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_updateid.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_updateid.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js new file mode 100644 index 0000000000..c88c8e637b --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_updateid.js @@ -0,0 +1,82 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +// This verifies that updating an add-on to a new ID does not work. + +// The test extension uses an insecure update url. +Services.prefs.setBoolPref("extensions.checkUpdateSecurity", false); + +let testserver = AddonTestUtils.createHttpServer({ hosts: ["example.com"] }); + +const ID = "updateid@tests.mozilla.org"; + +// Verify that an update to an add-on with a new ID fails +add_task(async function test_update_new_id() { + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1"); + await promiseStartupManager(); + + await promiseInstallWebExtension({ + manifest: { + version: "1.0", + browser_specific_settings: { + gecko: { + id: ID, + update_url: "http://example.com/update.json", + }, + }, + }, + }); + + let xpi = await createTempWebExtensionFile({ + manifest: { + version: "2.0", + browser_specific_settings: { + gecko: { id: "differentid@tests.mozilla.org" }, + }, + }, + }); + + testserver.registerFile("/addon.xpi", xpi); + AddonTestUtils.registerJSON(testserver, "/update.json", { + addons: { + [ID]: { + updates: [ + { + version: "2.0", + update_link: "http://example.com/addon.xpi", + applications: { + gecko: { + strict_min_version: "1", + strict_max_version: "10", + }, + }, + }, + ], + }, + }, + }); + + 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, null, "Found available update"); + Assert.equal(install.name, addon.name); + Assert.equal(install.version, "2.0"); + Assert.equal(install.state, AddonManager.STATE_AVAILABLE); + Assert.equal(install.existingAddon, addon); + + await Assert.rejects( + install.install(), + err => install.error == AddonManager.ERROR_INCORRECT_ID, + "Upgrade to a different ID fails" + ); + + await addon.uninstall(); +}); |