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/client/framework/test/browser_about-devtools-toolbox_reload.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/client/framework/test/browser_about-devtools-toolbox_reload.js')
-rw-r--r-- | devtools/client/framework/test/browser_about-devtools-toolbox_reload.js | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_about-devtools-toolbox_reload.js b/devtools/client/framework/test/browser_about-devtools-toolbox_reload.js new file mode 100644 index 0000000000..f350816b24 --- /dev/null +++ b/devtools/client/framework/test/browser_about-devtools-toolbox_reload.js @@ -0,0 +1,73 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Test that about:devtools-toolbox is reloaded correctly when reusing the same debugger + * client instance. + */ +add_task(async function () { + const devToolsClient = await createLocalClient(); + + info( + "Preload a local DevToolsClient as this-firefox in the remoteClientManager" + ); + const { + remoteClientManager, + } = require("resource://devtools/client/shared/remote-debugging/remote-client-manager.js"); + remoteClientManager.setClient( + "this-firefox", + "this-firefox", + devToolsClient, + {} + ); + registerCleanupFunction(() => { + remoteClientManager.removeAllClients(); + }); + + info("Create a dummy target tab"); + const targetTab = await addTab("data:text/html,somehtml"); + + let onToolboxReady = gDevTools.once("toolbox-ready"); + const { tab } = await openAboutToolbox({ + id: targetTab.linkedBrowser.browserId, + remoteId: "this-firefox-this-firefox", + type: "tab", + }); + await onToolboxReady; + + info("Reload about:devtools-toolbox page"); + onToolboxReady = gDevTools.once("toolbox-ready"); + tab.linkedBrowser.reload(); + await onToolboxReady; + + info("Check if about:devtools-toolbox was reloaded correctly"); + const refreshedDoc = tab.linkedBrowser.contentDocument; + ok( + refreshedDoc.querySelector(".debug-target-info"), + "about:devtools-toolbox header is correctly displayed" + ); + + const onToolboxDestroy = gDevTools.once("toolbox-destroyed"); + await removeTab(tab); + await onToolboxDestroy; + await devToolsClient.close(); + await removeTab(targetTab); +}); + +async function createLocalClient() { + const { + DevToolsClient, + } = require("resource://devtools/client/devtools-client.js"); + const { + DevToolsServer, + } = require("resource://devtools/server/devtools-server.js"); + DevToolsServer.init(); + DevToolsServer.registerAllActors(); + DevToolsServer.allowChromeProcess = true; + + const devToolsClient = new DevToolsClient(DevToolsServer.connectPipe()); + await devToolsClient.connect(); + return devToolsClient; +} |