tor-browser

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

browser_aboutdebugging_devtoolstoolbox_jstracer.js (2302B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 Services.scriptloader.loadSubScript(
      7  "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
      8  this
      9 );
     10 
     11 const TAB_URL =
     12  "data:text/html,<script>function foo() { bar(); }; function bar() {}</script>";
     13 
     14 /* import-globals-from helper-collapsibilities.js */
     15 Services.scriptloader.loadSubScript(
     16  CHROME_URL_ROOT + "helper-collapsibilities.js",
     17  this
     18 );
     19 
     20 /**
     21 * Test JavaScript Tracer in about:devtools-toolbox tabs (ie non localTab tab target).
     22 */
     23 add_task(async function () {
     24  // This is preffed off for now, so ensure turning it on
     25  await pushPref("devtools.debugger.features.javascript-tracing", true);
     26 
     27  const testTab = await addTab(TAB_URL);
     28 
     29  info("Force all debug target panes to be expanded");
     30  prepareCollapsibilitiesTest();
     31 
     32  const { document, tab, window } = await openAboutDebugging();
     33  await selectThisFirefoxPage(document, window.AboutDebugging.store);
     34  const { devtoolsTab, devtoolsWindow } = await openAboutDevtoolsToolbox(
     35    document,
     36    tab,
     37    window,
     38    TAB_URL
     39  );
     40  info("Select performance panel");
     41  const toolbox = getToolbox(devtoolsWindow);
     42  await toolbox.selectTool("jsdebugger");
     43 
     44  info("Add a breakpoint at line 10 in the test script");
     45  const debuggerContext = createDebuggerContext(toolbox);
     46 
     47  await toggleJsTracerMenuItem(
     48    debuggerContext,
     49    "#jstracer-menu-item-debugger-sidebar"
     50  );
     51 
     52  await toggleJsTracer(toolbox);
     53 
     54  info("Invoke some code that will be traced");
     55  await ContentTask.spawn(testTab.linkedBrowser, {}, function () {
     56    content.wrappedJSObject.foo();
     57  });
     58 
     59  info("Wait for the expected traces to appear in the call tree");
     60  const tree = await waitForElementWithSelector(
     61    debuggerContext,
     62    "#tracer-tab-panel .tree"
     63  );
     64  const traces = await waitFor(() => {
     65    const elements = tree.querySelectorAll(
     66      ".trace-line .frame-link-function-display-name"
     67    );
     68    if (elements.length == 2) {
     69      return elements;
     70    }
     71    return false;
     72  });
     73  is(traces[0].textContent, "λ foo");
     74  is(traces[1].textContent, "λ bar");
     75 
     76  await closeAboutDevtoolsToolbox(document, devtoolsTab, window);
     77  await removeTab(testTab);
     78  await removeTab(tab);
     79 });