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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

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 * Make sure that the variables view correctly populates itself
michael@0 6 * when given some raw data.
michael@0 7 */
michael@0 8
michael@0 9 let gTab, gDebuggee, gPanel, gDebugger;
michael@0 10 let gVariablesView, gScope, gVariable;
michael@0 11
michael@0 12 function test() {
michael@0 13 initDebugger("about:blank").then(([aTab, aDebuggee, aPanel]) => {
michael@0 14 gTab = aTab;
michael@0 15 gDebuggee = aDebuggee;
michael@0 16 gPanel = aPanel;
michael@0 17 gDebugger = gPanel.panelWin;
michael@0 18 gVariablesView = gDebugger.DebuggerView.Variables;
michael@0 19
michael@0 20 performTest();
michael@0 21 });
michael@0 22 }
michael@0 23
michael@0 24 function performTest() {
michael@0 25 let arr = [
michael@0 26 42,
michael@0 27 true,
michael@0 28 "nasu",
michael@0 29 undefined,
michael@0 30 null,
michael@0 31 [0, 1, 2],
michael@0 32 { prop1: 9, prop2: 8 }
michael@0 33 ];
michael@0 34
michael@0 35 let obj = {
michael@0 36 p0: 42,
michael@0 37 p1: true,
michael@0 38 p2: "nasu",
michael@0 39 p3: undefined,
michael@0 40 p4: null,
michael@0 41 p5: [3, 4, 5],
michael@0 42 p6: { prop1: 7, prop2: 6 },
michael@0 43 get p7() { return arr; },
michael@0 44 set p8(value) { arr[0] = value }
michael@0 45 };
michael@0 46
michael@0 47 let test = {
michael@0 48 someProp0: 42,
michael@0 49 someProp1: true,
michael@0 50 someProp2: "nasu",
michael@0 51 someProp3: undefined,
michael@0 52 someProp4: null,
michael@0 53 someProp5: arr,
michael@0 54 someProp6: obj,
michael@0 55 get someProp7() { return arr; },
michael@0 56 set someProp7(value) { arr[0] = value }
michael@0 57 };
michael@0 58
michael@0 59 gVariablesView.eval = function() {};
michael@0 60 gVariablesView.switch = function() {};
michael@0 61 gVariablesView.delete = function() {};
michael@0 62 gVariablesView.new = function() {};
michael@0 63 gVariablesView.rawObject = test;
michael@0 64
michael@0 65 testHierarchy();
michael@0 66 testHeader();
michael@0 67 testFirstLevelContents();
michael@0 68 testSecondLevelContents();
michael@0 69 testThirdLevelContents();
michael@0 70 testOriginalRawDataIntegrity(arr, obj);
michael@0 71
michael@0 72 let fooScope = gVariablesView.addScope("foo");
michael@0 73 let anonymousVar = fooScope.addItem();
michael@0 74
michael@0 75 let anonymousScope = gVariablesView.addScope();
michael@0 76 let barVar = anonymousScope.addItem("bar");
michael@0 77 let bazProperty = barVar.addItem("baz");
michael@0 78
michael@0 79 testAnonymousHeaders(fooScope, anonymousVar, anonymousScope, barVar, bazProperty);
michael@0 80 testPropertyInheritance(fooScope, anonymousVar, anonymousScope, barVar, bazProperty);
michael@0 81
michael@0 82 testClearHierarchy();
michael@0 83 closeDebuggerAndFinish(gPanel);
michael@0 84 }
michael@0 85
michael@0 86 function testHierarchy() {
michael@0 87 is(gVariablesView._currHierarchy.size, 13,
michael@0 88 "There should be 1 scope, 1 var, 1 proto, 8 props, 1 getter and 1 setter.");
michael@0 89
michael@0 90 gScope = gVariablesView._currHierarchy.get("");
michael@0 91 gVariable = gVariablesView._currHierarchy.get("[\"\"]");
michael@0 92
michael@0 93 is(gVariablesView._store.length, 1,
michael@0 94 "There should be only one scope in the view.");
michael@0 95 is(gScope._store.size, 1,
michael@0 96 "There should be only one variable in the scope.");
michael@0 97 is(gVariable._store.size, 9,
michael@0 98 "There should be 1 __proto__ and 8 properties in the variable.");
michael@0 99 }
michael@0 100
michael@0 101 function testHeader() {
michael@0 102 is(gScope.header, false,
michael@0 103 "The scope title header should be hidden.");
michael@0 104 is(gVariable.header, false,
michael@0 105 "The variable title header should be hidden.");
michael@0 106
michael@0 107 gScope.showHeader();
michael@0 108 gVariable.showHeader();
michael@0 109
michael@0 110 is(gScope.header, false,
michael@0 111 "The scope title header should still not be visible.");
michael@0 112 is(gVariable.header, false,
michael@0 113 "The variable title header should still not be visible.");
michael@0 114
michael@0 115 gScope.hideHeader();
michael@0 116 gVariable.hideHeader();
michael@0 117
michael@0 118 is(gScope.header, false,
michael@0 119 "The scope title header should now still be hidden.");
michael@0 120 is(gVariable.header, false,
michael@0 121 "The variable title header should now still be hidden.");
michael@0 122 }
michael@0 123
michael@0 124 function testFirstLevelContents() {
michael@0 125 let someProp0 = gVariable.get("someProp0");
michael@0 126 let someProp1 = gVariable.get("someProp1");
michael@0 127 let someProp2 = gVariable.get("someProp2");
michael@0 128 let someProp3 = gVariable.get("someProp3");
michael@0 129 let someProp4 = gVariable.get("someProp4");
michael@0 130 let someProp5 = gVariable.get("someProp5");
michael@0 131 let someProp6 = gVariable.get("someProp6");
michael@0 132 let someProp7 = gVariable.get("someProp7");
michael@0 133 let __proto__ = gVariable.get("__proto__");
michael@0 134
michael@0 135 is(someProp0.visible, true, "The first property visible state is correct.");
michael@0 136 is(someProp1.visible, true, "The second property visible state is correct.");
michael@0 137 is(someProp2.visible, true, "The third property visible state is correct.");
michael@0 138 is(someProp3.visible, true, "The fourth property visible state is correct.");
michael@0 139 is(someProp4.visible, true, "The fifth property visible state is correct.");
michael@0 140 is(someProp5.visible, true, "The sixth property visible state is correct.");
michael@0 141 is(someProp6.visible, true, "The seventh property visible state is correct.");
michael@0 142 is(someProp7.visible, true, "The eight property visible state is correct.");
michael@0 143 is(__proto__.visible, true, "The __proto__ property visible state is correct.");
michael@0 144
michael@0 145 is(someProp0.expanded, false, "The first property expanded state is correct.");
michael@0 146 is(someProp1.expanded, false, "The second property expanded state is correct.");
michael@0 147 is(someProp2.expanded, false, "The third property expanded state is correct.");
michael@0 148 is(someProp3.expanded, false, "The fourth property expanded state is correct.");
michael@0 149 is(someProp4.expanded, false, "The fifth property expanded state is correct.");
michael@0 150 is(someProp5.expanded, false, "The sixth property expanded state is correct.");
michael@0 151 is(someProp6.expanded, false, "The seventh property expanded state is correct.");
michael@0 152 is(someProp7.expanded, true, "The eight property expanded state is correct.");
michael@0 153 is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
michael@0 154
michael@0 155 is(someProp0.header, true, "The first property header state is correct.");
michael@0 156 is(someProp1.header, true, "The second property header state is correct.");
michael@0 157 is(someProp2.header, true, "The third property header state is correct.");
michael@0 158 is(someProp3.header, true, "The fourth property header state is correct.");
michael@0 159 is(someProp4.header, true, "The fifth property header state is correct.");
michael@0 160 is(someProp5.header, true, "The sixth property header state is correct.");
michael@0 161 is(someProp6.header, true, "The seventh property header state is correct.");
michael@0 162 is(someProp7.header, true, "The eight property header state is correct.");
michael@0 163 is(__proto__.header, true, "The __proto__ property header state is correct.");
michael@0 164
michael@0 165 is(someProp0.twisty, false, "The first property twisty state is correct.");
michael@0 166 is(someProp1.twisty, false, "The second property twisty state is correct.");
michael@0 167 is(someProp2.twisty, false, "The third property twisty state is correct.");
michael@0 168 is(someProp3.twisty, false, "The fourth property twisty state is correct.");
michael@0 169 is(someProp4.twisty, false, "The fifth property twisty state is correct.");
michael@0 170 is(someProp5.twisty, true, "The sixth property twisty state is correct.");
michael@0 171 is(someProp6.twisty, true, "The seventh property twisty state is correct.");
michael@0 172 is(someProp7.twisty, true, "The eight property twisty state is correct.");
michael@0 173 is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
michael@0 174
michael@0 175 is(someProp0.name, "someProp0", "The first property name is correct.");
michael@0 176 is(someProp1.name, "someProp1", "The second property name is correct.");
michael@0 177 is(someProp2.name, "someProp2", "The third property name is correct.");
michael@0 178 is(someProp3.name, "someProp3", "The fourth property name is correct.");
michael@0 179 is(someProp4.name, "someProp4", "The fifth property name is correct.");
michael@0 180 is(someProp5.name, "someProp5", "The sixth property name is correct.");
michael@0 181 is(someProp6.name, "someProp6", "The seventh property name is correct.");
michael@0 182 is(someProp7.name, "someProp7", "The eight property name is correct.");
michael@0 183 is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
michael@0 184
michael@0 185 is(someProp0.value, 42, "The first property value is correct.");
michael@0 186 is(someProp1.value, true, "The second property value is correct.");
michael@0 187 is(someProp2.value, "nasu", "The third property value is correct.");
michael@0 188 is(someProp3.value.type, "undefined", "The fourth property value is correct.");
michael@0 189 is(someProp4.value.type, "null", "The fifth property value is correct.");
michael@0 190 is(someProp5.value.type, "object", "The sixth property value type is correct.");
michael@0 191 is(someProp5.value.class, "Array", "The sixth property value class is correct.");
michael@0 192 is(someProp6.value.type, "object", "The seventh property value type is correct.");
michael@0 193 is(someProp6.value.class, "Object", "The seventh property value class is correct.");
michael@0 194 is(someProp7.value, null, "The eight property value is correct.");
michael@0 195 isnot(someProp7.getter, null, "The eight property getter is correct.");
michael@0 196 isnot(someProp7.setter, null, "The eight property setter is correct.");
michael@0 197 is(someProp7.getter.type, "object", "The eight property getter type is correct.");
michael@0 198 is(someProp7.getter.class, "Function", "The eight property getter class is correct.");
michael@0 199 is(someProp7.setter.type, "object", "The eight property setter type is correct.");
michael@0 200 is(someProp7.setter.class, "Function", "The eight property setter class is correct.");
michael@0 201 is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
michael@0 202 is(__proto__.value.class, "Object", "The __proto__ property value class is correct.");
michael@0 203
michael@0 204 someProp0.expand();
michael@0 205 someProp1.expand();
michael@0 206 someProp2.expand();
michael@0 207 someProp3.expand();
michael@0 208 someProp4.expand();
michael@0 209 someProp7.expand();
michael@0 210
michael@0 211 ok(!someProp0.get("__proto__"), "Number primitives should not have a prototype");
michael@0 212 ok(!someProp1.get("__proto__"), "Boolean primitives should not have a prototype");
michael@0 213 ok(!someProp2.get("__proto__"), "String literals should not have a prototype");
michael@0 214 ok(!someProp3.get("__proto__"), "Undefined values should not have a prototype");
michael@0 215 ok(!someProp4.get("__proto__"), "Null values should not have a prototype");
michael@0 216 ok(!someProp7.get("__proto__"), "Getter properties should not have a prototype");
michael@0 217 }
michael@0 218
michael@0 219 function testSecondLevelContents() {
michael@0 220 let someProp5 = gVariable.get("someProp5");
michael@0 221 let someProp6 = gVariable.get("someProp6");
michael@0 222
michael@0 223 is(someProp5._store.size, 0, "No properties should be in someProp5 before expanding");
michael@0 224 someProp5.expand();
michael@0 225 is(someProp5._store.size, 9, "Some properties should be in someProp5 before expanding");
michael@0 226
michael@0 227 let arrayItem0 = someProp5.get("0");
michael@0 228 let arrayItem1 = someProp5.get("1");
michael@0 229 let arrayItem2 = someProp5.get("2");
michael@0 230 let arrayItem3 = someProp5.get("3");
michael@0 231 let arrayItem4 = someProp5.get("4");
michael@0 232 let arrayItem5 = someProp5.get("5");
michael@0 233 let arrayItem6 = someProp5.get("6");
michael@0 234 let __proto__ = someProp5.get("__proto__");
michael@0 235
michael@0 236 is(arrayItem0.visible, true, "The first array item visible state is correct.");
michael@0 237 is(arrayItem1.visible, true, "The second array item visible state is correct.");
michael@0 238 is(arrayItem2.visible, true, "The third array item visible state is correct.");
michael@0 239 is(arrayItem3.visible, true, "The fourth array item visible state is correct.");
michael@0 240 is(arrayItem4.visible, true, "The fifth array item visible state is correct.");
michael@0 241 is(arrayItem5.visible, true, "The sixth array item visible state is correct.");
michael@0 242 is(arrayItem6.visible, true, "The seventh array item visible state is correct.");
michael@0 243 is(__proto__.visible, true, "The __proto__ property visible state is correct.");
michael@0 244
michael@0 245 is(arrayItem0.expanded, false, "The first array item expanded state is correct.");
michael@0 246 is(arrayItem1.expanded, false, "The second array item expanded state is correct.");
michael@0 247 is(arrayItem2.expanded, false, "The third array item expanded state is correct.");
michael@0 248 is(arrayItem3.expanded, false, "The fourth array item expanded state is correct.");
michael@0 249 is(arrayItem4.expanded, false, "The fifth array item expanded state is correct.");
michael@0 250 is(arrayItem5.expanded, false, "The sixth array item expanded state is correct.");
michael@0 251 is(arrayItem6.expanded, false, "The seventh array item expanded state is correct.");
michael@0 252 is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
michael@0 253
michael@0 254 is(arrayItem0.header, true, "The first array item header state is correct.");
michael@0 255 is(arrayItem1.header, true, "The second array item header state is correct.");
michael@0 256 is(arrayItem2.header, true, "The third array item header state is correct.");
michael@0 257 is(arrayItem3.header, true, "The fourth array item header state is correct.");
michael@0 258 is(arrayItem4.header, true, "The fifth array item header state is correct.");
michael@0 259 is(arrayItem5.header, true, "The sixth array item header state is correct.");
michael@0 260 is(arrayItem6.header, true, "The seventh array item header state is correct.");
michael@0 261 is(__proto__.header, true, "The __proto__ property header state is correct.");
michael@0 262
michael@0 263 is(arrayItem0.twisty, false, "The first array item twisty state is correct.");
michael@0 264 is(arrayItem1.twisty, false, "The second array item twisty state is correct.");
michael@0 265 is(arrayItem2.twisty, false, "The third array item twisty state is correct.");
michael@0 266 is(arrayItem3.twisty, false, "The fourth array item twisty state is correct.");
michael@0 267 is(arrayItem4.twisty, false, "The fifth array item twisty state is correct.");
michael@0 268 is(arrayItem5.twisty, true, "The sixth array item twisty state is correct.");
michael@0 269 is(arrayItem6.twisty, true, "The seventh array item twisty state is correct.");
michael@0 270 is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
michael@0 271
michael@0 272 is(arrayItem0.name, "0", "The first array item name is correct.");
michael@0 273 is(arrayItem1.name, "1", "The second array item name is correct.");
michael@0 274 is(arrayItem2.name, "2", "The third array item name is correct.");
michael@0 275 is(arrayItem3.name, "3", "The fourth array item name is correct.");
michael@0 276 is(arrayItem4.name, "4", "The fifth array item name is correct.");
michael@0 277 is(arrayItem5.name, "5", "The sixth array item name is correct.");
michael@0 278 is(arrayItem6.name, "6", "The seventh array item name is correct.");
michael@0 279 is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
michael@0 280
michael@0 281 is(arrayItem0.value, 42, "The first array item value is correct.");
michael@0 282 is(arrayItem1.value, true, "The second array item value is correct.");
michael@0 283 is(arrayItem2.value, "nasu", "The third array item value is correct.");
michael@0 284 is(arrayItem3.value.type, "undefined", "The fourth array item value is correct.");
michael@0 285 is(arrayItem4.value.type, "null", "The fifth array item value is correct.");
michael@0 286 is(arrayItem5.value.type, "object", "The sixth array item value type is correct.");
michael@0 287 is(arrayItem5.value.class, "Array", "The sixth array item value class is correct.");
michael@0 288 is(arrayItem6.value.type, "object", "The seventh array item value type is correct.");
michael@0 289 is(arrayItem6.value.class, "Object", "The seventh array item value class is correct.");
michael@0 290 is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
michael@0 291 is(__proto__.value.class, "Array", "The __proto__ property value class is correct.");
michael@0 292
michael@0 293 is(someProp6._store.size, 0, "No properties should be in someProp6 before expanding");
michael@0 294 someProp6.expand();
michael@0 295 is(someProp6._store.size, 10, "Some properties should be in someProp6 before expanding");
michael@0 296
michael@0 297 let objectItem0 = someProp6.get("p0");
michael@0 298 let objectItem1 = someProp6.get("p1");
michael@0 299 let objectItem2 = someProp6.get("p2");
michael@0 300 let objectItem3 = someProp6.get("p3");
michael@0 301 let objectItem4 = someProp6.get("p4");
michael@0 302 let objectItem5 = someProp6.get("p5");
michael@0 303 let objectItem6 = someProp6.get("p6");
michael@0 304 let objectItem7 = someProp6.get("p7");
michael@0 305 let objectItem8 = someProp6.get("p8");
michael@0 306 let __proto__ = someProp6.get("__proto__");
michael@0 307
michael@0 308 is(objectItem0.visible, true, "The first object item visible state is correct.");
michael@0 309 is(objectItem1.visible, true, "The second object item visible state is correct.");
michael@0 310 is(objectItem2.visible, true, "The third object item visible state is correct.");
michael@0 311 is(objectItem3.visible, true, "The fourth object item visible state is correct.");
michael@0 312 is(objectItem4.visible, true, "The fifth object item visible state is correct.");
michael@0 313 is(objectItem5.visible, true, "The sixth object item visible state is correct.");
michael@0 314 is(objectItem6.visible, true, "The seventh object item visible state is correct.");
michael@0 315 is(objectItem7.visible, true, "The eight object item visible state is correct.");
michael@0 316 is(objectItem8.visible, true, "The ninth object item visible state is correct.");
michael@0 317 is(__proto__.visible, true, "The __proto__ property visible state is correct.");
michael@0 318
michael@0 319 is(objectItem0.expanded, false, "The first object item expanded state is correct.");
michael@0 320 is(objectItem1.expanded, false, "The second object item expanded state is correct.");
michael@0 321 is(objectItem2.expanded, false, "The third object item expanded state is correct.");
michael@0 322 is(objectItem3.expanded, false, "The fourth object item expanded state is correct.");
michael@0 323 is(objectItem4.expanded, false, "The fifth object item expanded state is correct.");
michael@0 324 is(objectItem5.expanded, false, "The sixth object item expanded state is correct.");
michael@0 325 is(objectItem6.expanded, false, "The seventh object item expanded state is correct.");
michael@0 326 is(objectItem7.expanded, true, "The eight object item expanded state is correct.");
michael@0 327 is(objectItem8.expanded, true, "The ninth object item expanded state is correct.");
michael@0 328 is(__proto__.expanded, false, "The __proto__ property expanded state is correct.");
michael@0 329
michael@0 330 is(objectItem0.header, true, "The first object item header state is correct.");
michael@0 331 is(objectItem1.header, true, "The second object item header state is correct.");
michael@0 332 is(objectItem2.header, true, "The third object item header state is correct.");
michael@0 333 is(objectItem3.header, true, "The fourth object item header state is correct.");
michael@0 334 is(objectItem4.header, true, "The fifth object item header state is correct.");
michael@0 335 is(objectItem5.header, true, "The sixth object item header state is correct.");
michael@0 336 is(objectItem6.header, true, "The seventh object item header state is correct.");
michael@0 337 is(objectItem7.header, true, "The eight object item header state is correct.");
michael@0 338 is(objectItem8.header, true, "The ninth object item header state is correct.");
michael@0 339 is(__proto__.header, true, "The __proto__ property header state is correct.");
michael@0 340
michael@0 341 is(objectItem0.twisty, false, "The first object item twisty state is correct.");
michael@0 342 is(objectItem1.twisty, false, "The second object item twisty state is correct.");
michael@0 343 is(objectItem2.twisty, false, "The third object item twisty state is correct.");
michael@0 344 is(objectItem3.twisty, false, "The fourth object item twisty state is correct.");
michael@0 345 is(objectItem4.twisty, false, "The fifth object item twisty state is correct.");
michael@0 346 is(objectItem5.twisty, true, "The sixth object item twisty state is correct.");
michael@0 347 is(objectItem6.twisty, true, "The seventh object item twisty state is correct.");
michael@0 348 is(objectItem7.twisty, true, "The eight object item twisty state is correct.");
michael@0 349 is(objectItem8.twisty, true, "The ninth object item twisty state is correct.");
michael@0 350 is(__proto__.twisty, true, "The __proto__ property twisty state is correct.");
michael@0 351
michael@0 352 is(objectItem0.name, "p0", "The first object item name is correct.");
michael@0 353 is(objectItem1.name, "p1", "The second object item name is correct.");
michael@0 354 is(objectItem2.name, "p2", "The third object item name is correct.");
michael@0 355 is(objectItem3.name, "p3", "The fourth object item name is correct.");
michael@0 356 is(objectItem4.name, "p4", "The fifth object item name is correct.");
michael@0 357 is(objectItem5.name, "p5", "The sixth object item name is correct.");
michael@0 358 is(objectItem6.name, "p6", "The seventh object item name is correct.");
michael@0 359 is(objectItem7.name, "p7", "The eight seventh object item name is correct.");
michael@0 360 is(objectItem8.name, "p8", "The ninth seventh object item name is correct.");
michael@0 361 is(__proto__.name, "__proto__", "The __proto__ property name is correct.");
michael@0 362
michael@0 363 is(objectItem0.value, 42, "The first object item value is correct.");
michael@0 364 is(objectItem1.value, true, "The second object item value is correct.");
michael@0 365 is(objectItem2.value, "nasu", "The third object item value is correct.");
michael@0 366 is(objectItem3.value.type, "undefined", "The fourth object item value is correct.");
michael@0 367 is(objectItem4.value.type, "null", "The fifth object item value is correct.");
michael@0 368 is(objectItem5.value.type, "object", "The sixth object item value type is correct.");
michael@0 369 is(objectItem5.value.class, "Array", "The sixth object item value class is correct.");
michael@0 370 is(objectItem6.value.type, "object", "The seventh object item value type is correct.");
michael@0 371 is(objectItem6.value.class, "Object", "The seventh object item value class is correct.");
michael@0 372 is(objectItem7.value, null, "The eight object item value is correct.");
michael@0 373 isnot(objectItem7.getter, null, "The eight object item getter is correct.");
michael@0 374 isnot(objectItem7.setter, null, "The eight object item setter is correct.");
michael@0 375 is(objectItem7.setter.type, "undefined", "The eight object item setter type is correct.");
michael@0 376 is(objectItem7.getter.type, "object", "The eight object item getter type is correct.");
michael@0 377 is(objectItem7.getter.class, "Function", "The eight object item getter class is correct.");
michael@0 378 is(objectItem8.value, null, "The ninth object item value is correct.");
michael@0 379 isnot(objectItem8.getter, null, "The ninth object item getter is correct.");
michael@0 380 isnot(objectItem8.setter, null, "The ninth object item setter is correct.");
michael@0 381 is(objectItem8.getter.type, "undefined", "The eight object item getter type is correct.");
michael@0 382 is(objectItem8.setter.type, "object", "The ninth object item setter type is correct.");
michael@0 383 is(objectItem8.setter.class, "Function", "The ninth object item setter class is correct.");
michael@0 384 is(__proto__.value.type, "object", "The __proto__ property value type is correct.");
michael@0 385 is(__proto__.value.class, "Object", "The __proto__ property value class is correct.");
michael@0 386 }
michael@0 387
michael@0 388 function testThirdLevelContents() {
michael@0 389 (function() {
michael@0 390 let someProp5 = gVariable.get("someProp5");
michael@0 391 let arrayItem5 = someProp5.get("5");
michael@0 392 let arrayItem6 = someProp5.get("6");
michael@0 393
michael@0 394 is(arrayItem5._store.size, 0, "No properties should be in arrayItem5 before expanding");
michael@0 395 arrayItem5.expand();
michael@0 396 is(arrayItem5._store.size, 5, "Some properties should be in arrayItem5 before expanding");
michael@0 397
michael@0 398 is(arrayItem6._store.size, 0, "No properties should be in arrayItem6 before expanding");
michael@0 399 arrayItem6.expand();
michael@0 400 is(arrayItem6._store.size, 3, "Some properties should be in arrayItem6 before expanding");
michael@0 401
michael@0 402 let arraySubItem0 = arrayItem5.get("0");
michael@0 403 let arraySubItem1 = arrayItem5.get("1");
michael@0 404 let arraySubItem2 = arrayItem5.get("2");
michael@0 405 let objectSubItem0 = arrayItem6.get("prop1");
michael@0 406 let objectSubItem1 = arrayItem6.get("prop2");
michael@0 407
michael@0 408 is(arraySubItem0.value, 0, "The first array sub-item value is correct.");
michael@0 409 is(arraySubItem1.value, 1, "The second array sub-item value is correct.");
michael@0 410 is(arraySubItem2.value, 2, "The third array sub-item value is correct.");
michael@0 411
michael@0 412 is(objectSubItem0.value, 9, "The first object sub-item value is correct.");
michael@0 413 is(objectSubItem1.value, 8, "The second object sub-item value is correct.");
michael@0 414
michael@0 415 let array__proto__ = arrayItem5.get("__proto__");
michael@0 416 let object__proto__ = arrayItem6.get("__proto__");
michael@0 417
michael@0 418 ok(array__proto__, "The array should have a __proto__ property.");
michael@0 419 ok(object__proto__, "The object should have a __proto__ property.");
michael@0 420 })();
michael@0 421
michael@0 422 (function() {
michael@0 423 let someProp6 = gVariable.get("someProp6");
michael@0 424 let objectItem5 = someProp6.get("p5");
michael@0 425 let objectItem6 = someProp6.get("p6");
michael@0 426
michael@0 427 is(objectItem5._store.size, 0, "No properties should be in objectItem5 before expanding");
michael@0 428 objectItem5.expand();
michael@0 429 is(objectItem5._store.size, 5, "Some properties should be in objectItem5 before expanding");
michael@0 430
michael@0 431 is(objectItem6._store.size, 0, "No properties should be in objectItem6 before expanding");
michael@0 432 objectItem6.expand();
michael@0 433 is(objectItem6._store.size, 3, "Some properties should be in objectItem6 before expanding");
michael@0 434
michael@0 435 let arraySubItem0 = objectItem5.get("0");
michael@0 436 let arraySubItem1 = objectItem5.get("1");
michael@0 437 let arraySubItem2 = objectItem5.get("2");
michael@0 438 let objectSubItem0 = objectItem6.get("prop1");
michael@0 439 let objectSubItem1 = objectItem6.get("prop2");
michael@0 440
michael@0 441 is(arraySubItem0.value, 3, "The first array sub-item value is correct.");
michael@0 442 is(arraySubItem1.value, 4, "The second array sub-item value is correct.");
michael@0 443 is(arraySubItem2.value, 5, "The third array sub-item value is correct.");
michael@0 444
michael@0 445 is(objectSubItem0.value, 7, "The first object sub-item value is correct.");
michael@0 446 is(objectSubItem1.value, 6, "The second object sub-item value is correct.");
michael@0 447
michael@0 448 let array__proto__ = objectItem5.get("__proto__");
michael@0 449 let object__proto__ = objectItem6.get("__proto__");
michael@0 450
michael@0 451 ok(array__proto__, "The array should have a __proto__ property.");
michael@0 452 ok(object__proto__, "The object should have a __proto__ property.");
michael@0 453 })();
michael@0 454 }
michael@0 455
michael@0 456 function testOriginalRawDataIntegrity(arr, obj) {
michael@0 457 is(arr[0], 42, "The first array item should not have changed.");
michael@0 458 is(arr[1], true, "The second array item should not have changed.");
michael@0 459 is(arr[2], "nasu", "The third array item should not have changed.");
michael@0 460 is(arr[3], undefined, "The fourth array item should not have changed.");
michael@0 461 is(arr[4], null, "The fifth array item should not have changed.");
michael@0 462 ok(arr[5] instanceof Array, "The sixth array item should be an Array.");
michael@0 463 is(arr[5][0], 0, "The sixth array item should not have changed.");
michael@0 464 is(arr[5][1], 1, "The sixth array item should not have changed.");
michael@0 465 is(arr[5][2], 2, "The sixth array item should not have changed.");
michael@0 466 ok(arr[6] instanceof Object, "The seventh array item should be an Object.");
michael@0 467 is(arr[6].prop1, 9, "The seventh array item should not have changed.");
michael@0 468 is(arr[6].prop2, 8, "The seventh array item should not have changed.");
michael@0 469
michael@0 470 is(obj.p0, 42, "The first object property should not have changed.");
michael@0 471 is(obj.p1, true, "The first object property should not have changed.");
michael@0 472 is(obj.p2, "nasu", "The first object property should not have changed.");
michael@0 473 is(obj.p3, undefined, "The first object property should not have changed.");
michael@0 474 is(obj.p4, null, "The first object property should not have changed.");
michael@0 475 ok(obj.p5 instanceof Array, "The sixth object property should be an Array.");
michael@0 476 is(obj.p5[0], 3, "The sixth object property should not have changed.");
michael@0 477 is(obj.p5[1], 4, "The sixth object property should not have changed.");
michael@0 478 is(obj.p5[2], 5, "The sixth object property should not have changed.");
michael@0 479 ok(obj.p6 instanceof Object, "The seventh object property should be an Object.");
michael@0 480 is(obj.p6.prop1, 7, "The seventh object property should not have changed.");
michael@0 481 is(obj.p6.prop2, 6, "The seventh object property should not have changed.");
michael@0 482 }
michael@0 483
michael@0 484 function testAnonymousHeaders(fooScope, anonymousVar, anonymousScope, barVar, bazProperty) {
michael@0 485 is(fooScope.header, true,
michael@0 486 "A named scope should have a header visible.");
michael@0 487 is(fooScope.target.hasAttribute("untitled"), false,
michael@0 488 "The non-header attribute should not be applied to scopes with headers.");
michael@0 489
michael@0 490 is(anonymousScope.header, false,
michael@0 491 "An anonymous scope should have a header visible.");
michael@0 492 is(anonymousScope.target.hasAttribute("untitled"), true,
michael@0 493 "The non-header attribute should not be applied to scopes without headers.");
michael@0 494
michael@0 495 is(barVar.header, true,
michael@0 496 "A named variable should have a header visible.");
michael@0 497 is(barVar.target.hasAttribute("untitled"), false,
michael@0 498 "The non-header attribute should not be applied to variables with headers.");
michael@0 499
michael@0 500 is(anonymousVar.header, false,
michael@0 501 "An anonymous variable should have a header visible.");
michael@0 502 is(anonymousVar.target.hasAttribute("untitled"), true,
michael@0 503 "The non-header attribute should not be applied to variables without headers.");
michael@0 504 }
michael@0 505
michael@0 506 function testPropertyInheritance(fooScope, anonymousVar, anonymousScope, barVar, bazProperty) {
michael@0 507 is(fooScope.preventDisableOnChange, gVariablesView.preventDisableOnChange,
michael@0 508 "The preventDisableOnChange property should persist from the view to all scopes.");
michael@0 509 is(fooScope.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
michael@0 510 "The preventDescriptorModifiers property should persist from the view to all scopes.");
michael@0 511 is(fooScope.editableNameTooltip, gVariablesView.editableNameTooltip,
michael@0 512 "The editableNameTooltip property should persist from the view to all scopes.");
michael@0 513 is(fooScope.editableValueTooltip, gVariablesView.editableValueTooltip,
michael@0 514 "The editableValueTooltip property should persist from the view to all scopes.");
michael@0 515 is(fooScope.editButtonTooltip, gVariablesView.editButtonTooltip,
michael@0 516 "The editButtonTooltip property should persist from the view to all scopes.");
michael@0 517 is(fooScope.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
michael@0 518 "The deleteButtonTooltip property should persist from the view to all scopes.");
michael@0 519 is(fooScope.contextMenuId, gVariablesView.contextMenuId,
michael@0 520 "The contextMenuId property should persist from the view to all scopes.");
michael@0 521 is(fooScope.separatorStr, gVariablesView.separatorStr,
michael@0 522 "The separatorStr property should persist from the view to all scopes.");
michael@0 523 is(fooScope.eval, gVariablesView.eval,
michael@0 524 "The eval property should persist from the view to all scopes.");
michael@0 525 is(fooScope.switch, gVariablesView.switch,
michael@0 526 "The switch property should persist from the view to all scopes.");
michael@0 527 is(fooScope.delete, gVariablesView.delete,
michael@0 528 "The delete property should persist from the view to all scopes.");
michael@0 529 is(fooScope.new, gVariablesView.new,
michael@0 530 "The new property should persist from the view to all scopes.");
michael@0 531 isnot(fooScope.eval, fooScope.switch,
michael@0 532 "The eval and switch functions got mixed up in the scope.");
michael@0 533 isnot(fooScope.switch, fooScope.delete,
michael@0 534 "The eval and switch functions got mixed up in the scope.");
michael@0 535
michael@0 536 is(barVar.preventDisableOnChange, gVariablesView.preventDisableOnChange,
michael@0 537 "The preventDisableOnChange property should persist from the view to all variables.");
michael@0 538 is(barVar.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
michael@0 539 "The preventDescriptorModifiers property should persist from the view to all variables.");
michael@0 540 is(barVar.editableNameTooltip, gVariablesView.editableNameTooltip,
michael@0 541 "The editableNameTooltip property should persist from the view to all variables.");
michael@0 542 is(barVar.editableValueTooltip, gVariablesView.editableValueTooltip,
michael@0 543 "The editableValueTooltip property should persist from the view to all variables.");
michael@0 544 is(barVar.editButtonTooltip, gVariablesView.editButtonTooltip,
michael@0 545 "The editButtonTooltip property should persist from the view to all variables.");
michael@0 546 is(barVar.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
michael@0 547 "The deleteButtonTooltip property should persist from the view to all variables.");
michael@0 548 is(barVar.contextMenuId, gVariablesView.contextMenuId,
michael@0 549 "The contextMenuId property should persist from the view to all variables.");
michael@0 550 is(barVar.separatorStr, gVariablesView.separatorStr,
michael@0 551 "The separatorStr property should persist from the view to all variables.");
michael@0 552 is(barVar.eval, gVariablesView.eval,
michael@0 553 "The eval property should persist from the view to all variables.");
michael@0 554 is(barVar.switch, gVariablesView.switch,
michael@0 555 "The switch property should persist from the view to all variables.");
michael@0 556 is(barVar.delete, gVariablesView.delete,
michael@0 557 "The delete property should persist from the view to all variables.");
michael@0 558 is(barVar.new, gVariablesView.new,
michael@0 559 "The new property should persist from the view to all variables.");
michael@0 560 isnot(barVar.eval, barVar.switch,
michael@0 561 "The eval and switch functions got mixed up in the variable.");
michael@0 562 isnot(barVar.switch, barVar.delete,
michael@0 563 "The eval and switch functions got mixed up in the variable.");
michael@0 564
michael@0 565 is(bazProperty.preventDisableOnChange, gVariablesView.preventDisableOnChange,
michael@0 566 "The preventDisableOnChange property should persist from the view to all properties.");
michael@0 567 is(bazProperty.preventDescriptorModifiers, gVariablesView.preventDescriptorModifiers,
michael@0 568 "The preventDescriptorModifiers property should persist from the view to all properties.");
michael@0 569 is(bazProperty.editableNameTooltip, gVariablesView.editableNameTooltip,
michael@0 570 "The editableNameTooltip property should persist from the view to all properties.");
michael@0 571 is(bazProperty.editableValueTooltip, gVariablesView.editableValueTooltip,
michael@0 572 "The editableValueTooltip property should persist from the view to all properties.");
michael@0 573 is(bazProperty.editButtonTooltip, gVariablesView.editButtonTooltip,
michael@0 574 "The editButtonTooltip property should persist from the view to all properties.");
michael@0 575 is(bazProperty.deleteButtonTooltip, gVariablesView.deleteButtonTooltip,
michael@0 576 "The deleteButtonTooltip property should persist from the view to all properties.");
michael@0 577 is(bazProperty.contextMenuId, gVariablesView.contextMenuId,
michael@0 578 "The contextMenuId property should persist from the view to all properties.");
michael@0 579 is(bazProperty.separatorStr, gVariablesView.separatorStr,
michael@0 580 "The separatorStr property should persist from the view to all properties.");
michael@0 581 is(bazProperty.eval, gVariablesView.eval,
michael@0 582 "The eval property should persist from the view to all properties.");
michael@0 583 is(bazProperty.switch, gVariablesView.switch,
michael@0 584 "The switch property should persist from the view to all properties.");
michael@0 585 is(bazProperty.delete, gVariablesView.delete,
michael@0 586 "The delete property should persist from the view to all properties.");
michael@0 587 is(bazProperty.new, gVariablesView.new,
michael@0 588 "The new property should persist from the view to all properties.");
michael@0 589 isnot(bazProperty.eval, bazProperty.switch,
michael@0 590 "The eval and switch functions got mixed up in the property.");
michael@0 591 isnot(bazProperty.switch, bazProperty.delete,
michael@0 592 "The eval and switch functions got mixed up in the property.");
michael@0 593 }
michael@0 594
michael@0 595 function testClearHierarchy() {
michael@0 596 gVariablesView.clearHierarchy();
michael@0 597 ok(!gVariablesView._prevHierarchy.size,
michael@0 598 "The previous hierarchy should have been cleared.");
michael@0 599 ok(!gVariablesView._currHierarchy.size,
michael@0 600 "The current hierarchy should have been cleared.");
michael@0 601 }
michael@0 602
michael@0 603 registerCleanupFunction(function() {
michael@0 604 gTab = null;
michael@0 605 gDebuggee = null;
michael@0 606 gPanel = null;
michael@0 607 gDebugger = null;
michael@0 608 gVariablesView = null;
michael@0 609 gScope = null;
michael@0 610 gVariable = null;
michael@0 611 });

mercurial