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