michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Tests that recursively creating properties in the variables view works michael@0: * as expected. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: function test() { michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: let variables = aPanel.panelWin.DebuggerView.Variables; michael@0: let testScope = variables.addScope("test"); michael@0: michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 1, michael@0: "One enumerable container should be present in the scope."); michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, michael@0: "One non-enumerable container should be present in the scope."); michael@0: is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "No enumerable variables should be present in the scope."); michael@0: is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No non-enumerable variables should be present in the scope."); michael@0: michael@0: testScope.addItem("something", { michael@0: value: { michael@0: type: "object", michael@0: class: "Object" michael@0: }, michael@0: enumerable: true michael@0: }); michael@0: michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 2, michael@0: "Two enumerable containers should be present in the tree."); michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 2, michael@0: "Two non-enumerable containers should be present in the tree."); michael@0: michael@0: is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, michael@0: "A new enumerable variable should have been added in the scope."); michael@0: is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No new non-enumerable variables should have been added in the scope."); michael@0: michael@0: let testVar = testScope.get("something"); michael@0: ok(testVar, michael@0: "The added variable should be accessible from the scope."); michael@0: michael@0: is(testVar.target.querySelectorAll(".variables-view-element-details.enum").length, 1, michael@0: "One enumerable container should be present in the variable."); michael@0: is(testVar.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, michael@0: "One non-enumerable container should be present in the variable."); michael@0: is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "No enumerable properties should be present in the variable."); michael@0: is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No non-enumerable properties should be present in the variable."); michael@0: michael@0: testVar.addItem("child", { michael@0: value: { michael@0: type: "object", michael@0: class: "Object" michael@0: }, michael@0: enumerable: true michael@0: }); michael@0: michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 3, michael@0: "Three enumerable containers should be present in the tree."); michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 3, michael@0: "Three non-enumerable containers should be present in the tree."); michael@0: michael@0: is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, michael@0: "A new enumerable property should have been added in the variable."); michael@0: is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No new non-enumerable properties should have been added in the variable."); michael@0: michael@0: let testChild = testVar.get("child"); michael@0: ok(testChild, michael@0: "The added property should be accessible from the variable."); michael@0: michael@0: is(testChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, michael@0: "One enumerable container should be present in the property."); michael@0: is(testChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, michael@0: "One non-enumerable container should be present in the property."); michael@0: is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "No enumerable sub-properties should be present in the property."); michael@0: is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No non-enumerable sub-properties should be present in the property."); michael@0: michael@0: testChild.addItem("grandChild", { michael@0: value: { michael@0: type: "object", michael@0: class: "Object" michael@0: }, michael@0: enumerable: true michael@0: }); michael@0: michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 4, michael@0: "Four enumerable containers should be present in the tree."); michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 4, michael@0: "Four non-enumerable containers should be present in the tree."); michael@0: michael@0: is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, michael@0: "A new enumerable sub-property should have been added in the property."); michael@0: is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No new non-enumerable sub-properties should have been added in the property."); michael@0: michael@0: let testGrandChild = testChild.get("grandChild"); michael@0: ok(testGrandChild, michael@0: "The added sub-property should be accessible from the property."); michael@0: michael@0: is(testGrandChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, michael@0: "One enumerable container should be present in the property."); michael@0: is(testGrandChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, michael@0: "One non-enumerable container should be present in the property."); michael@0: is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "No enumerable sub-properties should be present in the property."); michael@0: is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No non-enumerable sub-properties should be present in the property."); michael@0: michael@0: testGrandChild.addItem("granderChild", { michael@0: value: { michael@0: type: "object", michael@0: class: "Object" michael@0: }, michael@0: enumerable: true michael@0: }); michael@0: michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 5, michael@0: "Five enumerable containers should be present in the tree."); michael@0: is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 5, michael@0: "Five non-enumerable containers should be present in the tree."); michael@0: michael@0: is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, michael@0: "A new enumerable variable should have been added in the variable."); michael@0: is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No new non-enumerable variables should have been added in the variable."); michael@0: michael@0: let testGranderChild = testGrandChild.get("granderChild"); michael@0: ok(testGranderChild, michael@0: "The added sub-property should be accessible from the property."); michael@0: michael@0: is(testGranderChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, michael@0: "One enumerable container should be present in the property."); michael@0: is(testGranderChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, michael@0: "One non-enumerable container should be present in the property."); michael@0: is(testGranderChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, michael@0: "No enumerable sub-properties should be present in the property."); michael@0: is(testGranderChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, michael@0: "No non-enumerable sub-properties should be present in the property."); michael@0: michael@0: closeDebuggerAndFinish(aPanel); michael@0: }); michael@0: }