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