From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../server/tests/xpcshell/test_front_destroy.js | 42 ++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 devtools/server/tests/xpcshell/test_front_destroy.js (limited to 'devtools/server/tests/xpcshell/test_front_destroy.js') diff --git a/devtools/server/tests/xpcshell/test_front_destroy.js b/devtools/server/tests/xpcshell/test_front_destroy.js new file mode 100644 index 0000000000..33e2ac827a --- /dev/null +++ b/devtools/server/tests/xpcshell/test_front_destroy.js @@ -0,0 +1,42 @@ +/* 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). +// eslint-disable-next-line no-undef +_profileInitialized = true; + +add_task(async function test() { + DevToolsServer.init(); + DevToolsServer.registerAllActors(); + + info("Create and connect the DevToolsClient"); + const transport = DevToolsServer.connectPipe(); + const client = new DevToolsClient(transport); + await client.connect(); + + 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(); +}); -- cgit v1.2.3