diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/server/tests/xpcshell/test_addons_actor.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/server/tests/xpcshell/test_addons_actor.js')
-rw-r--r-- | devtools/server/tests/xpcshell/test_addons_actor.js | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/devtools/server/tests/xpcshell/test_addons_actor.js b/devtools/server/tests/xpcshell/test_addons_actor.js new file mode 100644 index 0000000000..e101d9d505 --- /dev/null +++ b/devtools/server/tests/xpcshell/test_addons_actor.js @@ -0,0 +1,56 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ +/* eslint-disable no-shadow */ + +"use strict"; + +async function connect() { + DevToolsServer.init(); + DevToolsServer.registerAllActors(); + + const client = new DevToolsClient(DevToolsServer.connectPipe()); + await client.connect(); + + const addons = await client.mainRoot.getFront("addons"); + return [client, addons]; +} + +// The AddonsManager test helper can only be called once per test script. +// This `setup` task will run first. +add_task(async function setup() { + await startupAddonsManager(); +}); + +add_task(async function testSuccessfulInstall() { + const [client, addons] = await connect(); + + const allowMissing = false; + const usePlatformSeparator = true; + const addonPath = getFilePath( + "addons/web-extension", + allowMissing, + usePlatformSeparator + ); + const installedAddon = await addons.installTemporaryAddon(addonPath); + equal(installedAddon.id, "test-addons-actor@mozilla.org"); + // The returned object is currently not a proper actor. + equal(installedAddon.actor, false); + + const addonList = await client.mainRoot.listAddons(); + ok(addonList && addonList.map(a => a.name), "Received list of add-ons"); + const addon = addonList.find(a => a.id === installedAddon.id); + ok(addon, "Test add-on appeared in root install list"); + + await close(client); +}); + +add_task(async function testNonExistantPath() { + const [client, addons] = await connect(); + + await Assert.rejects( + addons.installTemporaryAddon("some-non-existant-path"), + /Could not install add-on.*Component returned failure/ + ); + + await close(client); +}); |