mirror of
https://github.com/HeyPuter/firefox.git
synced 2026-11-25 02:40:22 -10:00
Depends on D37859 Differential Revision: https://phabricator.services.mozilla.com/D37860
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
|
|
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
|
|
/* Any copyright is dedicated to the Public Domain.
|
|
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
|
|
|
// Tests that toggling prefs immediately (de)activates the relevant menuitem
|
|
|
|
var gItemsToTest = {
|
|
menu_browserToolbox: [
|
|
"devtools.chrome.enabled",
|
|
"devtools.debugger.remote-enabled",
|
|
],
|
|
menu_devtools_connect: [
|
|
"devtools.connectpage.enabled",
|
|
"devtools.debugger.remote-enabled",
|
|
],
|
|
};
|
|
|
|
function expectedAttributeValueFromPrefs(prefs) {
|
|
return prefs.every(pref => Services.prefs.getBoolPref(pref)) ? "" : "true";
|
|
}
|
|
|
|
function checkItem(el, prefs) {
|
|
const expectedValue = expectedAttributeValueFromPrefs(prefs);
|
|
is(
|
|
el.getAttribute("disabled"),
|
|
expectedValue,
|
|
"disabled attribute should match current pref state"
|
|
);
|
|
is(
|
|
el.getAttribute("hidden"),
|
|
expectedValue,
|
|
"hidden attribute should match current pref state"
|
|
);
|
|
}
|
|
|
|
function test() {
|
|
for (const k in gItemsToTest) {
|
|
const el = document.getElementById(k);
|
|
const prefs = gItemsToTest[k];
|
|
checkItem(el, prefs);
|
|
for (const pref of prefs) {
|
|
Services.prefs.setBoolPref(pref, !Services.prefs.getBoolPref(pref));
|
|
checkItem(el, prefs);
|
|
Services.prefs.setBoolPref(pref, !Services.prefs.getBoolPref(pref));
|
|
checkItem(el, prefs);
|
|
}
|
|
}
|
|
finish();
|
|
}
|