tor-browser

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

browser_net_header-dns.js (1477B)


      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 "DNS Resolution" is displayed in the headers panel and
      8 * that requests that are resolve over DNS over HTTPS are accuratelly tracked.
      9 * Note: Test has to run as a http3 test for the DoH servers to be used
     10 */
     11 
     12 add_task(async function testCheckDNSResolution() {
     13  Services.dns.clearCache(true);
     14  // Force to use DNS Trusted Recursive Resolver only
     15  await pushPref("network.trr.mode", 3);
     16 
     17  const { monitor } = await initNetMonitor(HTTPS_SIMPLE_URL, {
     18    enableCache: true,
     19    requestCount: 1,
     20  });
     21 
     22  const { document } = monitor.panelWin;
     23 
     24  const requestsComplete = waitForNetworkEvents(monitor, 1);
     25  await reloadBrowser();
     26  await requestsComplete;
     27 
     28  // Wait until the tab panel summary is displayed
     29  const waitForTab = waitUntil(
     30    () => document.querySelectorAll(".tabpanel-summary-label")[0]
     31  );
     32  EventUtils.sendMouseEvent(
     33    { type: "mousedown" },
     34    document.querySelectorAll(".request-list-item")[0]
     35  );
     36  await waitForTab;
     37 
     38  const dnsEl = [...document.querySelectorAll(".headers-summary")].find(
     39    el =>
     40      el.querySelector(".headers-summary-label").textContent ===
     41      "DNS Resolution"
     42  );
     43 
     44  is(
     45    dnsEl.querySelector(".tabpanel-summary-value").textContent,
     46    L10N.getStr(`netmonitor.headers.dns.overHttps`),
     47    "The DNS Resolution value showed correctly"
     48  );
     49 
     50  return teardown(monitor);
     51 });