michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Test that non-enumerable variables and properties can be hidden michael@0: * in the variables view. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest); michael@0: gDebuggee.simpleCall(); michael@0: }); michael@0: } michael@0: michael@0: function performTest() { michael@0: let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope"); michael@0: let testVar = testScope.addItem("foo"); michael@0: michael@0: testVar.addItems({ michael@0: foo: { michael@0: value: "bar", michael@0: enumerable: true michael@0: }, michael@0: bar: { michael@0: value: "foo", michael@0: enumerable: false michael@0: } michael@0: }); michael@0: michael@0: // Expand the scope and variable. michael@0: testScope.expand(); michael@0: testVar.expand(); michael@0: michael@0: // Expanding the non-enumerable container is synchronously dispatched michael@0: // on the main thread, so wait for the next tick. michael@0: executeSoon(() => { michael@0: let details = testVar._enum; michael@0: let nonenum = testVar._nonenum; michael@0: michael@0: is(details.childNodes.length, 1, michael@0: "There should be just one property in the .details container."); michael@0: ok(details.hasAttribute("open"), michael@0: ".details container should be visible."); michael@0: ok(nonenum.hasAttribute("open"), michael@0: ".nonenum container should be visible."); michael@0: is(nonenum.childNodes.length, 1, michael@0: "There should be just one property in the .nonenum container."); michael@0: michael@0: // Uncheck 'show hidden properties'. michael@0: gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); michael@0: gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); michael@0: michael@0: ok(details.hasAttribute("open"), michael@0: ".details container should stay visible."); michael@0: ok(!nonenum.hasAttribute("open"), michael@0: ".nonenum container should become hidden."); michael@0: michael@0: // Check 'show hidden properties'. michael@0: gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); michael@0: gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); michael@0: michael@0: ok(details.hasAttribute("open"), michael@0: ".details container should stay visible."); michael@0: ok(nonenum.hasAttribute("open"), michael@0: ".nonenum container should become visible."); michael@0: michael@0: // Collapse the variable. This is done on the current tick. michael@0: testVar.collapse(); michael@0: michael@0: ok(!details.hasAttribute("open"), michael@0: ".details container should be hidden."); michael@0: ok(!nonenum.hasAttribute("open"), michael@0: ".nonenum container should be hidden."); michael@0: michael@0: // Uncheck 'show hidden properties'. michael@0: gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); michael@0: gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); michael@0: michael@0: ok(!details.hasAttribute("open"), michael@0: ".details container should stay hidden."); michael@0: ok(!nonenum.hasAttribute("open"), michael@0: ".nonenum container should stay hidden."); michael@0: michael@0: // Check 'show hidden properties'. michael@0: gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); michael@0: gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); michael@0: michael@0: resumeDebuggerThenCloseAndFinish(gPanel); michael@0: }); michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: });