|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Tests that grips are correctly applied to variables and properties. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
|
9 |
|
10 function test() { |
|
11 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
12 let variables = aPanel.panelWin.DebuggerView.Variables; |
|
13 |
|
14 let globalScope = variables.addScope("Test-Global"); |
|
15 let localScope = variables.addScope("Test-Local"); |
|
16 |
|
17 ok(globalScope, "The globalScope hasn't been created correctly."); |
|
18 ok(localScope, "The localScope hasn't been created correctly."); |
|
19 |
|
20 is(globalScope.target.querySelector(".separator"), null, |
|
21 "No separator string should be created for scopes (1)."); |
|
22 is(localScope.target.querySelector(".separator"), null, |
|
23 "No separator string should be created for scopes (2)."); |
|
24 |
|
25 let windowVar = globalScope.addItem("window"); |
|
26 let documentVar = globalScope.addItem("document"); |
|
27 |
|
28 ok(windowVar, "The windowVar hasn't been created correctly."); |
|
29 ok(documentVar, "The documentVar hasn't been created correctly."); |
|
30 |
|
31 ok(windowVar.target.querySelector(".separator").hidden, |
|
32 "No separator string should be shown for variables without a grip (1)."); |
|
33 ok(documentVar.target.querySelector(".separator").hidden, |
|
34 "No separator string should be shown for variables without a grip (2)."); |
|
35 |
|
36 windowVar.setGrip({ type: "object", class: "Window" }); |
|
37 documentVar.setGrip({ type: "object", class: "HTMLDocument" }); |
|
38 |
|
39 is(windowVar.target.querySelector(".separator").hidden, false, |
|
40 "A separator string should now be shown after setting the grip (1)."); |
|
41 is(documentVar.target.querySelector(".separator").hidden, false, |
|
42 "A separator string should now be shown after setting the grip (2)."); |
|
43 |
|
44 is(windowVar.target.querySelector(".separator").getAttribute("value"), ": ", |
|
45 "The separator string label is correct (1)."); |
|
46 is(documentVar.target.querySelector(".separator").getAttribute("value"), ": ", |
|
47 "The separator string label is correct (2)."); |
|
48 |
|
49 let localVar0 = localScope.addItem("localVar0"); |
|
50 let localVar1 = localScope.addItem("localVar1"); |
|
51 let localVar2 = localScope.addItem("localVar2"); |
|
52 let localVar3 = localScope.addItem("localVar3"); |
|
53 let localVar4 = localScope.addItem("localVar4"); |
|
54 let localVar5 = localScope.addItem("localVar5"); |
|
55 |
|
56 let localVar6 = localScope.addItem("localVar6"); |
|
57 let localVar7 = localScope.addItem("localVar7"); |
|
58 let localVar8 = localScope.addItem("localVar8"); |
|
59 let localVar9 = localScope.addItem("localVar9"); |
|
60 |
|
61 ok(localVar0, "The localVar0 hasn't been created correctly."); |
|
62 ok(localVar1, "The localVar1 hasn't been created correctly."); |
|
63 ok(localVar2, "The localVar2 hasn't been created correctly."); |
|
64 ok(localVar3, "The localVar3 hasn't been created correctly."); |
|
65 ok(localVar4, "The localVar4 hasn't been created correctly."); |
|
66 ok(localVar5, "The localVar5 hasn't been created correctly."); |
|
67 ok(localVar6, "The localVar6 hasn't been created correctly."); |
|
68 ok(localVar7, "The localVar7 hasn't been created correctly."); |
|
69 ok(localVar8, "The localVar8 hasn't been created correctly."); |
|
70 ok(localVar9, "The localVar9 hasn't been created correctly."); |
|
71 |
|
72 localVar0.setGrip(42); |
|
73 localVar1.setGrip(true); |
|
74 localVar2.setGrip("nasu"); |
|
75 |
|
76 localVar3.setGrip({ type: "undefined" }); |
|
77 localVar4.setGrip({ type: "null" }); |
|
78 localVar5.setGrip({ type: "object", class: "Object" }); |
|
79 localVar6.setGrip({ type: "Infinity" }); |
|
80 localVar7.setGrip({ type: "-Infinity" }); |
|
81 localVar8.setGrip({ type: "NaN" }); |
|
82 localVar9.setGrip({ type: "-0" }); |
|
83 |
|
84 localVar5.addItems({ |
|
85 someProp0: { value: 42, enumerable: true }, |
|
86 someProp1: { value: true, enumerable: true }, |
|
87 someProp2: { value: "nasu", enumerable: true }, |
|
88 someProp3: { value: { type: "undefined" }, enumerable: true }, |
|
89 someProp4: { value: { type: "null" }, enumerable: true }, |
|
90 someProp5: { value: { type: "object", class: "Object" }, enumerable: true }, |
|
91 someProp6: { value: { type: "Infinity" }, enumerable: true }, |
|
92 someProp7: { value: { type: "-Infinity" }, enumerable: true }, |
|
93 someProp8: { value: { type: "NaN" }, enumerable: true }, |
|
94 someProp9: { value: { type: "-0" }, enumerable: true }, |
|
95 someUndefined: { |
|
96 get: { type: "undefined" }, |
|
97 set: { type: "undefined" }, |
|
98 enumerable: true |
|
99 }, |
|
100 someAccessor: { |
|
101 get: { type: "object", class: "Function" }, |
|
102 set: { type: "undefined" }, |
|
103 enumerable: true |
|
104 } |
|
105 }); |
|
106 |
|
107 localVar5.get("someProp5").addItems({ |
|
108 someProp0: { value: 42, enumerable: true }, |
|
109 someProp1: { value: true, enumerable: true }, |
|
110 someProp2: { value: "nasu", enumerable: true }, |
|
111 someProp3: { value: { type: "undefined" }, enumerable: true }, |
|
112 someProp4: { value: { type: "null" }, enumerable: true }, |
|
113 someProp5: { value: { type: "object", class: "Object" }, enumerable: true }, |
|
114 someProp6: { value: { type: "Infinity" }, enumerable: true }, |
|
115 someProp7: { value: { type: "-Infinity" }, enumerable: true }, |
|
116 someProp8: { value: { type: "NaN" }, enumerable: true }, |
|
117 someProp9: { value: { type: "-0" }, enumerable: true }, |
|
118 someUndefined: { |
|
119 get: { type: "undefined" }, |
|
120 set: { type: "undefined" }, |
|
121 enumerable: true |
|
122 }, |
|
123 someAccessor: { |
|
124 get: { type: "object", class: "Function" }, |
|
125 set: { type: "undefined" }, |
|
126 enumerable: true |
|
127 } |
|
128 }); |
|
129 |
|
130 is(globalScope.target.querySelector(".enum").childNodes.length, 0, |
|
131 "The globalScope doesn't contain all the created enumerable variable elements."); |
|
132 is(globalScope.target.querySelector(".nonenum").childNodes.length, 2, |
|
133 "The globalScope doesn't contain all the created non-enumerable variable elements."); |
|
134 |
|
135 is(localScope.target.querySelector(".enum").childNodes.length, 0, |
|
136 "The localScope doesn't contain all the created enumerable variable elements."); |
|
137 is(localScope.target.querySelector(".nonenum").childNodes.length, 10, |
|
138 "The localScope doesn't contain all the created non-enumerable variable elements."); |
|
139 |
|
140 is(localVar5.target.querySelector(".enum").childNodes.length, 12, |
|
141 "The localVar5 doesn't contain all the created enumerable properties."); |
|
142 is(localVar5.target.querySelector(".nonenum").childNodes.length, 0, |
|
143 "The localVar5 doesn't contain all the created non-enumerable properties."); |
|
144 |
|
145 is(localVar5.get("someProp5").target.querySelector(".enum").childNodes.length, 12, |
|
146 "The localVar5.someProp5 doesn't contain all the created enumerable properties."); |
|
147 is(localVar5.get("someProp5").target.querySelector(".nonenum").childNodes.length, 0, |
|
148 "The localVar5.someProp5 doesn't contain all the created non-enumerable properties."); |
|
149 |
|
150 is(windowVar.target.querySelector(".value").getAttribute("value"), "Window", |
|
151 "The grip information for the windowVar wasn't set correctly."); |
|
152 is(documentVar.target.querySelector(".value").getAttribute("value"), "HTMLDocument", |
|
153 "The grip information for the documentVar wasn't set correctly."); |
|
154 |
|
155 is(localVar0.target.querySelector(".value").getAttribute("value"), "42", |
|
156 "The grip information for the localVar0 wasn't set correctly."); |
|
157 is(localVar1.target.querySelector(".value").getAttribute("value"), "true", |
|
158 "The grip information for the localVar1 wasn't set correctly."); |
|
159 is(localVar2.target.querySelector(".value").getAttribute("value"), "\"nasu\"", |
|
160 "The grip information for the localVar2 wasn't set correctly."); |
|
161 is(localVar3.target.querySelector(".value").getAttribute("value"), "undefined", |
|
162 "The grip information for the localVar3 wasn't set correctly."); |
|
163 is(localVar4.target.querySelector(".value").getAttribute("value"), "null", |
|
164 "The grip information for the localVar4 wasn't set correctly."); |
|
165 is(localVar5.target.querySelector(".value").getAttribute("value"), "Object", |
|
166 "The grip information for the localVar5 wasn't set correctly."); |
|
167 is(localVar6.target.querySelector(".value").getAttribute("value"), "Infinity", |
|
168 "The grip information for the localVar6 wasn't set correctly."); |
|
169 is(localVar7.target.querySelector(".value").getAttribute("value"), "-Infinity", |
|
170 "The grip information for the localVar7 wasn't set correctly."); |
|
171 is(localVar8.target.querySelector(".value").getAttribute("value"), "NaN", |
|
172 "The grip information for the localVar8 wasn't set correctly."); |
|
173 is(localVar9.target.querySelector(".value").getAttribute("value"), "-0", |
|
174 "The grip information for the localVar9 wasn't set correctly."); |
|
175 |
|
176 is(localVar5.get("someProp0").target.querySelector(".value").getAttribute("value"), "42", |
|
177 "The grip information for the someProp0 wasn't set correctly."); |
|
178 is(localVar5.get("someProp1").target.querySelector(".value").getAttribute("value"), "true", |
|
179 "The grip information for the someProp1 wasn't set correctly."); |
|
180 is(localVar5.get("someProp2").target.querySelector(".value").getAttribute("value"), "\"nasu\"", |
|
181 "The grip information for the someProp2 wasn't set correctly."); |
|
182 is(localVar5.get("someProp3").target.querySelector(".value").getAttribute("value"), "undefined", |
|
183 "The grip information for the someProp3 wasn't set correctly."); |
|
184 is(localVar5.get("someProp4").target.querySelector(".value").getAttribute("value"), "null", |
|
185 "The grip information for the someProp4 wasn't set correctly."); |
|
186 is(localVar5.get("someProp5").target.querySelector(".value").getAttribute("value"), "Object", |
|
187 "The grip information for the someProp5 wasn't set correctly."); |
|
188 is(localVar5.get("someProp6").target.querySelector(".value").getAttribute("value"), "Infinity", |
|
189 "The grip information for the someProp6 wasn't set correctly."); |
|
190 is(localVar5.get("someProp7").target.querySelector(".value").getAttribute("value"), "-Infinity", |
|
191 "The grip information for the someProp7 wasn't set correctly."); |
|
192 is(localVar5.get("someProp8").target.querySelector(".value").getAttribute("value"), "NaN", |
|
193 "The grip information for the someProp8 wasn't set correctly."); |
|
194 is(localVar5.get("someProp9").target.querySelector(".value").getAttribute("value"), "-0", |
|
195 "The grip information for the someProp9 wasn't set correctly."); |
|
196 is(localVar5.get("someUndefined").target.querySelector(".value").getAttribute("value"), "", |
|
197 "The grip information for the someUndefined wasn't set correctly."); |
|
198 is(localVar5.get("someAccessor").target.querySelector(".value").getAttribute("value"), "", |
|
199 "The grip information for the someAccessor wasn't set correctly."); |
|
200 |
|
201 is(localVar5.get("someProp5").get("someProp0").target.querySelector(".value").getAttribute("value"), "42", |
|
202 "The grip information for the sub-someProp0 wasn't set correctly."); |
|
203 is(localVar5.get("someProp5").get("someProp1").target.querySelector(".value").getAttribute("value"), "true", |
|
204 "The grip information for the sub-someProp1 wasn't set correctly."); |
|
205 is(localVar5.get("someProp5").get("someProp2").target.querySelector(".value").getAttribute("value"), "\"nasu\"", |
|
206 "The grip information for the sub-someProp2 wasn't set correctly."); |
|
207 is(localVar5.get("someProp5").get("someProp3").target.querySelector(".value").getAttribute("value"), "undefined", |
|
208 "The grip information for the sub-someProp3 wasn't set correctly."); |
|
209 is(localVar5.get("someProp5").get("someProp4").target.querySelector(".value").getAttribute("value"), "null", |
|
210 "The grip information for the sub-someProp4 wasn't set correctly."); |
|
211 is(localVar5.get("someProp5").get("someProp5").target.querySelector(".value").getAttribute("value"), "Object", |
|
212 "The grip information for the sub-someProp5 wasn't set correctly."); |
|
213 is(localVar5.get("someProp5").get("someProp6").target.querySelector(".value").getAttribute("value"), "Infinity", |
|
214 "The grip information for the sub-someProp6 wasn't set correctly."); |
|
215 is(localVar5.get("someProp5").get("someProp7").target.querySelector(".value").getAttribute("value"), "-Infinity", |
|
216 "The grip information for the sub-someProp7 wasn't set correctly."); |
|
217 is(localVar5.get("someProp5").get("someProp8").target.querySelector(".value").getAttribute("value"), "NaN", |
|
218 "The grip information for the sub-someProp8 wasn't set correctly."); |
|
219 is(localVar5.get("someProp5").get("someProp9").target.querySelector(".value").getAttribute("value"), "-0", |
|
220 "The grip information for the sub-someProp9 wasn't set correctly."); |
|
221 is(localVar5.get("someProp5").get("someUndefined").target.querySelector(".value").getAttribute("value"), "", |
|
222 "The grip information for the sub-someUndefined wasn't set correctly."); |
|
223 is(localVar5.get("someProp5").get("someAccessor").target.querySelector(".value").getAttribute("value"), "", |
|
224 "The grip information for the sub-someAccessor wasn't set correctly."); |
|
225 |
|
226 closeDebuggerAndFinish(aPanel); |
|
227 }); |
|
228 } |