tor-browser

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

browser_sanitizeOnShutdown_prefLocked.js (1382B)


      1 "use strict";
      2 
      3 function switchToCustomHistoryMode(doc) {
      4  // Select the last item in the menulist.
      5  let menulist = doc.getElementById("historyMode");
      6  menulist.focus();
      7  EventUtils.sendKey("UP");
      8 }
      9 
     10 function testPrefStateMatchesLockedState() {
     11  let win = gBrowser.contentWindow;
     12  let doc = win.document;
     13  switchToCustomHistoryMode(doc);
     14 
     15  let checkbox = doc.getElementById("alwaysClear");
     16  let preference = win.Preferences.get("privacy.sanitize.sanitizeOnShutdown");
     17  is(
     18    checkbox.disabled,
     19    preference.locked,
     20    "Always Clear checkbox should be enabled when preference is not locked."
     21  );
     22 
     23  Services.prefs.clearUserPref("privacy.history.custom");
     24  gBrowser.removeCurrentTab();
     25 }
     26 
     27 add_setup(function () {
     28  registerCleanupFunction(function resetPreferences() {
     29    Services.prefs.unlockPref("privacy.sanitize.sanitizeOnShutdown");
     30    Services.prefs.clearUserPref("privacy.history.custom");
     31  });
     32 });
     33 
     34 add_task(async function test_preference_enabled_when_unlocked() {
     35  await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
     36    leaveOpen: true,
     37  });
     38  testPrefStateMatchesLockedState();
     39 });
     40 
     41 add_task(async function test_preference_disabled_when_locked() {
     42  Services.prefs.lockPref("privacy.sanitize.sanitizeOnShutdown");
     43  await openPreferencesViaOpenPreferencesAPI("panePrivacy", {
     44    leaveOpen: true,
     45  });
     46  testPrefStateMatchesLockedState();
     47 });