Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Tests that recursively creating properties in the variables view works
6 * as expected.
7 */
9 const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html";
11 function test() {
12 initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => {
13 let variables = aPanel.panelWin.DebuggerView.Variables;
14 let testScope = variables.addScope("test");
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.");
25 testScope.addItem("something", {
26 value: {
27 type: "object",
28 class: "Object"
29 },
30 enumerable: true
31 });
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.");
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.");
43 let testVar = testScope.get("something");
44 ok(testVar,
45 "The added variable should be accessible from the scope.");
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.");
56 testVar.addItem("child", {
57 value: {
58 type: "object",
59 class: "Object"
60 },
61 enumerable: true
62 });
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.");
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.");
74 let testChild = testVar.get("child");
75 ok(testChild,
76 "The added property should be accessible from the variable.");
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.");
87 testChild.addItem("grandChild", {
88 value: {
89 type: "object",
90 class: "Object"
91 },
92 enumerable: true
93 });
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.");
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.");
105 let testGrandChild = testChild.get("grandChild");
106 ok(testGrandChild,
107 "The added sub-property should be accessible from the property.");
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.");
118 testGrandChild.addItem("granderChild", {
119 value: {
120 type: "object",
121 class: "Object"
122 },
123 enumerable: true
124 });
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.");
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.");
136 let testGranderChild = testGrandChild.get("granderChild");
137 ok(testGranderChild,
138 "The added sub-property should be accessible from the property.");
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.");
149 closeDebuggerAndFinish(aPanel);
150 });
151 }