1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,151 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Tests that recursively creating properties in the variables view works 1.9 + * as expected. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; 1.13 + 1.14 +function test() { 1.15 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.16 + let variables = aPanel.panelWin.DebuggerView.Variables; 1.17 + let testScope = variables.addScope("test"); 1.18 + 1.19 + is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 1, 1.20 + "One enumerable container should be present in the scope."); 1.21 + is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, 1.22 + "One non-enumerable container should be present in the scope."); 1.23 + is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, 1.24 + "No enumerable variables should be present in the scope."); 1.25 + is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.26 + "No non-enumerable variables should be present in the scope."); 1.27 + 1.28 + testScope.addItem("something", { 1.29 + value: { 1.30 + type: "object", 1.31 + class: "Object" 1.32 + }, 1.33 + enumerable: true 1.34 + }); 1.35 + 1.36 + is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 2, 1.37 + "Two enumerable containers should be present in the tree."); 1.38 + is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 2, 1.39 + "Two non-enumerable containers should be present in the tree."); 1.40 + 1.41 + is(testScope.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, 1.42 + "A new enumerable variable should have been added in the scope."); 1.43 + is(testScope.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.44 + "No new non-enumerable variables should have been added in the scope."); 1.45 + 1.46 + let testVar = testScope.get("something"); 1.47 + ok(testVar, 1.48 + "The added variable should be accessible from the scope."); 1.49 + 1.50 + is(testVar.target.querySelectorAll(".variables-view-element-details.enum").length, 1, 1.51 + "One enumerable container should be present in the variable."); 1.52 + is(testVar.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, 1.53 + "One non-enumerable container should be present in the variable."); 1.54 + is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, 1.55 + "No enumerable properties should be present in the variable."); 1.56 + is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.57 + "No non-enumerable properties should be present in the variable."); 1.58 + 1.59 + testVar.addItem("child", { 1.60 + value: { 1.61 + type: "object", 1.62 + class: "Object" 1.63 + }, 1.64 + enumerable: true 1.65 + }); 1.66 + 1.67 + is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 3, 1.68 + "Three enumerable containers should be present in the tree."); 1.69 + is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 3, 1.70 + "Three non-enumerable containers should be present in the tree."); 1.71 + 1.72 + is(testVar.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, 1.73 + "A new enumerable property should have been added in the variable."); 1.74 + is(testVar.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.75 + "No new non-enumerable properties should have been added in the variable."); 1.76 + 1.77 + let testChild = testVar.get("child"); 1.78 + ok(testChild, 1.79 + "The added property should be accessible from the variable."); 1.80 + 1.81 + is(testChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, 1.82 + "One enumerable container should be present in the property."); 1.83 + is(testChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, 1.84 + "One non-enumerable container should be present in the property."); 1.85 + is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, 1.86 + "No enumerable sub-properties should be present in the property."); 1.87 + is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.88 + "No non-enumerable sub-properties should be present in the property."); 1.89 + 1.90 + testChild.addItem("grandChild", { 1.91 + value: { 1.92 + type: "object", 1.93 + class: "Object" 1.94 + }, 1.95 + enumerable: true 1.96 + }); 1.97 + 1.98 + is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 4, 1.99 + "Four enumerable containers should be present in the tree."); 1.100 + is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 4, 1.101 + "Four non-enumerable containers should be present in the tree."); 1.102 + 1.103 + is(testChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, 1.104 + "A new enumerable sub-property should have been added in the property."); 1.105 + is(testChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.106 + "No new non-enumerable sub-properties should have been added in the property."); 1.107 + 1.108 + let testGrandChild = testChild.get("grandChild"); 1.109 + ok(testGrandChild, 1.110 + "The added sub-property should be accessible from the property."); 1.111 + 1.112 + is(testGrandChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, 1.113 + "One enumerable container should be present in the property."); 1.114 + is(testGrandChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, 1.115 + "One non-enumerable container should be present in the property."); 1.116 + is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, 1.117 + "No enumerable sub-properties should be present in the property."); 1.118 + is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.119 + "No non-enumerable sub-properties should be present in the property."); 1.120 + 1.121 + testGrandChild.addItem("granderChild", { 1.122 + value: { 1.123 + type: "object", 1.124 + class: "Object" 1.125 + }, 1.126 + enumerable: true 1.127 + }); 1.128 + 1.129 + is(testScope.target.querySelectorAll(".variables-view-element-details.enum").length, 5, 1.130 + "Five enumerable containers should be present in the tree."); 1.131 + is(testScope.target.querySelectorAll(".variables-view-element-details.nonenum").length, 5, 1.132 + "Five non-enumerable containers should be present in the tree."); 1.133 + 1.134 + is(testGrandChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 1, 1.135 + "A new enumerable variable should have been added in the variable."); 1.136 + is(testGrandChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.137 + "No new non-enumerable variables should have been added in the variable."); 1.138 + 1.139 + let testGranderChild = testGrandChild.get("granderChild"); 1.140 + ok(testGranderChild, 1.141 + "The added sub-property should be accessible from the property."); 1.142 + 1.143 + is(testGranderChild.target.querySelectorAll(".variables-view-element-details.enum").length, 1, 1.144 + "One enumerable container should be present in the property."); 1.145 + is(testGranderChild.target.querySelectorAll(".variables-view-element-details.nonenum").length, 1, 1.146 + "One non-enumerable container should be present in the property."); 1.147 + is(testGranderChild.target.querySelector(".variables-view-element-details.enum").childNodes.length, 0, 1.148 + "No enumerable sub-properties should be present in the property."); 1.149 + is(testGranderChild.target.querySelector(".variables-view-element-details.nonenum").childNodes.length, 0, 1.150 + "No non-enumerable sub-properties should be present in the property."); 1.151 + 1.152 + closeDebuggerAndFinish(aPanel); 1.153 + }); 1.154 +}