tor-browser

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

browser_net_columns_time.js (1920B)


      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 for timings columns. Note that the column
      8 * header is visible only if there are requests in the list.
      9 */
     10 add_task(async function () {
     11  const { monitor } = await initNetMonitor(SIMPLE_URL, {
     12    requestCount: 1,
     13  });
     14  info("Starting test... ");
     15 
     16  const { document, store, windowRequire } = monitor.panelWin;
     17  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     18  store.dispatch(Actions.batchEnable(false));
     19 
     20  const visibleColumns = store.getState().ui.columns;
     21 
     22  const wait = waitForNetworkEvents(monitor, 1);
     23  await reloadBrowser();
     24  await wait;
     25 
     26  // Hide the waterfall column to make sure timing data are fetched
     27  // by the other timing columns ("endTime", "responseTime", "duration",
     28  // "latency").
     29  // Note that all these timing columns are based on the same
     30  // `RequestListColumnTime` component.
     31  if (visibleColumns.waterfall) {
     32    await hideColumn(monitor, "waterfall");
     33  }
     34 
     35  ["endTime", "responseTime", "duration", "latency"].forEach(async column => {
     36    if (!visibleColumns[column]) {
     37      await showColumn(monitor, column);
     38    }
     39  });
     40 
     41  const onNetworkEvents = waitForNetworkEvents(monitor, 1);
     42  await reloadBrowser();
     43  await onNetworkEvents;
     44 
     45  // There should be one request in the list.
     46  const requestItems = document.querySelectorAll(".request-list-item");
     47  is(requestItems.length, 1, "There must be one visible item");
     48 
     49  const item = requestItems[0];
     50  const types = ["end", "response", "duration", "latency"];
     51 
     52  for (const t of types) {
     53    info("Check the timing column for type: " + t);
     54    await waitUntil(() => {
     55      const node = item.querySelector(".requests-list-" + t + "-time");
     56      const value = parseInt(node.textContent, 10);
     57      return value >= 0;
     58    });
     59  }
     60 
     61  await teardown(monitor);
     62 });