|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 * http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Tests that toggling prefs immediately (de)activates the relevant menuitem |
|
5 |
|
6 let gItemsToTest = { |
|
7 "menu_devToolbar": "devtools.toolbar.enabled", |
|
8 "menu_devAppMgr": "devtools.appmanager.enabled", |
|
9 "menu_browserToolbox": ["devtools.chrome.enabled", "devtools.debugger.remote-enabled", "devtools.debugger.chrome-enabled"], |
|
10 "javascriptConsole": "devtools.errorconsole.enabled", |
|
11 "menu_devtools_connect": "devtools.debugger.remote-enabled", |
|
12 }; |
|
13 |
|
14 function expectedAttributeValueFromPrefs(prefs) { |
|
15 return prefs.every((pref) => Services.prefs.getBoolPref(pref)) ? |
|
16 "" : "true"; |
|
17 } |
|
18 |
|
19 function checkItem(el, prefs) { |
|
20 let expectedValue = expectedAttributeValueFromPrefs(prefs); |
|
21 is(el.getAttribute("disabled"), expectedValue, "disabled attribute should match current pref state"); |
|
22 is(el.getAttribute("hidden"), expectedValue, "hidden attribute should match current pref state"); |
|
23 } |
|
24 |
|
25 function test() { |
|
26 for (let k in gItemsToTest) { |
|
27 let el = document.getElementById(k); |
|
28 let prefs = gItemsToTest[k]; |
|
29 if (typeof prefs == "string") { |
|
30 prefs = [prefs]; |
|
31 } |
|
32 checkItem(el, prefs); |
|
33 for (let pref of prefs) { |
|
34 Services.prefs.setBoolPref(pref, !Services.prefs.getBoolPref(pref)); |
|
35 checkItem(el, prefs); |
|
36 Services.prefs.setBoolPref(pref, !Services.prefs.getBoolPref(pref)); |
|
37 checkItem(el, prefs); |
|
38 } |
|
39 } |
|
40 } |