diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js')
-rw-r--r-- | devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js b/devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js new file mode 100644 index 0000000000..a75ce28843 --- /dev/null +++ b/devtools/client/webconsole/test/browser/browser_webconsole_stacktrace_location_debugger_link.js @@ -0,0 +1,63 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that message source links for js errors and console API calls open in +// the jsdebugger when clicked. + +"use strict"; + +// There are shutdown issues for which multiple rejections are left uncaught. +// See bug 1018184 for resolving these issues. +PromiseTestUtils.allowMatchingRejectionsGlobally(/Component not initialized/); +PromiseTestUtils.allowMatchingRejectionsGlobally(/this\.worker is null/); + +const TEST_URI = + "http://example.com/browser/devtools/client/webconsole/" + + "test/browser/" + + "test-stacktrace-location-debugger-link.html"; + +add_task(async function () { + const hud = await openNewTabAndConsole(TEST_URI); + const toolbox = gDevTools.getToolboxForTab(gBrowser.selectedTab); + + await testOpenFrameInDebugger(hud, toolbox, "console.trace()"); + await testOpenFrameInDebugger(hud, toolbox, "myErrorObject"); +}); + +async function testOpenFrameInDebugger(hud, toolbox, text) { + info(`Testing message with text "${text}"`); + const messageNode = await waitFor(() => findConsoleAPIMessage(hud, text)); + const framesNode = await waitFor(() => messageNode.querySelector(".frames")); + + const frameNodes = framesNode.querySelectorAll(".frame"); + is( + frameNodes.length, + 3, + "The message does have the expected number of frames in the stacktrace" + ); + + for (const frameNode of frameNodes) { + await checkMousedownOnNode(hud, toolbox, frameNode); + + info("Selecting the console again"); + await toolbox.selectTool("webconsole"); + } +} + +async function checkMousedownOnNode(hud, toolbox, frameNode) { + info("checking click on node location"); + const onSourceInDebuggerOpened = once(hud, "source-in-debugger-opened"); + EventUtils.sendMouseEvent( + { type: "mousedown" }, + frameNode.querySelector(".location") + ); + await onSourceInDebuggerOpened; + + const url = frameNode.querySelector(".filename").textContent; + const dbg = toolbox.getPanel("jsdebugger"); + is( + dbg._selectors.getSelectedSource(dbg._getState()).url, + url, + `Debugger is opened at expected source url (${url})` + ); +} |