|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that non-enumerable variables and properties can be hidden |
|
6 * in the variables view. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 |
|
13 function test() { |
|
14 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
15 gTab = aTab; |
|
16 gDebuggee = aDebuggee; |
|
17 gPanel = aPanel; |
|
18 gDebugger = gPanel.panelWin; |
|
19 |
|
20 waitForSourceAndCaretAndScopes(gPanel, ".html", 14).then(performTest); |
|
21 gDebuggee.simpleCall(); |
|
22 }); |
|
23 } |
|
24 |
|
25 function performTest() { |
|
26 let testScope = gDebugger.DebuggerView.Variables.addScope("test-scope"); |
|
27 let testVar = testScope.addItem("foo"); |
|
28 |
|
29 testVar.addItems({ |
|
30 foo: { |
|
31 value: "bar", |
|
32 enumerable: true |
|
33 }, |
|
34 bar: { |
|
35 value: "foo", |
|
36 enumerable: false |
|
37 } |
|
38 }); |
|
39 |
|
40 // Expand the scope and variable. |
|
41 testScope.expand(); |
|
42 testVar.expand(); |
|
43 |
|
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; |
|
49 |
|
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."); |
|
58 |
|
59 // Uncheck 'show hidden properties'. |
|
60 gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); |
|
61 gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
|
62 |
|
63 ok(details.hasAttribute("open"), |
|
64 ".details container should stay visible."); |
|
65 ok(!nonenum.hasAttribute("open"), |
|
66 ".nonenum container should become hidden."); |
|
67 |
|
68 // Check 'show hidden properties'. |
|
69 gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); |
|
70 gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
|
71 |
|
72 ok(details.hasAttribute("open"), |
|
73 ".details container should stay visible."); |
|
74 ok(nonenum.hasAttribute("open"), |
|
75 ".nonenum container should become visible."); |
|
76 |
|
77 // Collapse the variable. This is done on the current tick. |
|
78 testVar.collapse(); |
|
79 |
|
80 ok(!details.hasAttribute("open"), |
|
81 ".details container should be hidden."); |
|
82 ok(!nonenum.hasAttribute("open"), |
|
83 ".nonenum container should be hidden."); |
|
84 |
|
85 // Uncheck 'show hidden properties'. |
|
86 gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "true"); |
|
87 gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
|
88 |
|
89 ok(!details.hasAttribute("open"), |
|
90 ".details container should stay hidden."); |
|
91 ok(!nonenum.hasAttribute("open"), |
|
92 ".nonenum container should stay hidden."); |
|
93 |
|
94 // Check 'show hidden properties'. |
|
95 gDebugger.DebuggerView.Options._showVariablesOnlyEnumItem.setAttribute("checked", "false"); |
|
96 gDebugger.DebuggerView.Options._toggleShowVariablesOnlyEnum(); |
|
97 |
|
98 resumeDebuggerThenCloseAndFinish(gPanel); |
|
99 }); |
|
100 } |
|
101 |
|
102 registerCleanupFunction(function() { |
|
103 gTab = null; |
|
104 gDebuggee = null; |
|
105 gPanel = null; |
|
106 gDebugger = null; |
|
107 }); |