tor-browser

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

browser_bug795764_cachedisabled.js (2350B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 function test() {
      5  waitForExplicitFinish();
      6 
      7  // Adding one fake site so that the SiteDataManager would run.
      8  // Otherwise, without any site then it would just return so we would end up in not testing SiteDataManager.
      9  let principal =
     10    Services.scriptSecurityManager.createContentPrincipalFromOrigin(
     11      "https://www.foo.com"
     12    );
     13  Services.perms.addFromPrincipal(
     14    principal,
     15    "persistent-storage",
     16    Ci.nsIPermissionManager.ALLOW_ACTION
     17  );
     18  registerCleanupFunction(function () {
     19    Services.perms.removeFromPrincipal(principal, "persistent-storage");
     20  });
     21 
     22  SpecialPowers.pushPrefEnv({
     23    set: [["privacy.userContext.ui.enabled", true]],
     24  }).then(() => open_preferences(runTest));
     25 }
     26 
     27 async function runTest(win) {
     28  const ipProtectionEnabled = SpecialPowers.getBoolPref(
     29    "browser.ipProtection.enabled",
     30    false
     31  );
     32  is(gBrowser.currentURI.spec, "about:preferences", "about:preferences loaded");
     33 
     34  let tab = win.document;
     35  let elements = tab.getElementById("mainPrefPane").children;
     36 
     37  // Test if privacy pane is opened correctly
     38  await win.gotoPref("panePrivacy");
     39  for (let element of elements) {
     40    let attributeValue = element.getAttribute("data-category");
     41 
     42    // Ignore the cookie banner handling section, as it is currently preffed
     43    // off by default (bug 1800679).
     44    if (element.id === "cookieBannerHandlingGroup") {
     45      continue;
     46    }
     47 
     48    // IP Protection section is gated by browser.ipProtection.enabled
     49    if (element.id === "dataIPProtectionGroup" && !ipProtectionEnabled) {
     50      is_element_hidden(element, "Disabled ipProtection should be hidden");
     51      continue;
     52    }
     53 
     54    if (element.getAttribute("data-hidden-from-search") == "true") {
     55      is_element_hidden(element, "Hidden from search element should be hidden");
     56      continue;
     57    }
     58 
     59    if (attributeValue == "panePrivacy") {
     60      is_element_visible(element, "HTTPSOnly should be visible");
     61 
     62      is_element_visible(
     63        element,
     64        `Privacy element of id=${element.id} should be visible`
     65      );
     66    } else {
     67      is_element_hidden(
     68        element,
     69        `Non-Privacy element of id=${element.id} should be hidden`
     70      );
     71    }
     72  }
     73 
     74  gBrowser.removeCurrentTab();
     75  win.close();
     76  finish();
     77 }