diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 14:29:10 +0000 |
commit | 2aa4a82499d4becd2284cdb482213d541b8804dd (patch) | |
tree | b80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/test/mochitest/browser_dbg-console-async.js | |
parent | Initial commit. (diff) | |
download | firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip |
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-console-async.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-console-async.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-console-async.js b/devtools/client/debugger/test/mochitest/browser_dbg-console-async.js new file mode 100644 index 0000000000..6fcf4c63a4 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-console-async.js @@ -0,0 +1,47 @@ +// Return a promise with a reference to jsterm, opening the split +// console if necessary. This cleans up the split console pref so +// it won't pollute other tests. + +add_task(async function() { + Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true); + Services.prefs.setBoolPref( + "devtools.debugger.features.map-await-expression", + true + ); + + const dbg = await initDebugger("doc-script-switching.html", "switching-01"); + + await selectSource(dbg, "switching-01"); + + // open the console + await getDebuggerSplitConsole(dbg); + ok(dbg.toolbox.splitConsole, "Split console is shown."); + + const webConsole = await dbg.toolbox.getPanel("webconsole"); + const wrapper = webConsole.hud.ui.wrapper; + + wrapper.dispatchEvaluateExpression(` + let sleep = async (time, v) => new Promise( + res => setTimeout(() => res(v+'!!!'), time) + ) + `); + + await hasMessage(dbg, "sleep"); + + wrapper.dispatchEvaluateExpression(`await sleep(200, "DONE")`); + await hasMessage(dbg, "DONE!!!"); +}); + +function findMessages(win, query) { + return Array.prototype.filter.call( + win.document.querySelectorAll(".message"), + e => e.innerText.includes(query) + ); +} + +async function hasMessage(dbg, msg) { + const webConsole = await dbg.toolbox.getPanel("webconsole"); + return waitFor( + async () => findMessages(webConsole._frameWindow, msg).length > 0 + ); +} |