|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that the variables view displays the right variables and |
|
6 * properties when debugger is paused. |
|
7 */ |
|
8 |
|
9 const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
|
10 |
|
11 let gTab, gDebuggee, gPanel, gDebugger; |
|
12 let gVariables; |
|
13 |
|
14 function test() { |
|
15 // Debug test slaves are a bit slow at this test. |
|
16 requestLongerTimeout(2); |
|
17 |
|
18 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
|
19 gTab = aTab; |
|
20 gDebuggee = aDebuggee; |
|
21 gPanel = aPanel; |
|
22 gDebugger = gPanel.panelWin; |
|
23 gVariables = gDebugger.DebuggerView.Variables; |
|
24 |
|
25 waitForSourceAndCaretAndScopes(gPanel, ".html", 24) |
|
26 .then(testScopeVariables) |
|
27 .then(testArgumentsProperties) |
|
28 .then(testSimpleObject) |
|
29 .then(testComplexObject) |
|
30 .then(testArgumentObject) |
|
31 .then(testInnerArgumentObject) |
|
32 .then(testGetterSetterObject) |
|
33 .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
|
34 .then(null, aError => { |
|
35 ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
|
36 }); |
|
37 |
|
38 EventUtils.sendMouseEvent({ type: "click" }, |
|
39 gDebuggee.document.querySelector("button"), |
|
40 gDebuggee); |
|
41 }); |
|
42 } |
|
43 |
|
44 function testScopeVariables() { |
|
45 let localScope = gVariables.getScopeAtIndex(0); |
|
46 is(localScope.expanded, true, |
|
47 "The local scope should be expanded by default."); |
|
48 |
|
49 let localEnums = localScope.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
50 let localNonEnums = localScope.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
51 |
|
52 is(localEnums.length, 12, |
|
53 "The local scope should contain all the created enumerable elements."); |
|
54 is(localNonEnums.length, 0, |
|
55 "The local scope should contain all the created non-enumerable elements."); |
|
56 |
|
57 is(localEnums[0].querySelector(".name").getAttribute("value"), "this", |
|
58 "Should have the right property name for 'this'."); |
|
59 is(localEnums[0].querySelector(".value").getAttribute("value"), |
|
60 "Window \u2192 doc_frame-parameters.html", |
|
61 "Should have the right property value for 'this'."); |
|
62 ok(localEnums[0].querySelector(".value").className.contains("token-other"), |
|
63 "Should have the right token class for 'this'."); |
|
64 |
|
65 is(localEnums[1].querySelector(".name").getAttribute("value"), "aArg", |
|
66 "Should have the right property name for 'aArg'."); |
|
67 is(localEnums[1].querySelector(".value").getAttribute("value"), "Object", |
|
68 "Should have the right property value for 'aArg'."); |
|
69 ok(localEnums[1].querySelector(".value").className.contains("token-other"), |
|
70 "Should have the right token class for 'aArg'."); |
|
71 |
|
72 is(localEnums[2].querySelector(".name").getAttribute("value"), "bArg", |
|
73 "Should have the right property name for 'bArg'."); |
|
74 is(localEnums[2].querySelector(".value").getAttribute("value"), "\"beta\"", |
|
75 "Should have the right property value for 'bArg'."); |
|
76 ok(localEnums[2].querySelector(".value").className.contains("token-string"), |
|
77 "Should have the right token class for 'bArg'."); |
|
78 |
|
79 is(localEnums[3].querySelector(".name").getAttribute("value"), "cArg", |
|
80 "Should have the right property name for 'cArg'."); |
|
81 is(localEnums[3].querySelector(".value").getAttribute("value"), "3", |
|
82 "Should have the right property value for 'cArg'."); |
|
83 ok(localEnums[3].querySelector(".value").className.contains("token-number"), |
|
84 "Should have the right token class for 'cArg'."); |
|
85 |
|
86 is(localEnums[4].querySelector(".name").getAttribute("value"), "dArg", |
|
87 "Should have the right property name for 'dArg'."); |
|
88 is(localEnums[4].querySelector(".value").getAttribute("value"), "false", |
|
89 "Should have the right property value for 'dArg'."); |
|
90 ok(localEnums[4].querySelector(".value").className.contains("token-boolean"), |
|
91 "Should have the right token class for 'dArg'."); |
|
92 |
|
93 is(localEnums[5].querySelector(".name").getAttribute("value"), "eArg", |
|
94 "Should have the right property name for 'eArg'."); |
|
95 is(localEnums[5].querySelector(".value").getAttribute("value"), "null", |
|
96 "Should have the right property value for 'eArg'."); |
|
97 ok(localEnums[5].querySelector(".value").className.contains("token-null"), |
|
98 "Should have the right token class for 'eArg'."); |
|
99 |
|
100 is(localEnums[6].querySelector(".name").getAttribute("value"), "fArg", |
|
101 "Should have the right property name for 'fArg'."); |
|
102 is(localEnums[6].querySelector(".value").getAttribute("value"), "undefined", |
|
103 "Should have the right property value for 'fArg'."); |
|
104 ok(localEnums[6].querySelector(".value").className.contains("token-undefined"), |
|
105 "Should have the right token class for 'fArg'."); |
|
106 |
|
107 is(localEnums[7].querySelector(".name").getAttribute("value"), "a", |
|
108 "Should have the right property name for 'a'."); |
|
109 is(localEnums[7].querySelector(".value").getAttribute("value"), "1", |
|
110 "Should have the right property value for 'a'."); |
|
111 ok(localEnums[7].querySelector(".value").className.contains("token-number"), |
|
112 "Should have the right token class for 'a'."); |
|
113 |
|
114 is(localEnums[8].querySelector(".name").getAttribute("value"), "arguments", |
|
115 "Should have the right property name for 'arguments'."); |
|
116 is(localEnums[8].querySelector(".value").getAttribute("value"), "Arguments", |
|
117 "Should have the right property value for 'arguments'."); |
|
118 ok(localEnums[8].querySelector(".value").className.contains("token-other"), |
|
119 "Should have the right token class for 'arguments'."); |
|
120 |
|
121 is(localEnums[9].querySelector(".name").getAttribute("value"), "b", |
|
122 "Should have the right property name for 'b'."); |
|
123 is(localEnums[9].querySelector(".value").getAttribute("value"), "Object", |
|
124 "Should have the right property value for 'b'."); |
|
125 ok(localEnums[9].querySelector(".value").className.contains("token-other"), |
|
126 "Should have the right token class for 'b'."); |
|
127 |
|
128 is(localEnums[10].querySelector(".name").getAttribute("value"), "c", |
|
129 "Should have the right property name for 'c'."); |
|
130 is(localEnums[10].querySelector(".value").getAttribute("value"), "Object", |
|
131 "Should have the right property value for 'c'."); |
|
132 ok(localEnums[10].querySelector(".value").className.contains("token-other"), |
|
133 "Should have the right token class for 'c'."); |
|
134 |
|
135 is(localEnums[11].querySelector(".name").getAttribute("value"), "myVar", |
|
136 "Should have the right property name for 'myVar'."); |
|
137 is(localEnums[11].querySelector(".value").getAttribute("value"), "Object", |
|
138 "Should have the right property value for 'myVar'."); |
|
139 ok(localEnums[11].querySelector(".value").className.contains("token-other"), |
|
140 "Should have the right token class for 'myVar'."); |
|
141 } |
|
142 |
|
143 function testArgumentsProperties() { |
|
144 let deferred = promise.defer(); |
|
145 |
|
146 let argsVar = gVariables.getScopeAtIndex(0).get("arguments"); |
|
147 is(argsVar.expanded, false, |
|
148 "The 'arguments' variable should not be expanded by default."); |
|
149 |
|
150 let argsEnums = argsVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
151 let argsNonEnums = argsVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
152 |
|
153 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
154 is(argsEnums.length, 5, |
|
155 "The 'arguments' variable should contain all the created enumerable elements."); |
|
156 is(argsNonEnums.length, 3, |
|
157 "The 'arguments' variable should contain all the created non-enumerable elements."); |
|
158 |
|
159 is(argsEnums[0].querySelector(".name").getAttribute("value"), "0", |
|
160 "Should have the right property name for '0'."); |
|
161 is(argsEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
162 "Should have the right property value for '0'."); |
|
163 ok(argsEnums[0].querySelector(".value").className.contains("token-other"), |
|
164 "Should have the right token class for '0'."); |
|
165 |
|
166 is(argsEnums[1].querySelector(".name").getAttribute("value"), "1", |
|
167 "Should have the right property name for '1'."); |
|
168 is(argsEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
|
169 "Should have the right property value for '1'."); |
|
170 ok(argsEnums[1].querySelector(".value").className.contains("token-string"), |
|
171 "Should have the right token class for '1'."); |
|
172 |
|
173 is(argsEnums[2].querySelector(".name").getAttribute("value"), "2", |
|
174 "Should have the right property name for '2'."); |
|
175 is(argsEnums[2].querySelector(".value").getAttribute("value"), "3", |
|
176 "Should have the right property name for '2'."); |
|
177 ok(argsEnums[2].querySelector(".value").className.contains("token-number"), |
|
178 "Should have the right token class for '2'."); |
|
179 |
|
180 is(argsEnums[3].querySelector(".name").getAttribute("value"), "3", |
|
181 "Should have the right property name for '3'."); |
|
182 is(argsEnums[3].querySelector(".value").getAttribute("value"), "false", |
|
183 "Should have the right property value for '3'."); |
|
184 ok(argsEnums[3].querySelector(".value").className.contains("token-boolean"), |
|
185 "Should have the right token class for '3'."); |
|
186 |
|
187 is(argsEnums[4].querySelector(".name").getAttribute("value"), "4", |
|
188 "Should have the right property name for '4'."); |
|
189 is(argsEnums[4].querySelector(".value").getAttribute("value"), "null", |
|
190 "Should have the right property name for '4'."); |
|
191 ok(argsEnums[4].querySelector(".value").className.contains("token-null"), |
|
192 "Should have the right token class for '4'."); |
|
193 |
|
194 is(argsNonEnums[0].querySelector(".name").getAttribute("value"), "callee", |
|
195 "Should have the right property name for 'callee'."); |
|
196 is(argsNonEnums[0].querySelector(".value").getAttribute("value"), |
|
197 "test(aArg,bArg,cArg,dArg,eArg,fArg)", |
|
198 "Should have the right property name for 'callee'."); |
|
199 ok(argsNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
200 "Should have the right token class for 'callee'."); |
|
201 |
|
202 is(argsNonEnums[1].querySelector(".name").getAttribute("value"), "length", |
|
203 "Should have the right property name for 'length'."); |
|
204 is(argsNonEnums[1].querySelector(".value").getAttribute("value"), "5", |
|
205 "Should have the right property value for 'length'."); |
|
206 ok(argsNonEnums[1].querySelector(".value").className.contains("token-number"), |
|
207 "Should have the right token class for 'length'."); |
|
208 |
|
209 is(argsNonEnums[2].querySelector(".name").getAttribute("value"), "__proto__", |
|
210 "Should have the right property name for '__proto__'."); |
|
211 is(argsNonEnums[2].querySelector(".value").getAttribute("value"), "Object", |
|
212 "Should have the right property value for '__proto__'."); |
|
213 ok(argsNonEnums[2].querySelector(".value").className.contains("token-other"), |
|
214 "Should have the right token class for '__proto__'."); |
|
215 |
|
216 deferred.resolve(); |
|
217 }); |
|
218 |
|
219 argsVar.expand(); |
|
220 return deferred.promise; |
|
221 } |
|
222 |
|
223 function testSimpleObject() { |
|
224 let deferred = promise.defer(); |
|
225 |
|
226 let bVar = gVariables.getScopeAtIndex(0).get("b"); |
|
227 is(bVar.expanded, false, |
|
228 "The 'b' variable should not be expanded by default."); |
|
229 |
|
230 let bEnums = bVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
231 let bNonEnums = bVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
232 |
|
233 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
234 is(bEnums.length, 1, |
|
235 "The 'b' variable should contain all the created enumerable elements."); |
|
236 is(bNonEnums.length, 1, |
|
237 "The 'b' variable should contain all the created non-enumerable elements."); |
|
238 |
|
239 is(bEnums[0].querySelector(".name").getAttribute("value"), "a", |
|
240 "Should have the right property name for 'a'."); |
|
241 is(bEnums[0].querySelector(".value").getAttribute("value"), "1", |
|
242 "Should have the right property value for 'a'."); |
|
243 ok(bEnums[0].querySelector(".value").className.contains("token-number"), |
|
244 "Should have the right token class for 'a'."); |
|
245 |
|
246 is(bNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
|
247 "Should have the right property name for '__proto__'."); |
|
248 is(bNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
249 "Should have the right property value for '__proto__'."); |
|
250 ok(bNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
251 "Should have the right token class for '__proto__'."); |
|
252 |
|
253 deferred.resolve(); |
|
254 }); |
|
255 |
|
256 bVar.expand(); |
|
257 return deferred.promise; |
|
258 } |
|
259 |
|
260 function testComplexObject() { |
|
261 let deferred = promise.defer(); |
|
262 |
|
263 let cVar = gVariables.getScopeAtIndex(0).get("c"); |
|
264 is(cVar.expanded, false, |
|
265 "The 'c' variable should not be expanded by default."); |
|
266 |
|
267 let cEnums = cVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
268 let cNonEnums = cVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
269 |
|
270 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
271 is(cEnums.length, 6, |
|
272 "The 'c' variable should contain all the created enumerable elements."); |
|
273 is(cNonEnums.length, 1, |
|
274 "The 'c' variable should contain all the created non-enumerable elements."); |
|
275 |
|
276 is(cEnums[0].querySelector(".name").getAttribute("value"), "a", |
|
277 "Should have the right property name for 'a'."); |
|
278 is(cEnums[0].querySelector(".value").getAttribute("value"), "1", |
|
279 "Should have the right property value for 'a'."); |
|
280 ok(cEnums[0].querySelector(".value").className.contains("token-number"), |
|
281 "Should have the right token class for 'a'."); |
|
282 |
|
283 is(cEnums[1].querySelector(".name").getAttribute("value"), "b", |
|
284 "Should have the right property name for 'b'."); |
|
285 is(cEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
|
286 "Should have the right property value for 'b'."); |
|
287 ok(cEnums[1].querySelector(".value").className.contains("token-string"), |
|
288 "Should have the right token class for 'b'."); |
|
289 |
|
290 is(cEnums[2].querySelector(".name").getAttribute("value"), "c", |
|
291 "Should have the right property name for 'c'."); |
|
292 is(cEnums[2].querySelector(".value").getAttribute("value"), "3", |
|
293 "Should have the right property value for 'c'."); |
|
294 ok(cEnums[2].querySelector(".value").className.contains("token-number"), |
|
295 "Should have the right token class for 'c'."); |
|
296 |
|
297 is(cEnums[3].querySelector(".name").getAttribute("value"), "d", |
|
298 "Should have the right property name for 'd'."); |
|
299 is(cEnums[3].querySelector(".value").getAttribute("value"), "false", |
|
300 "Should have the right property value for 'd'."); |
|
301 ok(cEnums[3].querySelector(".value").className.contains("token-boolean"), |
|
302 "Should have the right token class for 'd'."); |
|
303 |
|
304 is(cEnums[4].querySelector(".name").getAttribute("value"), "e", |
|
305 "Should have the right property name for 'e'."); |
|
306 is(cEnums[4].querySelector(".value").getAttribute("value"), "null", |
|
307 "Should have the right property value for 'e'."); |
|
308 ok(cEnums[4].querySelector(".value").className.contains("token-null"), |
|
309 "Should have the right token class for 'e'."); |
|
310 |
|
311 is(cEnums[5].querySelector(".name").getAttribute("value"), "f", |
|
312 "Should have the right property name for 'f'."); |
|
313 is(cEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
|
314 "Should have the right property value for 'f'."); |
|
315 ok(cEnums[5].querySelector(".value").className.contains("token-undefined"), |
|
316 "Should have the right token class for 'f'."); |
|
317 |
|
318 is(cNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
|
319 "Should have the right property name for '__proto__'."); |
|
320 is(cNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
321 "Should have the right property value for '__proto__'."); |
|
322 ok(cNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
323 "Should have the right token class for '__proto__'."); |
|
324 |
|
325 deferred.resolve(); |
|
326 }); |
|
327 |
|
328 cVar.expand(); |
|
329 return deferred.promise; |
|
330 } |
|
331 |
|
332 function testArgumentObject() { |
|
333 let deferred = promise.defer(); |
|
334 |
|
335 let argVar = gVariables.getScopeAtIndex(0).get("aArg"); |
|
336 is(argVar.expanded, false, |
|
337 "The 'aArg' variable should not be expanded by default."); |
|
338 |
|
339 let argEnums = argVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
340 let argNonEnums = argVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
341 |
|
342 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
343 is(argEnums.length, 6, |
|
344 "The 'aArg' variable should contain all the created enumerable elements."); |
|
345 is(argNonEnums.length, 1, |
|
346 "The 'aArg' variable should contain all the created non-enumerable elements."); |
|
347 |
|
348 is(argEnums[0].querySelector(".name").getAttribute("value"), "a", |
|
349 "Should have the right property name for 'a'."); |
|
350 is(argEnums[0].querySelector(".value").getAttribute("value"), "1", |
|
351 "Should have the right property value for 'a'."); |
|
352 ok(argEnums[0].querySelector(".value").className.contains("token-number"), |
|
353 "Should have the right token class for 'a'."); |
|
354 |
|
355 is(argEnums[1].querySelector(".name").getAttribute("value"), "b", |
|
356 "Should have the right property name for 'b'."); |
|
357 is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
|
358 "Should have the right property value for 'b'."); |
|
359 ok(argEnums[1].querySelector(".value").className.contains("token-string"), |
|
360 "Should have the right token class for 'b'."); |
|
361 |
|
362 is(argEnums[2].querySelector(".name").getAttribute("value"), "c", |
|
363 "Should have the right property name for 'c'."); |
|
364 is(argEnums[2].querySelector(".value").getAttribute("value"), "3", |
|
365 "Should have the right property value for 'c'."); |
|
366 ok(argEnums[2].querySelector(".value").className.contains("token-number"), |
|
367 "Should have the right token class for 'c'."); |
|
368 |
|
369 is(argEnums[3].querySelector(".name").getAttribute("value"), "d", |
|
370 "Should have the right property name for 'd'."); |
|
371 is(argEnums[3].querySelector(".value").getAttribute("value"), "false", |
|
372 "Should have the right property value for 'd'."); |
|
373 ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), |
|
374 "Should have the right token class for 'd'."); |
|
375 |
|
376 is(argEnums[4].querySelector(".name").getAttribute("value"), "e", |
|
377 "Should have the right property name for 'e'."); |
|
378 is(argEnums[4].querySelector(".value").getAttribute("value"), "null", |
|
379 "Should have the right property value for 'e'."); |
|
380 ok(argEnums[4].querySelector(".value").className.contains("token-null"), |
|
381 "Should have the right token class for 'e'."); |
|
382 |
|
383 is(argEnums[5].querySelector(".name").getAttribute("value"), "f", |
|
384 "Should have the right property name for 'f'."); |
|
385 is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
|
386 "Should have the right property value for 'f'."); |
|
387 ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), |
|
388 "Should have the right token class for 'f'."); |
|
389 |
|
390 is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
|
391 "Should have the right property name for '__proto__'."); |
|
392 is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
393 "Should have the right property value for '__proto__'."); |
|
394 ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
395 "Should have the right token class for '__proto__'."); |
|
396 |
|
397 deferred.resolve(); |
|
398 }); |
|
399 |
|
400 argVar.expand(); |
|
401 return deferred.promise; |
|
402 } |
|
403 |
|
404 function testInnerArgumentObject() { |
|
405 let deferred = promise.defer(); |
|
406 |
|
407 let argProp = gVariables.getScopeAtIndex(0).get("arguments").get("0"); |
|
408 is(argProp.expanded, false, |
|
409 "The 'arguments[0]' property should not be expanded by default."); |
|
410 |
|
411 let argEnums = argProp.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
412 let argNonEnums = argProp.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
413 |
|
414 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
415 is(argEnums.length, 6, |
|
416 "The 'arguments[0]' property should contain all the created enumerable elements."); |
|
417 is(argNonEnums.length, 1, |
|
418 "The 'arguments[0]' property should contain all the created non-enumerable elements."); |
|
419 |
|
420 is(argEnums[0].querySelector(".name").getAttribute("value"), "a", |
|
421 "Should have the right property name for 'a'."); |
|
422 is(argEnums[0].querySelector(".value").getAttribute("value"), "1", |
|
423 "Should have the right property value for 'a'."); |
|
424 ok(argEnums[0].querySelector(".value").className.contains("token-number"), |
|
425 "Should have the right token class for 'a'."); |
|
426 |
|
427 is(argEnums[1].querySelector(".name").getAttribute("value"), "b", |
|
428 "Should have the right property name for 'b'."); |
|
429 is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
|
430 "Should have the right property value for 'b'."); |
|
431 ok(argEnums[1].querySelector(".value").className.contains("token-string"), |
|
432 "Should have the right token class for 'b'."); |
|
433 |
|
434 is(argEnums[2].querySelector(".name").getAttribute("value"), "c", |
|
435 "Should have the right property name for 'c'."); |
|
436 is(argEnums[2].querySelector(".value").getAttribute("value"), "3", |
|
437 "Should have the right property value for 'c'."); |
|
438 ok(argEnums[2].querySelector(".value").className.contains("token-number"), |
|
439 "Should have the right token class for 'c'."); |
|
440 |
|
441 is(argEnums[3].querySelector(".name").getAttribute("value"), "d", |
|
442 "Should have the right property name for 'd'."); |
|
443 is(argEnums[3].querySelector(".value").getAttribute("value"), "false", |
|
444 "Should have the right property value for 'd'."); |
|
445 ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), |
|
446 "Should have the right token class for 'd'."); |
|
447 |
|
448 is(argEnums[4].querySelector(".name").getAttribute("value"), "e", |
|
449 "Should have the right property name for 'e'."); |
|
450 is(argEnums[4].querySelector(".value").getAttribute("value"), "null", |
|
451 "Should have the right property value for 'e'."); |
|
452 ok(argEnums[4].querySelector(".value").className.contains("token-null"), |
|
453 "Should have the right token class for 'e'."); |
|
454 |
|
455 is(argEnums[5].querySelector(".name").getAttribute("value"), "f", |
|
456 "Should have the right property name for 'f'."); |
|
457 is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
|
458 "Should have the right property value for 'f'."); |
|
459 ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), |
|
460 "Should have the right token class for 'f'."); |
|
461 |
|
462 is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
|
463 "Should have the right property name for '__proto__'."); |
|
464 is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
465 "Should have the right property value for '__proto__'."); |
|
466 ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
467 "Should have the right token class for '__proto__'."); |
|
468 |
|
469 deferred.resolve(); |
|
470 }); |
|
471 |
|
472 argProp.expand(); |
|
473 return deferred.promise; |
|
474 } |
|
475 |
|
476 function testGetterSetterObject() { |
|
477 let deferred = promise.defer(); |
|
478 |
|
479 let myVar = gVariables.getScopeAtIndex(0).get("myVar"); |
|
480 is(myVar.expanded, false, |
|
481 "The myVar variable should not be expanded by default."); |
|
482 |
|
483 let myVarEnums = myVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
|
484 let myVarNonEnums = myVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
|
485 |
|
486 gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
|
487 is(myVarEnums.length, 2, |
|
488 "The myVar should contain all the created enumerable elements."); |
|
489 is(myVarNonEnums.length, 1, |
|
490 "The myVar should contain all the created non-enumerable elements."); |
|
491 |
|
492 is(myVarEnums[0].querySelector(".name").getAttribute("value"), "_prop", |
|
493 "Should have the right property name for '_prop'."); |
|
494 is(myVarEnums[0].querySelector(".value").getAttribute("value"), "42", |
|
495 "Should have the right property value for '_prop'."); |
|
496 ok(myVarEnums[0].querySelector(".value").className.contains("token-number"), |
|
497 "Should have the right token class for '_prop'."); |
|
498 |
|
499 is(myVarEnums[1].querySelector(".name").getAttribute("value"), "prop", |
|
500 "Should have the right property name for 'prop'."); |
|
501 is(myVarEnums[1].querySelector(".value").getAttribute("value"), "", |
|
502 "Should have the right property value for 'prop'."); |
|
503 ok(!myVarEnums[1].querySelector(".value").className.contains("token"), |
|
504 "Should have no token class for 'prop'."); |
|
505 |
|
506 is(myVarNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
|
507 "Should have the right property name for '__proto__'."); |
|
508 is(myVarNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
|
509 "Should have the right property value for '__proto__'."); |
|
510 ok(myVarNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
511 "Should have the right token class for '__proto__'."); |
|
512 |
|
513 let propEnums = myVarEnums[1].querySelector(".variables-view-element-details.enum").childNodes; |
|
514 let propNonEnums = myVarEnums[1].querySelector(".variables-view-element-details.nonenum").childNodes; |
|
515 |
|
516 is(propEnums.length, 0, |
|
517 "The propEnums should contain all the created enumerable elements."); |
|
518 is(propNonEnums.length, 2, |
|
519 "The propEnums should contain all the created non-enumerable elements."); |
|
520 |
|
521 is(propNonEnums[0].querySelector(".name").getAttribute("value"), "get", |
|
522 "Should have the right property name for 'get'."); |
|
523 is(propNonEnums[0].querySelector(".value").getAttribute("value"), |
|
524 "test/myVar.prop()", |
|
525 "Should have the right property value for 'get'."); |
|
526 ok(propNonEnums[0].querySelector(".value").className.contains("token-other"), |
|
527 "Should have the right token class for 'get'."); |
|
528 |
|
529 is(propNonEnums[1].querySelector(".name").getAttribute("value"), "set", |
|
530 "Should have the right property name for 'set'."); |
|
531 is(propNonEnums[1].querySelector(".value").getAttribute("value"), |
|
532 "test/myVar.prop(val)", |
|
533 "Should have the right property value for 'set'."); |
|
534 ok(propNonEnums[1].querySelector(".value").className.contains("token-other"), |
|
535 "Should have the right token class for 'set'."); |
|
536 |
|
537 deferred.resolve(); |
|
538 }); |
|
539 |
|
540 myVar.expand(); |
|
541 return deferred.promise; |
|
542 } |
|
543 |
|
544 registerCleanupFunction(function() { |
|
545 gTab = null; |
|
546 gDebuggee = null; |
|
547 gPanel = null; |
|
548 gDebugger = null; |
|
549 gVariables = null; |
|
550 }); |