From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../mochitest/browser_dbg-pretty-print-console.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-console.js (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-console.js') diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-console.js b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-console.js new file mode 100644 index 0000000000..e6aa266b26 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-pretty-print-console.js @@ -0,0 +1,66 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at . */ + +// The test has a lot of interactions between debugger and console panels which +// might take more than 30s to complete on a slow machine. + +"use strict"; + +requestLongerTimeout(2); + +// Tests that pretty-printing updates console messages. +add_task(async function () { + const dbg = await initDebugger("doc-minified.html"); + invokeInTab("arithmetic"); + + info("Switch to console and check message"); + const minifiedLink = await waitForConsoleLink( + dbg, + "arithmetic", + "math.min.js:3:73" + ); + + info("Click on the link to open the debugger"); + minifiedLink.click(); + await waitForSelectedSource(dbg, "math.min.js"); + await waitForSelectedLocation(dbg, 3); + + info("Click on pretty print button and wait for the file to be formatted"); + clickElement(dbg, "prettyPrintButton"); + await waitForSelectedSource(dbg, "math.min.js:formatted"); + + info("Switch back to console and check message"); + const formattedLink = await waitForConsoleLink( + dbg, + "arithmetic", + "math.min.js:formatted:31:24" + ); + ok(true, "Message location was updated as expected"); + + info( + "Click on the link again and check the debugger opens in formatted file" + ); + formattedLink.click(); + await selectSource(dbg, "math.min.js:formatted"); + await waitForSelectedLocation(dbg, 31); +}); + +async function waitForConsoleLink(dbg, messageText, linkText) { + const { toolbox } = dbg; + await toolbox.selectTool("webconsole"); + + return waitFor(async () => { + // Wait until the message updates. + const [message] = await findConsoleMessages(toolbox, messageText); + if (!message) { + return false; + } + const linkEl = message.querySelector(".frame-link-source"); + if (!linkEl) { + return false; + } + + return linkEl.textContent == linkText ? linkEl : false; + }); +} -- cgit v1.2.3