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