browser/devtools/debugger/test/browser_dbg_variables-view-data.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-data.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,611 @@
     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 + * Make sure that the variables view correctly populates itself
     1.9 + * when given some raw data.
    1.10 + */
    1.11 +
    1.12 +let gTab, gDebuggee, gPanel, gDebugger;
    1.13 +let gVariablesView, gScope, gVariable;
    1.14 +
    1.15 +function test() {
    1.16 +  initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => {
    1.17 +    gTab = aTab;
    1.18 +    gDebuggee = aDebuggee;
    1.19 +    gPanel = aPanel;
    1.20 +    gDebugger = gPanel.panelWin;
    1.21 +    gVariablesView = gDebugger.DebuggerView.Variables;
    1.22 +
    1.23 +    performTest();
    1.24 +  });
    1.25 +}
    1.26 +
    1.27 +function performTest() {
    1.28 +  let arr = [
    1.29 +    42,
    1.30 +    true,
    1.31 +    "nasu",
    1.32 +    undefined,
    1.33 +    null,
    1.34 +    [0, 1, 2],
    1.35 +    { prop1: 9, prop2: 8 }
    1.36 +  ];
    1.37 +
    1.38 +  let obj = {
    1.39 +    p0: 42,
    1.40 +    p1: true,
    1.41 +    p2: "nasu",
    1.42 +    p3: undefined,
    1.43 +    p4: null,
    1.44 +    p5: [3, 4, 5],
    1.45 +    p6: { prop1: 7, prop2: 6 },
    1.46 +    get p7() { return arr; },
    1.47 +    set p8(value) { arr[0] = value }
    1.48 +  };
    1.49 +
    1.50 +  let test = {
    1.51 +    someProp0: 42,
    1.52 +    someProp1: true,
    1.53 +    someProp2: "nasu",
    1.54 +    someProp3: undefined,
    1.55 +    someProp4: null,
    1.56 +    someProp5: arr,
    1.57 +    someProp6: obj,
    1.58 +    get someProp7() { return arr; },
    1.59 +    set someProp7(value) { arr[0] = value }
    1.60 +  };
    1.61 +
    1.62 +  gVariablesView.eval = function() {};
    1.63 +  gVariablesView.switch = function() {};
    1.64 +  gVariablesView.delete = function() {};
    1.65 +  gVariablesView.new = function() {};
    1.66 +  gVariablesView.rawObject = test;
    1.67 +
    1.68 +  testHierarchy();
    1.69 +  testHeader();
    1.70 +  testFirstLevelContents();
    1.71 +  testSecondLevelContents();
    1.72 +  testThirdLevelContents();
    1.73 +  testOriginalRawDataIntegrity(arr, obj);
    1.74 +
    1.75 +  let fooScope = gVariablesView.addScope("foo");
    1.76 +  let anonymousVar = fooScope.addItem();
    1.77 +
    1.78 +  let anonymousScope = gVariablesView.addScope();
    1.79 +  let barVar = anonymousScope.addItem("bar");
    1.80 +  let bazProperty = barVar.addItem("baz");
    1.81 +
    1.82 +  testAnonymousHeaders(fooScope, anonymousVar, anonymousScope, barVar, bazProperty);
    1.83 +  testPropertyInheritance(fooScope, anonymousVar, anonymousScope, barVar, bazProperty);
    1.84 +
    1.85 +  testClearHierarchy();
    1.86 +  closeDebuggerAndFinish(gPanel);
    1.87 +}
    1.88 +
    1.89 +function testHierarchy() {
    1.90 +  is(gVariablesView._currHierarchy.size, 13,
    1.91 +    "There should be 1 scope, 1 var, 1 proto, 8 props, 1 getter and 1 setter.");
    1.92 +
    1.93 +  gScope = gVariablesView._currHierarchy.get("");
    1.94 +  gVariable = gVariablesView._currHierarchy.get("[\"\"]");
    1.95 +
    1.96 +  is(gVariablesView._store.length, 1,
    1.97 +    "There should be only one scope in the view.");
    1.98 +  is(gScope._store.size, 1,
    1.99 +    "There should be only one variable in the scope.");
   1.100 +  is(gVariable._store.size, 9,
   1.101 +    "There should be 1 __proto__ and 8 properties in the variable.");
   1.102 +}
   1.103 +
   1.104 +function testHeader() {
   1.105 +  is(gScope.header, false,
   1.106 +    "The scope title header should be hidden.");
   1.107 +  is(gVariable.header, false,
   1.108 +    "The variable title header should be hidden.");
   1.109 +
   1.110 +  gScope.showHeader();
   1.111 +  gVariable.showHeader();
   1.112 +
   1.113 +  is(gScope.header, false,
   1.114 +    "The scope title header should still not be visible.");
   1.115 +  is(gVariable.header, false,
   1.116 +    "The variable title header should still not be visible.");
   1.117 +
   1.118 +  gScope.hideHeader();
   1.119 +  gVariable.hideHeader();
   1.120 +
   1.121 +  is(gScope.header, false,
   1.122 +    "The scope title header should now still be hidden.");
   1.123 +  is(gVariable.header, false,
   1.124 +    "The variable title header should now still be hidden.");
   1.125 +}
   1.126 +
   1.127 +function testFirstLevelContents() {
   1.128 +  let someProp0 = gVariable.get("someProp0");
   1.129 +  let someProp1 = gVariable.get("someProp1");
   1.130 +  let someProp2 = gVariable.get("someProp2");
   1.131 +  let someProp3 = gVariable.get("someProp3");
   1.132 +  let someProp4 = gVariable.get("someProp4");
   1.133 +  let someProp5 = gVariable.get("someProp5");
   1.134 +  let someProp6 = gVariable.get("someProp6");
   1.135 +  let someProp7 = gVariable.get("someProp7");
   1.136 +  let __proto__ = gVariable.get("__proto__");
   1.137 +
   1.138 +  is(someProp0.visible, true, "The first property visible state is correct.");
   1.139 +  is(someProp1.visible, true, "The second property visible state is correct.");
   1.140 +  is(someProp2.visible, true, "The third property visible state is correct.");
   1.141 +  is(someProp3.visible, true, "The fourth property visible state is correct.");
   1.142 +  is(someProp4.visible, true, "The fifth property visible state is correct.");
   1.143 +  is(someProp5.visible, true, "The sixth property visible state is correct.");
   1.144 +  is(someProp6.visible, true, "The seventh property visible state is correct.");
   1.145 +  is(someProp7.visible, true, "The eight property visible state is correct.");
   1.146 +  is(__proto__.visible, true, "The __proto__ property visible state is correct.");
   1.147 +
   1.148 +  is(someProp0.expanded, false, "The first property expanded state is correct.");
   1.149 +  is(someProp1.expanded, false, "The second property expanded state is correct.");
   1.150 +  is(someProp2.expanded, false, "The third property expanded state is correct.");
   1.151 +  is(someProp3.expanded, false, "The fourth property expanded state is correct.");
   1.152 +  is(someProp4.expanded, false, "The fifth property expanded state is correct.");
   1.153 +  is(someProp5.expanded, false, "The sixth property expanded state is correct.");
   1.154 +  is(someProp6.expanded, false, "The seventh property expanded state is correct.");
   1.155 +  is(someProp7.expanded, true, "The eight property expanded state is correct.");
   1.156 +  is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
   1.157 +
   1.158 +  is(someProp0.header, true, "The first property header state is correct.");
   1.159 +  is(someProp1.header, true, "The second property header state is correct.");
   1.160 +  is(someProp2.header, true, "The third property header state is correct.");
   1.161 +  is(someProp3.header, true, "The fourth property header state is correct.");
   1.162 +  is(someProp4.header, true, "The fifth property header state is correct.");
   1.163 +  is(someProp5.header, true, "The sixth property header state is correct.");
   1.164 +  is(someProp6.header, true, "The seventh property header state is correct.");
   1.165 +  is(someProp7.header, true, "The eight property header state is correct.");
   1.166 +  is(__proto__.header, true, "The __proto__ property header state is correct.");
   1.167 +
   1.168 +  is(someProp0.twisty, false, "The first property twisty state is correct.");
   1.169 +  is(someProp1.twisty, false, "The second property twisty state is correct.");
   1.170 +  is(someProp2.twisty, false, "The third property twisty state is correct.");
   1.171 +  is(someProp3.twisty, false, "The fourth property twisty state is correct.");
   1.172 +  is(someProp4.twisty, false, "The fifth property twisty state is correct.");
   1.173 +  is(someProp5.twisty, true, "The sixth property twisty state is correct.");
   1.174 +  is(someProp6.twisty, true, "The seventh property twisty state is correct.");
   1.175 +  is(someProp7.twisty, true, "The eight property twisty state is correct.");
   1.176 +  is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
   1.177 +
   1.178 +  is(someProp0.name, "someProp0", "The first property name is correct.");
   1.179 +  is(someProp1.name, "someProp1", "The second property name is correct.");
   1.180 +  is(someProp2.name, "someProp2", "The third property name is correct.");
   1.181 +  is(someProp3.name, "someProp3", "The fourth property name is correct.");
   1.182 +  is(someProp4.name, "someProp4", "The fifth property name is correct.");
   1.183 +  is(someProp5.name, "someProp5", "The sixth property name is correct.");
   1.184 +  is(someProp6.name, "someProp6", "The seventh property name is correct.");
   1.185 +  is(someProp7.name, "someProp7", "The eight property name is correct.");
   1.186 +  is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
   1.187 +
   1.188 +  is(someProp0.value, 42, "The first property value is correct.");
   1.189 +  is(someProp1.value, true, "The second property value is correct.");
   1.190 +  is(someProp2.value, "nasu", "The third property value is correct.");
   1.191 +  is(someProp3.value.type, "undefined", "The fourth property value is correct.");
   1.192 +  is(someProp4.value.type, "null", "The fifth property value is correct.");
   1.193 +  is(someProp5.value.type, "object", "The sixth property value type is correct.");
   1.194 +  is(someProp5.value.class, "Array", "The sixth property value class is correct.");
   1.195 +  is(someProp6.value.type, "object", "The seventh property value type is correct.");
   1.196 +  is(someProp6.value.class, "Object", "The seventh property value class is correct.");
   1.197 +  is(someProp7.value, null, "The eight property value is correct.");
   1.198 +  isnot(someProp7.getter, null, "The eight property getter is correct.");
   1.199 +  isnot(someProp7.setter, null, "The eight property setter is correct.");
   1.200 +  is(someProp7.getter.type, "object", "The eight property getter type is correct.");
   1.201 +  is(someProp7.getter.class, "Function", "The eight property getter class is correct.");
   1.202 +  is(someProp7.setter.type, "object", "The eight property setter type is correct.");
   1.203 +  is(someProp7.setter.class, "Function", "The eight property setter class is correct.");
   1.204 +  is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
   1.205 +  is(__proto__.value.class, "Object", "The __proto__ property value class is correct.");
   1.206 +
   1.207 +  someProp0.expand();
   1.208 +  someProp1.expand();
   1.209 +  someProp2.expand();
   1.210 +  someProp3.expand();
   1.211 +  someProp4.expand();
   1.212 +  someProp7.expand();
   1.213 +
   1.214 +  ok(!someProp0.get("__proto__"), "Number primitives should not have a prototype");
   1.215 +  ok(!someProp1.get("__proto__"), "Boolean primitives should not have a prototype");
   1.216 +  ok(!someProp2.get("__proto__"), "String literals should not have a prototype");
   1.217 +  ok(!someProp3.get("__proto__"), "Undefined values should not have a prototype");
   1.218 +  ok(!someProp4.get("__proto__"), "Null values should not have a prototype");
   1.219 +  ok(!someProp7.get("__proto__"), "Getter properties should not have a prototype");
   1.220 +}
   1.221 +
   1.222 +function testSecondLevelContents() {
   1.223 +  let someProp5 = gVariable.get("someProp5");
   1.224 +  let someProp6 = gVariable.get("someProp6");
   1.225 +
   1.226 +  is(someProp5._store.size, 0, "No properties should be in someProp5 before expanding");
   1.227 +  someProp5.expand();
   1.228 +  is(someProp5._store.size, 9, "Some properties should be in someProp5 before expanding");
   1.229 +
   1.230 +  let arrayItem0 = someProp5.get("0");
   1.231 +  let arrayItem1 = someProp5.get("1");
   1.232 +  let arrayItem2 = someProp5.get("2");
   1.233 +  let arrayItem3 = someProp5.get("3");
   1.234 +  let arrayItem4 = someProp5.get("4");
   1.235 +  let arrayItem5 = someProp5.get("5");
   1.236 +  let arrayItem6 = someProp5.get("6");
   1.237 +  let __proto__ = someProp5.get("__proto__");
   1.238 +
   1.239 +  is(arrayItem0.visible, true, "The first array item visible state is correct.");
   1.240 +  is(arrayItem1.visible, true, "The second array item visible state is correct.");
   1.241 +  is(arrayItem2.visible, true, "The third array item visible state is correct.");
   1.242 +  is(arrayItem3.visible, true, "The fourth array item visible state is correct.");
   1.243 +  is(arrayItem4.visible, true, "The fifth array item visible state is correct.");
   1.244 +  is(arrayItem5.visible, true, "The sixth array item visible state is correct.");
   1.245 +  is(arrayItem6.visible, true, "The seventh array item visible state is correct.");
   1.246 +  is(__proto__.visible, true, "The __proto__ property visible state is correct.");
   1.247 +
   1.248 +  is(arrayItem0.expanded, false, "The first array item expanded state is correct.");
   1.249 +  is(arrayItem1.expanded, false, "The second array item expanded state is correct.");
   1.250 +  is(arrayItem2.expanded, false, "The third array item expanded state is correct.");
   1.251 +  is(arrayItem3.expanded, false, "The fourth array item expanded state is correct.");
   1.252 +  is(arrayItem4.expanded, false, "The fifth array item expanded state is correct.");
   1.253 +  is(arrayItem5.expanded, false, "The sixth array item expanded state is correct.");
   1.254 +  is(arrayItem6.expanded, false, "The seventh array item expanded state is correct.");
   1.255 +  is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
   1.256 +
   1.257 +  is(arrayItem0.header, true, "The first array item header state is correct.");
   1.258 +  is(arrayItem1.header, true, "The second array item header state is correct.");
   1.259 +  is(arrayItem2.header, true, "The third array item header state is correct.");
   1.260 +  is(arrayItem3.header, true, "The fourth array item header state is correct.");
   1.261 +  is(arrayItem4.header, true, "The fifth array item header state is correct.");
   1.262 +  is(arrayItem5.header, true, "The sixth array item header state is correct.");
   1.263 +  is(arrayItem6.header, true, "The seventh array item header state is correct.");
   1.264 +  is(__proto__.header, true, "The __proto__ property header state is correct.");
   1.265 +
   1.266 +  is(arrayItem0.twisty, false, "The first array item twisty state is correct.");
   1.267 +  is(arrayItem1.twisty, false, "The second array item twisty state is correct.");
   1.268 +  is(arrayItem2.twisty, false, "The third array item twisty state is correct.");
   1.269 +  is(arrayItem3.twisty, false, "The fourth array item twisty state is correct.");
   1.270 +  is(arrayItem4.twisty, false, "The fifth array item twisty state is correct.");
   1.271 +  is(arrayItem5.twisty, true, "The sixth array item twisty state is correct.");
   1.272 +  is(arrayItem6.twisty, true, "The seventh array item twisty state is correct.");
   1.273 +  is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
   1.274 +
   1.275 +  is(arrayItem0.name, "0", "The first array item name is correct.");
   1.276 +  is(arrayItem1.name, "1", "The second array item name is correct.");
   1.277 +  is(arrayItem2.name, "2", "The third array item name is correct.");
   1.278 +  is(arrayItem3.name, "3", "The fourth array item name is correct.");
   1.279 +  is(arrayItem4.name, "4", "The fifth array item name is correct.");
   1.280 +  is(arrayItem5.name, "5", "The sixth array item name is correct.");
   1.281 +  is(arrayItem6.name, "6", "The seventh array item name is correct.");
   1.282 +  is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
   1.283 +
   1.284 +  is(arrayItem0.value, 42, "The first array item value is correct.");
   1.285 +  is(arrayItem1.value, true, "The second array item value is correct.");
   1.286 +  is(arrayItem2.value, "nasu", "The third array item value is correct.");
   1.287 +  is(arrayItem3.value.type, "undefined", "The fourth array item value is correct.");
   1.288 +  is(arrayItem4.value.type, "null", "The fifth array item value is correct.");
   1.289 +  is(arrayItem5.value.type, "object", "The sixth array item value type is correct.");
   1.290 +  is(arrayItem5.value.class, "Array", "The sixth array item value class is correct.");
   1.291 +  is(arrayItem6.value.type, "object", "The seventh array item value type is correct.");
   1.292 +  is(arrayItem6.value.class, "Object", "The seventh array item value class is correct.");
   1.293 +  is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
   1.294 +  is(__proto__.value.class, "Array", "The __proto__ property value class is correct.");
   1.295 +
   1.296 +  is(someProp6._store.size, 0, "No properties should be in someProp6 before expanding");
   1.297 +  someProp6.expand();
   1.298 +  is(someProp6._store.size, 10, "Some properties should be in someProp6 before expanding");
   1.299 +
   1.300 +  let objectItem0 = someProp6.get("p0");
   1.301 +  let objectItem1 = someProp6.get("p1");
   1.302 +  let objectItem2 = someProp6.get("p2");
   1.303 +  let objectItem3 = someProp6.get("p3");
   1.304 +  let objectItem4 = someProp6.get("p4");
   1.305 +  let objectItem5 = someProp6.get("p5");
   1.306 +  let objectItem6 = someProp6.get("p6");
   1.307 +  let objectItem7 = someProp6.get("p7");
   1.308 +  let objectItem8 = someProp6.get("p8");
   1.309 +  let __proto__ = someProp6.get("__proto__");
   1.310 +
   1.311 +  is(objectItem0.visible, true, "The first object item visible state is correct.");
   1.312 +  is(objectItem1.visible, true, "The second object item visible state is correct.");
   1.313 +  is(objectItem2.visible, true, "The third object item visible state is correct.");
   1.314 +  is(objectItem3.visible, true, "The fourth object item visible state is correct.");
   1.315 +  is(objectItem4.visible, true, "The fifth object item visible state is correct.");
   1.316 +  is(objectItem5.visible, true, "The sixth object item visible state is correct.");
   1.317 +  is(objectItem6.visible, true, "The seventh object item visible state is correct.");
   1.318 +  is(objectItem7.visible, true, "The eight object item visible state is correct.");
   1.319 +  is(objectItem8.visible, true, "The ninth object item visible state is correct.");
   1.320 +  is(__proto__.visible, true, "The __proto__ property visible state is correct.");
   1.321 +
   1.322 +  is(objectItem0.expanded, false, "The first object item expanded state is correct.");
   1.323 +  is(objectItem1.expanded, false, "The second object item expanded state is correct.");
   1.324 +  is(objectItem2.expanded, false, "The third object item expanded state is correct.");
   1.325 +  is(objectItem3.expanded, false, "The fourth object item expanded state is correct.");
   1.326 +  is(objectItem4.expanded, false, "The fifth object item expanded state is correct.");
   1.327 +  is(objectItem5.expanded, false, "The sixth object item expanded state is correct.");
   1.328 +  is(objectItem6.expanded, false, "The seventh object item expanded state is correct.");
   1.329 +  is(objectItem7.expanded, true, "The eight object item expanded state is correct.");
   1.330 +  is(objectItem8.expanded, true, "The ninth object item expanded state is correct.");
   1.331 +  is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
   1.332 +
   1.333 +  is(objectItem0.header, true, "The first object item header state is correct.");
   1.334 +  is(objectItem1.header, true, "The second object item header state is correct.");
   1.335 +  is(objectItem2.header, true, "The third object item header state is correct.");
   1.336 +  is(objectItem3.header, true, "The fourth object item header state is correct.");
   1.337 +  is(objectItem4.header, true, "The fifth object item header state is correct.");
   1.338 +  is(objectItem5.header, true, "The sixth object item header state is correct.");
   1.339 +  is(objectItem6.header, true, "The seventh object item header state is correct.");
   1.340 +  is(objectItem7.header, true, "The eight object item header state is correct.");
   1.341 +  is(objectItem8.header, true, "The ninth object item header state is correct.");
   1.342 +  is(__proto__.header, true, "The __proto__ property header state is correct.");
   1.343 +
   1.344 +  is(objectItem0.twisty, false, "The first object item twisty state is correct.");
   1.345 +  is(objectItem1.twisty, false, "The second object item twisty state is correct.");
   1.346 +  is(objectItem2.twisty, false, "The third object item twisty state is correct.");
   1.347 +  is(objectItem3.twisty, false, "The fourth object item twisty state is correct.");
   1.348 +  is(objectItem4.twisty, false, "The fifth object item twisty state is correct.");
   1.349 +  is(objectItem5.twisty, true, "The sixth object item twisty state is correct.");
   1.350 +  is(objectItem6.twisty, true, "The seventh object item twisty state is correct.");
   1.351 +  is(objectItem7.twisty, true, "The eight object item twisty state is correct.");
   1.352 +  is(objectItem8.twisty, true, "The ninth object item twisty state is correct.");
   1.353 +  is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
   1.354 +
   1.355 +  is(objectItem0.name, "p0", "The first object item name is correct.");
   1.356 +  is(objectItem1.name, "p1", "The second object item name is correct.");
   1.357 +  is(objectItem2.name, "p2", "The third object item name is correct.");
   1.358 +  is(objectItem3.name, "p3", "The fourth object item name is correct.");
   1.359 +  is(objectItem4.name, "p4", "The fifth object item name is correct.");
   1.360 +  is(objectItem5.name, "p5", "The sixth object item name is correct.");
   1.361 +  is(objectItem6.name, "p6", "The seventh object item name is correct.");
   1.362 +  is(objectItem7.name, "p7", "The eight seventh object item name is correct.");
   1.363 +  is(objectItem8.name, "p8", "The ninth seventh object item name is correct.");
   1.364 +  is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
   1.365 +
   1.366 +  is(objectItem0.value, 42, "The first object item value is correct.");
   1.367 +  is(objectItem1.value, true, "The second object item value is correct.");
   1.368 +  is(objectItem2.value, "nasu", "The third object item value is correct.");
   1.369 +  is(objectItem3.value.type, "undefined", "The fourth object item value is correct.");
   1.370 +  is(objectItem4.value.type, "null", "The fifth object item value is correct.");
   1.371 +  is(objectItem5.value.type, "object", "The sixth object item value type is correct.");
   1.372 +  is(objectItem5.value.class, "Array", "The sixth object item value class is correct.");
   1.373 +  is(objectItem6.value.type, "object", "The seventh object item value type is correct.");
   1.374 +  is(objectItem6.value.class, "Object", "The seventh object item value class is correct.");
   1.375 +  is(objectItem7.value, null, "The eight object item value is correct.");
   1.376 +  isnot(objectItem7.getter, null, "The eight object item getter is correct.");
   1.377 +  isnot(objectItem7.setter, null, "The eight object item setter is correct.");
   1.378 +  is(objectItem7.setter.type, "undefined", "The eight object item setter type is correct.");
   1.379 +  is(objectItem7.getter.type, "object", "The eight object item getter type is correct.");
   1.380 +  is(objectItem7.getter.class, "Function", "The eight object item getter class is correct.");
   1.381 +  is(objectItem8.value, null, "The ninth object item value is correct.");
   1.382 +  isnot(objectItem8.getter, null, "The ninth object item getter is correct.");
   1.383 +  isnot(objectItem8.setter, null, "The ninth object item setter is correct.");
   1.384 +  is(objectItem8.getter.type, "undefined", "The eight object item getter type is correct.");
   1.385 +  is(objectItem8.setter.type, "object", "The ninth object item setter type is correct.");
   1.386 +  is(objectItem8.setter.class, "Function", "The ninth object item setter class is correct.");
   1.387 +  is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
   1.388 +  is(__proto__.value.class, "Object", "The __proto__ property value class is correct.");
   1.389 +}
   1.390 +
   1.391 +function testThirdLevelContents() {
   1.392 +  (function() {
   1.393 +    let someProp5 = gVariable.get("someProp5");
   1.394 +    let arrayItem5 = someProp5.get("5");
   1.395 +    let arrayItem6 = someProp5.get("6");
   1.396 +
   1.397 +    is(arrayItem5._store.size, 0, "No properties should be in arrayItem5 before expanding");
   1.398 +    arrayItem5.expand();
   1.399 +    is(arrayItem5._store.size, 5, "Some properties should be in arrayItem5 before expanding");
   1.400 +
   1.401 +    is(arrayItem6._store.size, 0, "No properties should be in arrayItem6 before expanding");
   1.402 +    arrayItem6.expand();
   1.403 +    is(arrayItem6._store.size, 3, "Some properties should be in arrayItem6 before expanding");
   1.404 +
   1.405 +    let arraySubItem0 = arrayItem5.get("0");
   1.406 +    let arraySubItem1 = arrayItem5.get("1");
   1.407 +    let arraySubItem2 = arrayItem5.get("2");
   1.408 +    let objectSubItem0 = arrayItem6.get("prop1");
   1.409 +    let objectSubItem1 = arrayItem6.get("prop2");
   1.410 +
   1.411 +    is(arraySubItem0.value, 0, "The first array sub-item value is correct.");
   1.412 +    is(arraySubItem1.value, 1, "The second array sub-item value is correct.");
   1.413 +    is(arraySubItem2.value, 2, "The third array sub-item value is correct.");
   1.414 +
   1.415 +    is(objectSubItem0.value, 9, "The first object sub-item value is correct.");
   1.416 +    is(objectSubItem1.value, 8, "The second object sub-item value is correct.");
   1.417 +
   1.418 +    let array__proto__ = arrayItem5.get("__proto__");
   1.419 +    let object__proto__ = arrayItem6.get("__proto__");
   1.420 +
   1.421 +    ok(array__proto__, "The array should have a __proto__ property.");
   1.422 +    ok(object__proto__, "The object should have a __proto__ property.");
   1.423 +  })();
   1.424 +
   1.425 +  (function() {
   1.426 +    let someProp6 = gVariable.get("someProp6");
   1.427 +    let objectItem5 = someProp6.get("p5");
   1.428 +    let objectItem6 = someProp6.get("p6");
   1.429 +
   1.430 +    is(objectItem5._store.size, 0, "No properties should be in objectItem5 before expanding");
   1.431 +    objectItem5.expand();
   1.432 +    is(objectItem5._store.size, 5, "Some properties should be in objectItem5 before expanding");
   1.433 +
   1.434 +    is(objectItem6._store.size, 0, "No properties should be in objectItem6 before expanding");
   1.435 +    objectItem6.expand();
   1.436 +    is(objectItem6._store.size, 3, "Some properties should be in objectItem6 before expanding");
   1.437 +
   1.438 +    let arraySubItem0 = objectItem5.get("0");
   1.439 +    let arraySubItem1 = objectItem5.get("1");
   1.440 +    let arraySubItem2 = objectItem5.get("2");
   1.441 +    let objectSubItem0 = objectItem6.get("prop1");
   1.442 +    let objectSubItem1 = objectItem6.get("prop2");
   1.443 +
   1.444 +    is(arraySubItem0.value, 3, "The first array sub-item value is correct.");
   1.445 +    is(arraySubItem1.value, 4, "The second array sub-item value is correct.");
   1.446 +    is(arraySubItem2.value, 5, "The third array sub-item value is correct.");
   1.447 +
   1.448 +    is(objectSubItem0.value, 7, "The first object sub-item value is correct.");
   1.449 +    is(objectSubItem1.value, 6, "The second object sub-item value is correct.");
   1.450 +
   1.451 +    let array__proto__ = objectItem5.get("__proto__");
   1.452 +    let object__proto__ = objectItem6.get("__proto__");
   1.453 +
   1.454 +    ok(array__proto__, "The array should have a __proto__ property.");
   1.455 +    ok(object__proto__, "The object should have a __proto__ property.");
   1.456 +  })();
   1.457 +}
   1.458 +
   1.459 +function testOriginalRawDataIntegrity(arr, obj) {
   1.460 +  is(arr[0], 42, "The first array item should not have changed.");
   1.461 +  is(arr[1], true, "The second array item should not have changed.");
   1.462 +  is(arr[2], "nasu", "The third array item should not have changed.");
   1.463 +  is(arr[3], undefined, "The fourth array item should not have changed.");
   1.464 +  is(arr[4], null, "The fifth array item should not have changed.");
   1.465 +  ok(arr[5] instanceof Array, "The sixth array item should be an Array.");
   1.466 +  is(arr[5][0], 0, "The sixth array item should not have changed.");
   1.467 +  is(arr[5][1], 1, "The sixth array item should not have changed.");
   1.468 +  is(arr[5][2], 2, "The sixth array item should not have changed.");
   1.469 +  ok(arr[6] instanceof Object, "The seventh array item should be an Object.");
   1.470 +  is(arr[6].prop1, 9, "The seventh array item should not have changed.");
   1.471 +  is(arr[6].prop2, 8, "The seventh array item should not have changed.");
   1.472 +
   1.473 +  is(obj.p0, 42, "The first object property should not have changed.");
   1.474 +  is(obj.p1, true, "The first object property should not have changed.");
   1.475 +  is(obj.p2, "nasu", "The first object property should not have changed.");
   1.476 +  is(obj.p3, undefined, "The first object property should not have changed.");
   1.477 +  is(obj.p4, null, "The first object property should not have changed.");
   1.478 +  ok(obj.p5 instanceof Array, "The sixth object property should be an Array.");
   1.479 +  is(obj.p5[0], 3, "The sixth object property should not have changed.");
   1.480 +  is(obj.p5[1], 4, "The sixth object property should not have changed.");
   1.481 +  is(obj.p5[2], 5, "The sixth object property should not have changed.");
   1.482 +  ok(obj.p6 instanceof Object, "The seventh object property should be an Object.");
   1.483 +  is(obj.p6.prop1, 7, "The seventh object property should not have changed.");
   1.484 +  is(obj.p6.prop2, 6, "The seventh object property should not have changed.");
   1.485 +}
   1.486 +
   1.487 +function testAnonymousHeaders(fooScope, anonymousVar, anonymousScope, barVar, bazProperty) {
   1.488 +  is(fooScope.header, true,
   1.489 +    "A named scope should have a header visible.");
   1.490 +  is(fooScope.target.hasAttribute("untitled"), false,
   1.491 +    "The non-header attribute should not be applied to scopes with headers.");
   1.492 +
   1.493 +  is(anonymousScope.header, false,
   1.494 +    "An anonymous scope should have a header visible.");
   1.495 +  is(anonymousScope.target.hasAttribute("untitled"), true,
   1.496 +    "The non-header attribute should not be applied to scopes without headers.");
   1.497 +
   1.498 +  is(barVar.header, true,
   1.499 +    "A named variable should have a header visible.");
   1.500 +  is(barVar.target.hasAttribute("untitled"), false,
   1.501 +    "The non-header attribute should not be applied to variables with headers.");
   1.502 +
   1.503 +  is(anonymousVar.header, false,
   1.504 +    "An anonymous variable should have a header visible.");
   1.505 +  is(anonymousVar.target.hasAttribute("untitled"), true,
   1.506 +    "The non-header attribute should not be applied to variables without headers.");
   1.507 +}
   1.508 +
   1.509 +function testPropertyInheritance(fooScope, anonymousVar, anonymousScope, barVar, bazProperty) {
   1.510 +  is(fooScope.preventDisableOnChange, gVariablesView.preventDisableOnChange,
   1.511 +    "The preventDisableOnChange property should persist from the view to all scopes.");
   1.512 +  is(fooScope.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
   1.513 +    "The preventDescriptorModifiers property should persist from the view to all scopes.");
   1.514 +  is(fooScope.editableNameTooltip, gVariablesView.editableNameTooltip,
   1.515 +    "The editableNameTooltip property should persist from the view to all scopes.");
   1.516 +  is(fooScope.editableValueTooltip, gVariablesView.editableValueTooltip,
   1.517 +    "The editableValueTooltip property should persist from the view to all scopes.");
   1.518 +  is(fooScope.editButtonTooltip, gVariablesView.editButtonTooltip,
   1.519 +    "The editButtonTooltip property should persist from the view to all scopes.");
   1.520 +  is(fooScope.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
   1.521 +    "The deleteButtonTooltip property should persist from the view to all scopes.");
   1.522 +  is(fooScope.contextMenuId, gVariablesView.contextMenuId,
   1.523 +    "The contextMenuId property should persist from the view to all scopes.");
   1.524 +  is(fooScope.separatorStr, gVariablesView.separatorStr,
   1.525 +    "The separatorStr property should persist from the view to all scopes.");
   1.526 +  is(fooScope.eval, gVariablesView.eval,
   1.527 +    "The eval property should persist from the view to all scopes.");
   1.528 +  is(fooScope.switch, gVariablesView.switch,
   1.529 +    "The switch property should persist from the view to all scopes.");
   1.530 +  is(fooScope.delete, gVariablesView.delete,
   1.531 +    "The delete property should persist from the view to all scopes.");
   1.532 +  is(fooScope.new, gVariablesView.new,
   1.533 +    "The new property should persist from the view to all scopes.");
   1.534 +  isnot(fooScope.eval, fooScope.switch,
   1.535 +    "The eval and switch functions got mixed up in the scope.");
   1.536 +  isnot(fooScope.switch, fooScope.delete,
   1.537 +    "The eval and switch functions got mixed up in the scope.");
   1.538 +
   1.539 +  is(barVar.preventDisableOnChange, gVariablesView.preventDisableOnChange,
   1.540 +    "The preventDisableOnChange property should persist from the view to all variables.");
   1.541 +  is(barVar.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
   1.542 +    "The preventDescriptorModifiers property should persist from the view to all variables.");
   1.543 +  is(barVar.editableNameTooltip, gVariablesView.editableNameTooltip,
   1.544 +    "The editableNameTooltip property should persist from the view to all variables.");
   1.545 +  is(barVar.editableValueTooltip, gVariablesView.editableValueTooltip,
   1.546 +    "The editableValueTooltip property should persist from the view to all variables.");
   1.547 +  is(barVar.editButtonTooltip, gVariablesView.editButtonTooltip,
   1.548 +    "The editButtonTooltip property should persist from the view to all variables.");
   1.549 +  is(barVar.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
   1.550 +    "The deleteButtonTooltip property should persist from the view to all variables.");
   1.551 +  is(barVar.contextMenuId, gVariablesView.contextMenuId,
   1.552 +    "The contextMenuId property should persist from the view to all variables.");
   1.553 +  is(barVar.separatorStr, gVariablesView.separatorStr,
   1.554 +    "The separatorStr property should persist from the view to all variables.");
   1.555 +  is(barVar.eval, gVariablesView.eval,
   1.556 +    "The eval property should persist from the view to all variables.");
   1.557 +  is(barVar.switch, gVariablesView.switch,
   1.558 +    "The switch property should persist from the view to all variables.");
   1.559 +  is(barVar.delete, gVariablesView.delete,
   1.560 +    "The delete property should persist from the view to all variables.");
   1.561 +  is(barVar.new, gVariablesView.new,
   1.562 +    "The new property should persist from the view to all variables.");
   1.563 +  isnot(barVar.eval, barVar.switch,
   1.564 +    "The eval and switch functions got mixed up in the variable.");
   1.565 +  isnot(barVar.switch, barVar.delete,
   1.566 +    "The eval and switch functions got mixed up in the variable.");
   1.567 +
   1.568 +  is(bazProperty.preventDisableOnChange, gVariablesView.preventDisableOnChange,
   1.569 +    "The preventDisableOnChange property should persist from the view to all properties.");
   1.570 +  is(bazProperty.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
   1.571 +    "The preventDescriptorModifiers property should persist from the view to all properties.");
   1.572 +  is(bazProperty.editableNameTooltip, gVariablesView.editableNameTooltip,
   1.573 +    "The editableNameTooltip property should persist from the view to all properties.");
   1.574 +  is(bazProperty.editableValueTooltip, gVariablesView.editableValueTooltip,
   1.575 +    "The editableValueTooltip property should persist from the view to all properties.");
   1.576 +  is(bazProperty.editButtonTooltip, gVariablesView.editButtonTooltip,
   1.577 +    "The editButtonTooltip property should persist from the view to all properties.");
   1.578 +  is(bazProperty.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
   1.579 +    "The deleteButtonTooltip property should persist from the view to all properties.");
   1.580 +  is(bazProperty.contextMenuId, gVariablesView.contextMenuId,
   1.581 +    "The contextMenuId property should persist from the view to all properties.");
   1.582 +  is(bazProperty.separatorStr, gVariablesView.separatorStr,
   1.583 +    "The separatorStr property should persist from the view to all properties.");
   1.584 +  is(bazProperty.eval, gVariablesView.eval,
   1.585 +    "The eval property should persist from the view to all properties.");
   1.586 +  is(bazProperty.switch, gVariablesView.switch,
   1.587 +    "The switch property should persist from the view to all properties.");
   1.588 +  is(bazProperty.delete, gVariablesView.delete,
   1.589 +    "The delete property should persist from the view to all properties.");
   1.590 +  is(bazProperty.new, gVariablesView.new,
   1.591 +    "The new property should persist from the view to all properties.");
   1.592 +  isnot(bazProperty.eval, bazProperty.switch,
   1.593 +    "The eval and switch functions got mixed up in the property.");
   1.594 +  isnot(bazProperty.switch, bazProperty.delete,
   1.595 +    "The eval and switch functions got mixed up in the property.");
   1.596 +}
   1.597 +
   1.598 +function testClearHierarchy() {
   1.599 +  gVariablesView.clearHierarchy();
   1.600 +  ok(!gVariablesView._prevHierarchy.size,
   1.601 +    "The previous hierarchy should have been cleared.");
   1.602 +  ok(!gVariablesView._currHierarchy.size,
   1.603 +    "The current hierarchy should have been cleared.");
   1.604 +}
   1.605 +
   1.606 +registerCleanupFunction(function() {
   1.607 +  gTab = null;
   1.608 +  gDebuggee = null;
   1.609 +  gPanel = null;
   1.610 +  gDebugger = null;
   1.611 +  gVariablesView = null;
   1.612 +  gScope = null;
   1.613 +  gVariable = null;
   1.614 +});

mercurial