tor-browser

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

browser_net_layout_after_toggle.js (1729B)


      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 the netmonitor UI is not broken after toggling to another panel.
      8 */
      9 
     10 add_task(async function () {
     11  const { monitor, toolbox } = await initNetMonitor(HTTPS_SIMPLE_URL, {
     12    requestCount: 1,
     13  });
     14  ok(monitor, "The network monitor was opened");
     15 
     16  const onNetworkEvent = waitForNetworkEvents(monitor, 1);
     17  await navigateTo(HTTPS_SIMPLE_URL);
     18  await onNetworkEvent;
     19 
     20  const { document } = monitor.panelWin;
     21 
     22  info("Select the first request to show the details side panel");
     23  const firstRequest = document.querySelectorAll(".request-list-item")[0];
     24  EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequest);
     25 
     26  // Wait for a reflow before measuring the request list height.
     27  await new Promise(r =>
     28    window.requestAnimationFrame(() => TestUtils.executeSoon(r))
     29  );
     30  const requestsListHeight = getRequestsListHeight(document);
     31 
     32  info("Select the inspector");
     33  await toolbox.selectTool("inspector");
     34 
     35  info("Wait for Net panel to be hidden");
     36  await waitUntil(() => document.visibilityState == "hidden");
     37 
     38  info("Select the Net panel again");
     39  await toolbox.selectTool("netmonitor");
     40 
     41  info("Wait for Net panel to be hidden");
     42  await waitUntil(() => document.visibilityState == "visible");
     43 
     44  ("Wait until the requests list has the same height as before");
     45  await waitFor(
     46    () => getRequestsListHeight(document) == requestsListHeight,
     47    "Requests list height is the same after switching to another panel"
     48  );
     49  await teardown(monitor);
     50 });
     51 
     52 function getRequestsListHeight(document) {
     53  return document.querySelector(".requests-list-scroll").offsetHeight;
     54 }