diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js')
-rw-r--r-- | toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js | 213 |
1 files changed, 213 insertions, 0 deletions
diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js b/toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js new file mode 100644 index 0000000000..f231397072 --- /dev/null +++ b/toolkit/mozapps/extensions/test/xpcshell/test_reinstall_disabled_addon.js @@ -0,0 +1,213 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ + */ + +const ID = "test_addon@tests.mozilla.org"; + +const ADDONS = { + test_install1_1: { + name: "Test 1 Addon", + description: "Test 1 addon description", + manifest_version: 2, + version: "1.0", + browser_specific_settings: { + gecko: { + id: ID, + }, + }, + }, + test_install1_2: { + name: "Test 1 Addon", + description: "Test 1 addon description", + manifest_version: 2, + version: "2.0", + browser_specific_settings: { + gecko: { + id: ID, + }, + }, + }, +}; + +add_task(async function setup() { + createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "1.9.2"); + await promiseStartupManager(); +}); + +// User intentionally reinstalls existing disabled addon of the same version. +// No onInstalling nor onInstalled are fired. +add_task(async function reinstallExistingDisabledAddonSameVersion() { + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onInstalling" }, { event: "onInstalled" }], + }, + installEvents: [ + { event: "onNewInstall" }, + { event: "onInstallStarted" }, + { event: "onInstallEnded" }, + ], + }, + async () => { + const xpi = AddonTestUtils.createTempWebExtensionFile({ + manifest: ADDONS.test_install1_1, + }); + let install = await AddonManager.getInstallForFile(xpi); + await install.install(); + } + ); + + let addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(addon.isActive); + ok(!addon.userDisabled); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onDisabling" }, { event: "onDisabled" }], + }, + }, + () => addon.disable() + ); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(!addon.isActive); + ok(addon.userDisabled); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onEnabling" }, { event: "onEnabled" }], + }, + installEvents: [ + { event: "onNewInstall" }, + { event: "onInstallStarted" }, + { event: "onInstallEnded" }, + ], + }, + async () => { + const xpi2 = AddonTestUtils.createTempWebExtensionFile({ + manifest: ADDONS.test_install1_1, + }); + let install = await AddonManager.getInstallForFile(xpi2); + await install.install(); + } + ); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(addon.isActive); + ok(!addon.userDisabled); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onUninstalling" }, { event: "onUninstalled" }], + }, + }, + () => addon.uninstall() + ); + + addon = await promiseAddonByID(ID); + equal(addon, null); + + await promiseRestartManager(); +}); + +// User intentionally reinstalls existing disabled addon of different version, +// but addon *still should be disabled*. +add_task(async function reinstallExistingDisabledAddonDifferentVersion() { + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onInstalling" }, { event: "onInstalled" }], + }, + installEvents: [ + { event: "onNewInstall" }, + { event: "onInstallStarted" }, + { event: "onInstallEnded" }, + ], + }, + async () => { + const xpi = AddonTestUtils.createTempWebExtensionFile({ + manifest: ADDONS.test_install1_1, + }); + let install = await AddonManager.getInstallForFile(xpi); + + await install.install(); + } + ); + + let addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(addon.isActive); + ok(!addon.userDisabled); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onDisabling" }, { event: "onDisabled" }], + }, + }, + () => addon.disable() + ); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(!addon.isActive); + ok(addon.userDisabled); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onInstalling" }, { event: "onInstalled" }], + }, + installEvents: [ + { event: "onNewInstall" }, + { event: "onInstallStarted" }, + { event: "onInstallEnded" }, + ], + }, + async () => { + let xpi2 = AddonTestUtils.createTempWebExtensionFile({ + manifest: ADDONS.test_install1_2, + }); + let install = await AddonManager.getInstallForFile(xpi2); + await install.install(); + } + ); + + addon = await promiseAddonByID(ID); + notEqual(addon, null); + equal(addon.pendingOperations, AddonManager.PENDING_NONE); + ok(!addon.isActive); + ok(addon.userDisabled); + equal(addon.version, "2.0"); + + await expectEvents( + { + ignorePlugins: true, + addonEvents: { + [ID]: [{ event: "onUninstalling" }, { event: "onUninstalled" }], + }, + }, + () => addon.uninstall() + ); + + addon = await promiseAddonByID(ID); + equal(addon, null); +}); |