Files
Alexandre Poirot 7610af1774 Bug 2064424 - [devtools] Always use CommandsFactory helpers to instantiate local DevToolsClient's. r=devtools-reviewers,nchevobbe
This helps share the logic to create the DevToolsServer
and better highlights tab-debugger client (createLocalClientForTests)
versus browser-toolbox-debugger client (spawnClientToDebugSystemPrincipal).

Differential Revision: https://phabricator.services.mozilla.com/D319532
2026-08-24 18:50:34 +00:00

37 lines
1.2 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test that fronts throw errors if they are called after being destroyed.
*/
"use strict";
// HACK: ServiceWorkerManager requires the "profile-change-teardown" to cleanly
// shutdown, and setting _profileInitialized to `true` will trigger those
// notifications (see /testing/xpcshell/head.js).
_profileInitialized = true;
add_task(async function test() {
info("Create and connect the DevToolsClient");
const client = await CommandsFactory.spawnClientToDebugSystemPrincipal();
info("Get the device front and check calling getDescription() on it");
const front = await client.mainRoot.getFront("device");
const description = await front.getDescription();
ok(
!!description,
"Check that the getDescription() method returns a valid response."
);
info("Destroy the device front and try calling getDescription again");
front.destroy();
Assert.throws(
() => front.getDescription(),
/Can not send request 'getDescription' because front 'device' is already destroyed\./,
"Check device front throws when getDescription() is called after destroy()"
);
await client.close();
});