tor-browser

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

browser_net_stacktraces-visibility.js (2512B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Tests that opening the stacktrace details panel in the netmonitor and console
      8 * show the expected stacktraces.
      9 */
     10 
     11 add_task(async function () {
     12  const URL = EXAMPLE_URL + "html_single-get-page.html";
     13  const REQUEST =
     14    "http://example.com/browser/devtools/client/netmonitor/test/request_0";
     15 
     16  const { monitor } = await initNetMonitor(URL, {
     17    requestCount: 1,
     18  });
     19 
     20  const { document, store, windowRequire } = monitor.panelWin;
     21  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     22 
     23  store.dispatch(Actions.batchEnable(false));
     24 
     25  info("Starting test... ");
     26 
     27  const allRequestsVisible = waitUntil(
     28    () => document.querySelectorAll(".request-list-item").length == 2
     29  );
     30 
     31  await waitForAllNetworkUpdateEvents();
     32  await reloadBrowser();
     33  await allRequestsVisible;
     34 
     35  const onStackTracesVisible = waitUntil(
     36    () => document.querySelector("#stack-trace-panel .stack-trace .frame-link"),
     37    "Wait for the stacktrace to be rendered"
     38  );
     39 
     40  // Select the request initiated by html_single-get-page.html
     41  EventUtils.sendMouseEvent(
     42    { type: "mousedown" },
     43    document.querySelector(
     44      `.request-list-item .requests-list-file[title="${REQUEST}"]`
     45    )
     46  );
     47 
     48  // Wait for the stack trace tab to show
     49  await waitUntil(() =>
     50    document.querySelector(".network-details-bar #stack-trace-tab")
     51  );
     52 
     53  clickOnSidebarTab(document, "stack-trace");
     54 
     55  await onStackTracesVisible;
     56 
     57  // Switch to the webconsole.
     58  const { hud } = await monitor.toolbox.selectTool("webconsole");
     59  await waitFor(
     60    () =>
     61      hud.ui.outputNode.querySelector(
     62        ".webconsole-output .cm-s-mozilla.message.network"
     63      ),
     64    "Wait for the network request log to show"
     65  );
     66  const fetchRequestUrlNode = hud.ui.outputNode.querySelector(
     67    `.webconsole-output .cm-s-mozilla.message.network a[title="${REQUEST}"]`
     68  );
     69  fetchRequestUrlNode.click();
     70 
     71  const messageWrapper = fetchRequestUrlNode.closest(".message-body-wrapper");
     72 
     73  await waitFor(
     74    () => messageWrapper.querySelector(".network-info"),
     75    "Wait for .network-info to be rendered"
     76  );
     77 
     78  // Select stacktrace details panel and check the content.
     79  messageWrapper.querySelector("#stack-trace-tab").click();
     80  await waitFor(
     81    () => messageWrapper.querySelector("#stack-trace-panel .frame-link"),
     82    "Wait for stacktrace to be rendered"
     83  );
     84 
     85  return teardown(monitor);
     86 });