fune/browser/components/preferences/in-content/tests/browser_sanitizeOnShutdown_prefLocked.js
David Malaschonok bc0f62486b Bug 552434 - Allow the history mode to stay in Custom even if the settings match the preference values for keeping history. r=jaws
MozReview-Commit-ID: BCX4h3CdBhc

--HG--
extra : rebase_source : 799f964e4d73d6fb0ce317474fdc3c3b457b653c
2016-10-30 11:59:29 +01:00

39 lines
1.3 KiB
JavaScript

"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 = doc.getElementById("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_task(function setup() {
registerCleanupFunction(function resetPreferences() {
Services.prefs.unlockPref("privacy.sanitize.sanitizeOnShutdown");
Services.prefs.clearUserPref("privacy.history.custom");
});
});
add_task(function* test_preference_enabled_when_unlocked() {
yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
testPrefStateMatchesLockedState();
});
add_task(function* test_preference_disabled_when_locked() {
Services.prefs.lockPref("privacy.sanitize.sanitizeOnShutdown");
yield openPreferencesViaOpenPreferencesAPI("panePrivacy", undefined, {leaveOpen: true});
testPrefStateMatchesLockedState();
});