1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-hide-non-enums.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,107 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Test that non-enumerable variables and properties can be hidden 1.9 + * in the variables view. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 + 1.16 +function test() { 1.17 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.18 + gTab = aTab; 1.19 + gDebuggee = aDebuggee; 1.20 + gPanel = aPanel; 1.21 + gDebugger = gPanel.panelWin; 1.22 + 1.23 + waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest); 1.24 + gDebuggee.simpleCall(); 1.25 + }); 1.26 +} 1.27 + 1.28 +function performTest() { 1.29 + let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope"); 1.30 + let testVar = testScope.addItem("foo"); 1.31 + 1.32 + testVar.addItems({ 1.33 + foo: { 1.34 + value: "bar", 1.35 + enumerable: true 1.36 + }, 1.37 + bar: { 1.38 + value: "foo", 1.39 + enumerable: false 1.40 + } 1.41 + }); 1.42 + 1.43 + // Expand the scope and variable. 1.44 + testScope.expand(); 1.45 + testVar.expand(); 1.46 + 1.47 + // Expanding the non-enumerable container is synchronously dispatched 1.48 + // on the main thread, so wait for the next tick. 1.49 + executeSoon(() => { 1.50 + let details = testVar._enum; 1.51 + let nonenum = testVar._nonenum; 1.52 + 1.53 + is(details.childNodes.length, 1, 1.54 + "There should be just one property in the .details container."); 1.55 + ok(details.hasAttribute("open"), 1.56 + ".details container should be visible."); 1.57 + ok(nonenum.hasAttribute("open"), 1.58 + ".nonenum container should be visible."); 1.59 + is(nonenum.childNodes.length, 1, 1.60 + "There should be just one property in the .nonenum container."); 1.61 + 1.62 + // Uncheck 'show hidden properties'. 1.63 + gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); 1.64 + gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); 1.65 + 1.66 + ok(details.hasAttribute("open"), 1.67 + ".details container should stay visible."); 1.68 + ok(!nonenum.hasAttribute("open"), 1.69 + ".nonenum container should become hidden."); 1.70 + 1.71 + // Check 'show hidden properties'. 1.72 + gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); 1.73 + gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); 1.74 + 1.75 + ok(details.hasAttribute("open"), 1.76 + ".details container should stay visible."); 1.77 + ok(nonenum.hasAttribute("open"), 1.78 + ".nonenum container should become visible."); 1.79 + 1.80 + // Collapse the variable. This is done on the current tick. 1.81 + testVar.collapse(); 1.82 + 1.83 + ok(!details.hasAttribute("open"), 1.84 + ".details container should be hidden."); 1.85 + ok(!nonenum.hasAttribute("open"), 1.86 + ".nonenum container should be hidden."); 1.87 + 1.88 + // Uncheck 'show hidden properties'. 1.89 + gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); 1.90 + gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); 1.91 + 1.92 + ok(!details.hasAttribute("open"), 1.93 + ".details container should stay hidden."); 1.94 + ok(!nonenum.hasAttribute("open"), 1.95 + ".nonenum container should stay hidden."); 1.96 + 1.97 + // Check 'show hidden properties'. 1.98 + gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); 1.99 + gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); 1.100 + 1.101 + resumeDebuggerThenCloseAndFinish(gPanel); 1.102 + }); 1.103 +} 1.104 + 1.105 +registerCleanupFunction(function() { 1.106 + gTab = null; 1.107 + gDebuggee = null; 1.108 + gPanel = null; 1.109 + gDebugger = null; 1.110 +});