browser/devtools/debugger/test/browser_dbg_variables-view-hide-non-enums.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 /**
     5  * Test that non-enumerable variables and properties can be hidden
     6  * in the variables view.
     7  */
     9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
    11 let gTab, gDebuggee, gPanel, gDebugger;
    13 function test() {
    14   initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
    15     gTab = aTab;
    16     gDebuggee = aDebuggee;
    17     gPanel = aPanel;
    18     gDebugger = gPanel.panelWin;
    20     waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest);
    21     gDebuggee.simpleCall();
    22   });
    23 }
    25 function performTest() {
    26   let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope");
    27   let testVar = testScope.addItem("foo");
    29   testVar.addItems({
    30     foo: {
    31       value: "bar",
    32       enumerable: true
    33     },
    34     bar: {
    35       value: "foo",
    36       enumerable: false
    37     }
    38   });
    40   // Expand the scope and variable.
    41   testScope.expand();
    42   testVar.expand();
    44   // Expanding the non-enumerable container is synchronously dispatched
    45   // on the main thread, so wait for the next tick.
    46   executeSoon(() => {
    47     let details = testVar._enum;
    48     let nonenum = testVar._nonenum;
    50     is(details.childNodes.length, 1,
    51       "There should be just one property in the .details container.");
    52     ok(details.hasAttribute("open"),
    53       ".details container should be visible.");
    54     ok(nonenum.hasAttribute("open"),
    55       ".nonenum container should be visible.");
    56     is(nonenum.childNodes.length, 1,
    57       "There should be just one property in the .nonenum container.");
    59     // Uncheck 'show hidden properties'.
    60     gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true");
    61     gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
    63     ok(details.hasAttribute("open"),
    64       ".details container should stay visible.");
    65     ok(!nonenum.hasAttribute("open"),
    66       ".nonenum container should become hidden.");
    68     // Check 'show hidden properties'.
    69     gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false");
    70     gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
    72     ok(details.hasAttribute("open"),
    73       ".details container should stay visible.");
    74     ok(nonenum.hasAttribute("open"),
    75       ".nonenum container should become visible.");
    77     // Collapse the variable. This is done on the current tick.
    78     testVar.collapse();
    80     ok(!details.hasAttribute("open"),
    81       ".details container should be hidden.");
    82     ok(!nonenum.hasAttribute("open"),
    83       ".nonenum container should be hidden.");
    85     // Uncheck 'show hidden properties'.
    86     gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true");
    87     gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
    89     ok(!details.hasAttribute("open"),
    90       ".details container should stay hidden.");
    91     ok(!nonenum.hasAttribute("open"),
    92       ".nonenum container should stay hidden.");
    94     // Check 'show hidden properties'.
    95     gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false");
    96     gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum();
    98     resumeDebuggerThenCloseAndFinish(gPanel);
    99   });
   100 }
   102 registerCleanupFunction(function() {
   103   gTab = null;
   104   gDebuggee = null;
   105   gPanel = null;
   106   gDebugger = null;
   107 });

mercurial