diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 09:22:09 +0000 |
commit | 43a97878ce14b72f0981164f87f2e35e14151312 (patch) | |
tree | 620249daf56c0258faa40cbdcf9cfba06de2a846 /browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js | |
parent | Initial commit. (diff) | |
download | firefox-upstream.tar.xz firefox-upstream.zip |
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js')
-rw-r--r-- | browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js b/browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js new file mode 100644 index 0000000000..9811ed62d1 --- /dev/null +++ b/browser/components/preferences/tests/browser_sanitizeOnShutdown_prefLocked.js @@ -0,0 +1,47 @@ +"use strict"; + +function switchToCustomHistoryMode(doc) { + // Select the last item in the menulist. + let menulist = doc.getElementById("historyMode"); + menulist.focus(); + EventUtils.sendKey("UP"); +} + +function testPrefStateMatchesLockedState() { + let win = gBrowser.contentWindow; + let doc = win.document; + switchToCustomHistoryMode(doc); + + let checkbox = doc.getElementById("alwaysClear"); + let preference = win.Preferences.get("privacy.sanitize.sanitizeOnShutdown"); + is( + checkbox.disabled, + preference.locked, + "Always Clear checkbox should be enabled when preference is not locked." + ); + + Services.prefs.clearUserPref("privacy.history.custom"); + gBrowser.removeCurrentTab(); +} + +add_setup(function() { + registerCleanupFunction(function resetPreferences() { + Services.prefs.unlockPref("privacy.sanitize.sanitizeOnShutdown"); + Services.prefs.clearUserPref("privacy.history.custom"); + }); +}); + +add_task(async function test_preference_enabled_when_unlocked() { + await openPreferencesViaOpenPreferencesAPI("panePrivacy", { + leaveOpen: true, + }); + testPrefStateMatchesLockedState(); +}); + +add_task(async function test_preference_disabled_when_locked() { + Services.prefs.lockPref("privacy.sanitize.sanitizeOnShutdown"); + await openPreferencesViaOpenPreferencesAPI("panePrivacy", { + leaveOpen: true, + }); + testPrefStateMatchesLockedState(); +}); |