tor-browser

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

browser_net_statistics-02.js (2147B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Test if the correct filtering predicates are used when filtering from
      8 * the performance analysis view.
      9 */
     10 
     11 add_task(async function () {
     12  const { monitor } = await initNetMonitor(FILTERING_URL, { requestCount: 1 });
     13  info("Starting test... ");
     14 
     15  const panel = monitor.panelWin;
     16  const { document, store, windowRequire, connector } = panel;
     17  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     18 
     19  EventUtils.sendMouseEvent(
     20    { type: "click" },
     21    document.querySelector(".requests-list-filter-html-button")
     22  );
     23  EventUtils.sendMouseEvent(
     24    { type: "click" },
     25    document.querySelector(".requests-list-filter-css-button")
     26  );
     27  EventUtils.sendMouseEvent(
     28    { type: "click" },
     29    document.querySelector(".requests-list-filter-js-button")
     30  );
     31  EventUtils.sendMouseEvent(
     32    { type: "click" },
     33    document.querySelector(".requests-list-filter-ws-button")
     34  );
     35  EventUtils.sendMouseEvent(
     36    { type: "click" },
     37    document.querySelector(".requests-list-filter-other-button")
     38  );
     39  testFilterButtonsCustom(monitor, [0, 1, 1, 1, 0, 0, 0, 0, 1, 1]);
     40  info(
     41    "The correct filtering predicates are used before entering perf. analysis mode."
     42  );
     43 
     44  store.dispatch(Actions.openStatistics(connector, true));
     45 
     46  await waitForAllNetworkUpdateEvents();
     47 
     48  ok(
     49    document.querySelector(".statistics-panel"),
     50    "The main panel is switched to the statistics panel."
     51  );
     52 
     53  await waitUntil(
     54    () =>
     55      document.querySelectorAll(".pie-chart-container:not([placeholder=true])")
     56        .length == 2
     57  );
     58  ok(true, "Two real pie charts appear to be rendered correctly.");
     59 
     60  EventUtils.sendMouseEvent(
     61    { type: "click" },
     62    document.querySelector(".pie-chart-slice-container")
     63  );
     64 
     65  ok(
     66    document.querySelector(".monitor-panel"),
     67    "The main panel is switched back to the monitor panel."
     68  );
     69 
     70  testFilterButtons(monitor, "html");
     71  info(
     72    "The correct filtering predicate is used when exiting perf. analysis mode."
     73  );
     74 
     75  await teardown(monitor);
     76 });