tor-browser

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

browser_net_status-bar.js (1955B)


      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 whether the StatusBar properly renders expected labels.
      8 */
      9 add_task(async () => {
     10  const { monitor } = await initNetMonitor(SIMPLE_URL, {
     11    requestCount: 1,
     12  });
     13  info("Starting test... ");
     14 
     15  const { document, store, windowRequire } = monitor.panelWin;
     16  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     17 
     18  store.dispatch(Actions.batchEnable(false));
     19 
     20  await SpecialPowers.pushPrefEnv({
     21    set: [["privacy.reduceTimerPrecision", false]],
     22  });
     23 
     24  const requestsDone = waitForNetworkEvents(monitor, 1);
     25  const markersDone = waitForTimelineMarkers(monitor);
     26  await reloadBrowser();
     27  await Promise.all([requestsDone, markersDone]);
     28 
     29  const statusBar = document.querySelector(".devtools-toolbar-bottom");
     30  const requestCount = statusBar.querySelector(
     31    ".requests-list-network-summary-count"
     32  );
     33  const size = statusBar.querySelector(
     34    ".requests-list-network-summary-transfer"
     35  );
     36  const onContentLoad = statusBar.querySelector(".dom-content-loaded");
     37  const onLoad = statusBar.querySelector(".load");
     38 
     39  // All expected labels should be there
     40  ok(requestCount, "There must be request count label");
     41  ok(size, "There must be size label");
     42  ok(onContentLoad, "There must be DOMContentLoaded label");
     43  ok(onLoad, "There must be load label");
     44 
     45  // The content should not be empty. The UI update can also be async,
     46  // so use waitUntil.
     47  await waitUntil(() => requestCount.textContent);
     48  ok(true, "There must be request count label text");
     49 
     50  await waitUntil(() => size.textContent);
     51  ok(true, "There must be size label text");
     52 
     53  await waitUntil(() => onContentLoad.textContent);
     54  ok(true, "There must be DOMContentLoaded label text");
     55 
     56  await waitUntil(() => onLoad.textContent);
     57  ok(true, "There must be load label text");
     58 
     59  return teardown(monitor);
     60 });