browser/devtools/debugger/test/browser_dbg_variables-view-03.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:2c3f5991d56b
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Tests that recursively creating properties in the variables view works
6 * 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 is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 1,
17 "One enumerable container should be present in the scope.");
18 is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1,
19 "One non-enumerable container should be present in the scope.");
20 is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
21 "No enumerable variables should be present in the scope.");
22 is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
23 "No non-enumerable variables should be present in the scope.");
24
25 testScope.addItem("something", {
26 value: {
27 type: "object",
28 class: "Object"
29 },
30 enumerable: true
31 });
32
33 is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 2,
34 "Two enumerable containers should be present in the tree.");
35 is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 2,
36 "Two non-enumerable containers should be present in the tree.");
37
38 is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1,
39 "A new enumerable variable should have been added in the scope.");
40 is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
41 "No new non-enumerable variables should have been added in the scope.");
42
43 let testVar = testScope.get("something");
44 ok(testVar,
45 "The added variable should be accessible from the scope.");
46
47 is(testVar.target.querySelectorAll(".variables-view-element-details.enum").length, 1,
48 "One enumerable container should be present in the variable.");
49 is(testVar.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1,
50 "One non-enumerable container should be present in the variable.");
51 is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
52 "No enumerable properties should be present in the variable.");
53 is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
54 "No non-enumerable properties should be present in the variable.");
55
56 testVar.addItem("child", {
57 value: {
58 type: "object",
59 class: "Object"
60 },
61 enumerable: true
62 });
63
64 is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 3,
65 "Three enumerable containers should be present in the tree.");
66 is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 3,
67 "Three non-enumerable containers should be present in the tree.");
68
69 is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1,
70 "A new enumerable property should have been added in the variable.");
71 is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
72 "No new non-enumerable properties should have been added in the variable.");
73
74 let testChild = testVar.get("child");
75 ok(testChild,
76 "The added property should be accessible from the variable.");
77
78 is(testChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1,
79 "One enumerable container should be present in the property.");
80 is(testChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1,
81 "One non-enumerable container should be present in the property.");
82 is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
83 "No enumerable sub-properties should be present in the property.");
84 is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
85 "No non-enumerable sub-properties should be present in the property.");
86
87 testChild.addItem("grandChild", {
88 value: {
89 type: "object",
90 class: "Object"
91 },
92 enumerable: true
93 });
94
95 is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 4,
96 "Four enumerable containers should be present in the tree.");
97 is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 4,
98 "Four non-enumerable containers should be present in the tree.");
99
100 is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1,
101 "A new enumerable sub-property should have been added in the property.");
102 is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
103 "No new non-enumerable sub-properties should have been added in the property.");
104
105 let testGrandChild = testChild.get("grandChild");
106 ok(testGrandChild,
107 "The added sub-property should be accessible from the property.");
108
109 is(testGrandChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1,
110 "One enumerable container should be present in the property.");
111 is(testGrandChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1,
112 "One non-enumerable container should be present in the property.");
113 is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
114 "No enumerable sub-properties should be present in the property.");
115 is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
116 "No non-enumerable sub-properties should be present in the property.");
117
118 testGrandChild.addItem("granderChild", {
119 value: {
120 type: "object",
121 class: "Object"
122 },
123 enumerable: true
124 });
125
126 is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 5,
127 "Five enumerable containers should be present in the tree.");
128 is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 5,
129 "Five non-enumerable containers should be present in the tree.");
130
131 is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1,
132 "A new enumerable variable should have been added in the variable.");
133 is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
134 "No new non-enumerable variables should have been added in the variable.");
135
136 let testGranderChild = testGrandChild.get("granderChild");
137 ok(testGranderChild,
138 "The added sub-property should be accessible from the property.");
139
140 is(testGranderChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1,
141 "One enumerable container should be present in the property.");
142 is(testGranderChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1,
143 "One non-enumerable container should be present in the property.");
144 is(testGranderChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0,
145 "No enumerable sub-properties should be present in the property.");
146 is(testGranderChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0,
147 "No non-enumerable sub-properties should be present in the property.");
148
149 closeDebuggerAndFinish(aPanel);
150 });
151 }

mercurial