|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that creating, collpasing and expanding scopes in the |
|
6 * variables view works as expected. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
|
10 |
|
11 function test() { |
|
12 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
13 let variables = aPanel.panelWin.DebuggerView.Variables; |
|
14 let testScope = variables.addScope("test"); |
|
15 |
|
16 ok(testScope, |
|
17 "Should have created a scope."); |
|
18 ok(testScope.id.contains("test"), |
|
19 "The newly created scope should have the default id set."); |
|
20 is(testScope.name, "test", |
|
21 "The newly created scope should have the desired name set."); |
|
22 |
|
23 ok(!testScope.displayValue, |
|
24 "The newly created scope should not have a displayed value (1)."); |
|
25 ok(!testScope.displayValueClassName, |
|
26 "The newly created scope should not have a displayed value (2)."); |
|
27 |
|
28 ok(testScope.target, |
|
29 "The newly created scope should point to a target node."); |
|
30 ok(testScope.target.id.contains("test"), |
|
31 "Should have the correct scope id on the element."); |
|
32 |
|
33 is(testScope.target.querySelector(".name").getAttribute("value"), "test", |
|
34 "Any new scope should have the designated name."); |
|
35 is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, |
|
36 "Any new scope should have a container with no enumerable child nodes."); |
|
37 is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, |
|
38 "Any new scope should have a container with no non-enumerable child nodes."); |
|
39 |
|
40 ok(!testScope.expanded, |
|
41 "Any new created scope should be initially collapsed."); |
|
42 ok(testScope.visible, |
|
43 "Any new created scope should be initially visible."); |
|
44 |
|
45 let expandCallbackArg = null; |
|
46 let collapseCallbackArg = null; |
|
47 let toggleCallbackArg = null; |
|
48 let hideCallbackArg = null; |
|
49 let showCallbackArg = null; |
|
50 |
|
51 testScope.onexpand = aScope => expandCallbackArg = aScope; |
|
52 testScope.oncollapse = aScope => collapseCallbackArg = aScope; |
|
53 testScope.ontoggle = aScope => toggleCallbackArg = aScope; |
|
54 testScope.onhide = aScope => hideCallbackArg = aScope; |
|
55 testScope.onshow = aScope => showCallbackArg = aScope; |
|
56 |
|
57 testScope.expand(); |
|
58 ok(testScope.expanded, |
|
59 "The testScope shouldn't be collapsed anymore."); |
|
60 is(expandCallbackArg, testScope, |
|
61 "The expandCallback wasn't called as it should."); |
|
62 |
|
63 testScope.collapse(); |
|
64 ok(!testScope.expanded, |
|
65 "The testScope should be collapsed again."); |
|
66 is(collapseCallbackArg, testScope, |
|
67 "The collapseCallback wasn't called as it should."); |
|
68 |
|
69 testScope.expanded = true; |
|
70 ok(testScope.expanded, |
|
71 "The testScope shouldn't be collapsed anymore."); |
|
72 |
|
73 testScope.toggle(); |
|
74 ok(!testScope.expanded, |
|
75 "The testScope should be collapsed again."); |
|
76 is(toggleCallbackArg, testScope, |
|
77 "The toggleCallback wasn't called as it should."); |
|
78 |
|
79 testScope.hide(); |
|
80 ok(!testScope.visible, |
|
81 "The testScope should be invisible after hiding."); |
|
82 is(hideCallbackArg, testScope, |
|
83 "The hideCallback wasn't called as it should."); |
|
84 |
|
85 testScope.show(); |
|
86 ok(testScope.visible, |
|
87 "The testScope should be visible again."); |
|
88 is(showCallbackArg, testScope, |
|
89 "The showCallback wasn't called as it should."); |
|
90 |
|
91 testScope.visible = false; |
|
92 ok(!testScope.visible, |
|
93 "The testScope should be invisible after hiding."); |
|
94 ok(!testScope.expanded, |
|
95 "The testScope should remember it is collapsed even if it is hidden."); |
|
96 |
|
97 testScope.visible = true; |
|
98 ok(testScope.visible, |
|
99 "The testScope should be visible after reshowing."); |
|
100 ok(!testScope.expanded, |
|
101 "The testScope should remember it is collapsed after it is reshown."); |
|
102 |
|
103 EventUtils.sendMouseEvent({ type: "mousedown", button: 1 }, |
|
104 testScope.target.querySelector(".title"), |
|
105 aPanel.panelWin); |
|
106 |
|
107 ok(!testScope.expanded, |
|
108 "Clicking the testScope title with the right mouse button should't expand it."); |
|
109 |
|
110 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
111 testScope.target.querySelector(".title"), |
|
112 aPanel.panelWin); |
|
113 |
|
114 ok(testScope.expanded, |
|
115 "Clicking the testScope title should expand it."); |
|
116 |
|
117 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
118 testScope.target.querySelector(".title"), |
|
119 aPanel.panelWin); |
|
120 |
|
121 ok(!testScope.expanded, |
|
122 "Clicking again the testScope title should collapse it."); |
|
123 |
|
124 closeDebuggerAndFinish(aPanel); |
|
125 }); |
|
126 } |