tor-browser

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

browser_net_headers-alignment.js (2062B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Bug 1360457 - Mis-alignment between headers and columns on overflow
      8 */
      9 
     10 add_task(async function () {
     11  requestLongerTimeout(4);
     12 
     13  const { tab, monitor } = await initNetMonitor(INFINITE_GET_URL, {
     14    enableCache: true,
     15    requestCount: 1,
     16    expectedEventTimings: 1,
     17  });
     18  const { document, windowRequire, store } = monitor.panelWin;
     19  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     20 
     21  store.dispatch(Actions.batchEnable(false));
     22 
     23  // Wait until the first request makes the empty notice disappear
     24  await waitForRequestListToAppear();
     25 
     26  const requestsContainerScroll = document.querySelector(
     27    ".requests-list-scroll"
     28  );
     29  ok(requestsContainerScroll, "Container element exists as expected.");
     30  const requestsContainer = document.querySelector(".requests-list-row-group");
     31  const headers = document.querySelector(".requests-list-headers");
     32  ok(headers, "Headers element exists as expected.");
     33 
     34  await waitForRequestsToOverflowContainer(monitor, requestsContainerScroll);
     35 
     36  testColumnsAlignment(headers, requestsContainer);
     37 
     38  // Stop doing requests.
     39  await SpecialPowers.spawn(tab.linkedBrowser, [], async function () {
     40    content.wrappedJSObject.stopRequests();
     41  });
     42 
     43  // Done: clean up.
     44  return teardown(monitor);
     45 
     46  function waitForRequestListToAppear() {
     47    info(
     48      "Waiting until the empty notice disappears and is replaced with the list"
     49    );
     50    return waitUntil(
     51      () => !!document.querySelector(".requests-list-row-group")
     52    );
     53  }
     54 });
     55 
     56 async function waitForRequestsToOverflowContainer(monitor, requestList) {
     57  info("Waiting for enough requests to overflow the container");
     58  while (true) {
     59    info("Waiting for one network request");
     60    await waitForNetworkEvents(monitor, 1, { expectedEventTimings: 1 });
     61    if (requestList.scrollHeight > requestList.clientHeight + 50) {
     62      info("The list is long enough, returning");
     63      return;
     64    }
     65  }
     66 }