tor-browser

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

browser_net_background_update.js (1608B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 /**
      7 * Check that network logs created when the Net panel is not visible
      8 * are displayed when the user shows the panel again.
      9 */
     10 add_task(async () => {
     11  const { tab, monitor, toolbox } = await initNetMonitor(CUSTOM_GET_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 
     19  store.dispatch(Actions.batchEnable(false));
     20 
     21  // Execute two requests
     22  await performRequests(monitor, tab, 2);
     23 
     24  // Wait for two logs
     25  await waitUntil(
     26    () => document.querySelectorAll(".request-list-item").length == 2
     27  );
     28 
     29  info("Select the inspector");
     30  await toolbox.selectTool("inspector");
     31 
     32  info("Wait for Net panel to be hidden");
     33  await waitUntil(() => document.visibilityState == "hidden");
     34 
     35  // Execute another two requests
     36  await performRequests(monitor, tab, 2);
     37 
     38  // The number of rendered requests should be the same since
     39  // requests shouldn't be rendered while the net panel is in
     40  // background
     41  is(
     42    document.querySelectorAll(".request-list-item").length,
     43    2,
     44    "There should be expected number of requests"
     45  );
     46 
     47  info("Select the Net panel again");
     48  await toolbox.selectTool("netmonitor");
     49 
     50  // Wait for another two logs to be rendered since the panel
     51  // is selected now.
     52  await waitUntil(
     53    () => document.querySelectorAll(".request-list-item").length == 4
     54  );
     55 
     56  return teardown(monitor);
     57 });