tor-browser

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

browser_webconsole_click_function_to_source.js (1553B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 // Tests that clicking on a function displays its source in the debugger. See Bug 1050691.
      5 
      6 "use strict";
      7 
      8 requestLongerTimeout(5);
      9 
     10 const TEST_URI =
     11  "http://example.com/browser/devtools/client/webconsole/" +
     12  "test/browser/" +
     13  "test-click-function-to-source.html";
     14 
     15 const TEST_SCRIPT_URI =
     16  "http://example.com/browser/devtools/client/webconsole/" +
     17  "test/browser/" +
     18  "test-click-function-to-source.js";
     19 
     20 add_task(async function () {
     21  const hud = await openNewTabAndConsole(TEST_URI);
     22 
     23  info("Log a function");
     24  const onLoggedFunction = waitForMessageByType(
     25    hud,
     26    "function foo",
     27    ".console-api"
     28  );
     29  SpecialPowers.spawn(gBrowser.selectedBrowser, [], function () {
     30    content.wrappedJSObject.foo();
     31  });
     32  const { node } = await onLoggedFunction;
     33  const jumpIcon = node.querySelector(".jump-definition");
     34  ok(jumpIcon, "A jump to definition button is rendered, as expected");
     35 
     36  info("Click on the jump to definition button.");
     37  jumpIcon.click();
     38 
     39  info("Wait for the Debugger panel to open.");
     40  const toolbox = hud.toolbox;
     41  await toolbox.getPanelWhenReady("jsdebugger");
     42 
     43  const dbg = createDebuggerContext(toolbox);
     44  await waitForSelectedSource(dbg, TEST_SCRIPT_URI);
     45 
     46  const pendingLocation = dbg.selectors.getPendingSelectedLocation();
     47  const { line, column } = pendingLocation;
     48  is(line, 9, "Debugger is open at the expected line");
     49  is(column, 12, "Debugger is open at the expected column");
     50 });