tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_dbg-console-map-bindings.js (1391B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
      4 
      5 "use strict";
      6 
      7 add_task(async function () {
      8  Services.prefs.setBoolPref("devtools.toolbox.splitconsole.open", true);
      9  const dbg = await initDebugger("doc-strict.html");
     10 
     11  await getSplitConsole(dbg);
     12  ok(dbg.toolbox.splitConsole, "Split console is shown.");
     13 
     14  invokeInTab("strict", 2);
     15 
     16  await waitForPaused(dbg);
     17  await evaluate(dbg, "var c = 3");
     18  const msg2 = await evaluate(dbg, "c");
     19 
     20  is(msg2.trim(), "3");
     21 });
     22 
     23 // Return a promise with a reference to jsterm, opening the split
     24 // console if necessary.  This cleans up the split console pref so
     25 // it won't pollute other tests.
     26 function getSplitConsole(dbg) {
     27  const { toolbox } = dbg;
     28 
     29  if (!toolbox.splitConsole) {
     30    pressKey(dbg, "Escape");
     31  }
     32 
     33  return new Promise(resolve => {
     34    toolbox.getPanelWhenReady("webconsole").then(() => {
     35      ok(toolbox.splitConsole, "Split console is shown.");
     36      const jsterm = toolbox.getPanel("webconsole").hud.jsterm;
     37      resolve(jsterm);
     38    });
     39  });
     40 }
     41 
     42 async function evaluate(dbg, expression) {
     43  const { toolbox } = dbg;
     44  const { hud } = toolbox.getPanel("webconsole");
     45  const msg = await evaluateExpressionInConsole(hud, expression);
     46  return msg.innerText;
     47 }