diff options
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-console-map-bindings.js')
-rw-r--r-- | devtools/client/debugger/test/mochitest/browser_dbg-console-map-bindings.js | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-console-map-bindings.js b/devtools/client/debugger/test/mochitest/browser_dbg-console-map-bindings.js new file mode 100644 index 0000000000..cf37b98af6 --- /dev/null +++ b/devtools/client/debugger/test/mochitest/browser_dbg-console-map-bindings.js @@ -0,0 +1,49 @@ +/* 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 <http://mozilla.org/MPL/2.0/>. */ + +add_task(async function() { + Services.prefs.setBoolPref("devtools.toolbox.splitconsoleEnabled", true); + const dbg = await initDebugger("doc-strict.html"); + + await getSplitConsole(dbg); + ok(dbg.toolbox.splitConsole, "Split console is shown."); + + invokeInTab("strict", 2); + + await waitForPaused(dbg); + await evaluate(dbg, "var c = 3"); + const msg2 = await evaluate(dbg, "c"); + + is(msg2.trim(), "3"); +}); + +// 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. +function getSplitConsole(dbg) { + const { toolbox, win } = dbg; + + if (!win) { + win = toolbox.win; + } + + if (!toolbox.splitConsole) { + pressKey(dbg, "Escape"); + } + + return new Promise(resolve => { + toolbox.getPanelWhenReady("webconsole").then(() => { + ok(toolbox.splitConsole, "Split console is shown."); + let jsterm = toolbox.getPanel("webconsole").hud.jsterm; + resolve(jsterm); + }); + }); +} + +async function evaluate(dbg, expression) { + const { toolbox } = dbg; + const { hud } = toolbox.getPanel("webconsole"); + const msg = await evaluateExpressionInConsole(hud, expression); + return msg.innerText; +}
\ No newline at end of file |