tor-browser

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

browser_net_send-beacon-other-tab.js (1384B)


      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 if beacons from other tabs are properly ignored.
      8 */
      9 
     10 add_task(async function () {
     11  const { monitor, tab } = await initNetMonitor(SIMPLE_URL, {
     12    requestCount: 1,
     13  });
     14  const { store, windowRequire } = monitor.panelWin;
     15  const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
     16  const { getSortedRequests } = windowRequire(
     17    "devtools/client/netmonitor/src/selectors/index"
     18  );
     19 
     20  store.dispatch(Actions.batchEnable(false));
     21 
     22  const beaconTab = await addTab(SEND_BEACON_URL);
     23  info("Beacon tab added successfully.");
     24 
     25  is(
     26    store.getState().requests.requests.length,
     27    0,
     28    "The requests menu should be empty."
     29  );
     30 
     31  const wait = waitForNetworkEvents(monitor, 1);
     32  await SpecialPowers.spawn(beaconTab.linkedBrowser, [], async function () {
     33    content.wrappedJSObject.performRequests();
     34  });
     35  await reloadBrowser({ browser: tab.linkedBrowser });
     36  await wait;
     37 
     38  is(
     39    store.getState().requests.requests.length,
     40    1,
     41    "Only the reload should be recorded."
     42  );
     43  const request = getSortedRequests(store.getState())[0];
     44  is(request.method, "GET", "The method is correct.");
     45  is(request.status, "200", "The status is correct.");
     46 
     47  await removeTab(beaconTab);
     48  return teardown(monitor);
     49 });