browser/devtools/framework/test/browser_dynamic_tool_enabling.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2  * http://creativecommons.org/publicdomain/zero/1.0/ */
     4 // Tests that toggling prefs immediately (de)activates the relevant menuitem
     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 };
    14 function expectedAttributeValueFromPrefs(prefs) {
    15   return prefs.every((pref) => Services.prefs.getBoolPref(pref)) ?
    16          "" : "true";
    17 }
    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 }
    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 }

mercurial