tor-browser

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

browser_net_disable_cache_rdm.js (1185B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   https://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 "use strict";
      5 
      6 add_task(async function () {
      7  info("Start netmonitor with the cache disabled");
      8  const { tab } = await initNetMonitor(SIMPLE_URL, {
      9    requestCount: 1,
     10    enableCache: false,
     11  });
     12 
     13  is(
     14    await getBrowsingContextDefaultLoadFlags(tab),
     15    Ci.nsIRequest.LOAD_BYPASS_CACHE,
     16    "Cache is disabled on the browsing context"
     17  );
     18 
     19  info("Open responsive design mode");
     20  await openRDM(tab);
     21 
     22  is(
     23    await getBrowsingContextDefaultLoadFlags(tab),
     24    Ci.nsIRequest.LOAD_BYPASS_CACHE,
     25    "Cache is still disabled on the browsing context after opening RDM"
     26  );
     27 
     28  info("Close responsive design mode");
     29  await closeRDM(tab);
     30 
     31  // wait for a bit so flags would have the time to be reset
     32  await wait(1000);
     33 
     34  is(
     35    await getBrowsingContextDefaultLoadFlags(tab),
     36    Ci.nsIRequest.LOAD_BYPASS_CACHE,
     37    "Cache is still disabled on the browsing context after closing RDM"
     38  );
     39 });
     40 
     41 function getBrowsingContextDefaultLoadFlags(tab) {
     42  return SpecialPowers.spawn(
     43    tab.linkedBrowser,
     44    [],
     45    () => content.browsingContext.defaultLoadFlags
     46  );
     47 }