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 /devtools/server/tests/xpcshell/test_addon_events.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 'devtools/server/tests/xpcshell/test_addon_events.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_addon_events.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_addon_events.js b/devtools/server/tests/xpcshell/test_addon_events.js new file mode 100644 index 0000000000..262a604953 --- /dev/null +++ b/devtools/server/tests/xpcshell/test_addon_events.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const { AddonManager } = ChromeUtils.importESModule( + "resource://gre/modules/AddonManager.sys.mjs" +); +add_task(async function testReloadExitedAddon() { + await startupAddonsManager(); + + DevToolsServer.init(); + DevToolsServer.registerAllActors(); + + const client = new DevToolsClient(DevToolsServer.connectPipe()); + await client.connect(); + + // Retrieve the current list of addons to be notified of the next list update. + // We will also call listAddons every time we receive the event "addonListChanged" for + // the same reason. + await client.mainRoot.listAddons(); + + info("Install the addon"); + const addonFile = do_get_file("addons/web-extension", false); + + let installedAddon; + await expectAddonListChanged(client, async () => { + installedAddon = await AddonManager.installTemporaryAddon(addonFile); + }); + ok(true, "Received onAddonListChanged when installing addon"); + + info("Disable the addon"); + await expectAddonListChanged(client, () => installedAddon.disable()); + ok(true, "Received onAddonListChanged when disabling addon"); + + info("Enable the addon"); + await expectAddonListChanged(client, () => installedAddon.enable()); + ok(true, "Received onAddonListChanged when enabling addon"); + + info("Put the addon in pending uninstall mode"); + await expectAddonListChanged(client, () => installedAddon.uninstall(true)); + ok(true, "Received onAddonListChanged when addon moves to pending uninstall"); + + info("Cancel uninstall for addon"); + await expectAddonListChanged(client, () => installedAddon.cancelUninstall()); + ok(true, "Received onAddonListChanged when addon uninstall is canceled"); + + info("Completely uninstall the addon"); + await expectAddonListChanged(client, () => installedAddon.uninstall()); + ok(true, "Received onAddonListChanged when addon is uninstalled"); + + await close(client); +}); + +async function expectAddonListChanged(client, predicate) { + const onAddonListChanged = client.mainRoot.once("addonListChanged"); + await predicate(); + await onAddonListChanged; + await client.mainRoot.listAddons(); +} |