browser/devtools/framework/test/browser_dynamic_tool_enabling.js

Thu, 15 Jan 2015 21:03:48 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 21:03:48 +0100
branch
TOR_BUG_9701
changeset 11
deefc01c0e14
permissions
-rw-r--r--

Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)

     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