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 | * Make sure that the variables view displays the right variables and |
michael@0 | 6 | * properties when debugger is paused. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; |
michael@0 | 10 | |
michael@0 | 11 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 12 | let gVariables; |
michael@0 | 13 | |
michael@0 | 14 | function test() { |
michael@0 | 15 | // Debug test slaves are a bit slow at this test. |
michael@0 | 16 | requestLongerTimeout(2); |
michael@0 | 17 | |
michael@0 | 18 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 19 | gTab = aTab; |
michael@0 | 20 | gDebuggee = aDebuggee; |
michael@0 | 21 | gPanel = aPanel; |
michael@0 | 22 | gDebugger = gPanel.panelWin; |
michael@0 | 23 | gVariables = gDebugger.DebuggerView.Variables; |
michael@0 | 24 | |
michael@0 | 25 | waitForSourceAndCaretAndScopes(gPanel, ".html", 24) |
michael@0 | 26 | .then(testScopeVariables) |
michael@0 | 27 | .then(testArgumentsProperties) |
michael@0 | 28 | .then(testSimpleObject) |
michael@0 | 29 | .then(testComplexObject) |
michael@0 | 30 | .then(testArgumentObject) |
michael@0 | 31 | .then(testInnerArgumentObject) |
michael@0 | 32 | .then(testGetterSetterObject) |
michael@0 | 33 | .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) |
michael@0 | 34 | .then(null, aError => { |
michael@0 | 35 | ok(false, "Got an error: " + aError.message + "\n" + aError.stack); |
michael@0 | 36 | }); |
michael@0 | 37 | |
michael@0 | 38 | EventUtils.sendMouseEvent({ type: "click" }, |
michael@0 | 39 | gDebuggee.document.querySelector("button"), |
michael@0 | 40 | gDebuggee); |
michael@0 | 41 | }); |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | function testScopeVariables() { |
michael@0 | 45 | let localScope = gVariables.getScopeAtIndex(0); |
michael@0 | 46 | is(localScope.expanded, true, |
michael@0 | 47 | "The local scope should be expanded by default."); |
michael@0 | 48 | |
michael@0 | 49 | let localEnums = localScope.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 50 | let localNonEnums = localScope.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 51 | |
michael@0 | 52 | is(localEnums.length, 12, |
michael@0 | 53 | "The local scope should contain all the created enumerable elements."); |
michael@0 | 54 | is(localNonEnums.length, 0, |
michael@0 | 55 | "The local scope should contain all the created non-enumerable elements."); |
michael@0 | 56 | |
michael@0 | 57 | is(localEnums[0].querySelector(".name").getAttribute("value"), "this", |
michael@0 | 58 | "Should have the right property name for 'this'."); |
michael@0 | 59 | is(localEnums[0].querySelector(".value").getAttribute("value"), |
michael@0 | 60 | "Window \u2192 doc_frame-parameters.html", |
michael@0 | 61 | "Should have the right property value for 'this'."); |
michael@0 | 62 | ok(localEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 63 | "Should have the right token class for 'this'."); |
michael@0 | 64 | |
michael@0 | 65 | is(localEnums[1].querySelector(".name").getAttribute("value"), "aArg", |
michael@0 | 66 | "Should have the right property name for 'aArg'."); |
michael@0 | 67 | is(localEnums[1].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 68 | "Should have the right property value for 'aArg'."); |
michael@0 | 69 | ok(localEnums[1].querySelector(".value").className.contains("token-other"), |
michael@0 | 70 | "Should have the right token class for 'aArg'."); |
michael@0 | 71 | |
michael@0 | 72 | is(localEnums[2].querySelector(".name").getAttribute("value"), "bArg", |
michael@0 | 73 | "Should have the right property name for 'bArg'."); |
michael@0 | 74 | is(localEnums[2].querySelector(".value").getAttribute("value"), "\"beta\"", |
michael@0 | 75 | "Should have the right property value for 'bArg'."); |
michael@0 | 76 | ok(localEnums[2].querySelector(".value").className.contains("token-string"), |
michael@0 | 77 | "Should have the right token class for 'bArg'."); |
michael@0 | 78 | |
michael@0 | 79 | is(localEnums[3].querySelector(".name").getAttribute("value"), "cArg", |
michael@0 | 80 | "Should have the right property name for 'cArg'."); |
michael@0 | 81 | is(localEnums[3].querySelector(".value").getAttribute("value"), "3", |
michael@0 | 82 | "Should have the right property value for 'cArg'."); |
michael@0 | 83 | ok(localEnums[3].querySelector(".value").className.contains("token-number"), |
michael@0 | 84 | "Should have the right token class for 'cArg'."); |
michael@0 | 85 | |
michael@0 | 86 | is(localEnums[4].querySelector(".name").getAttribute("value"), "dArg", |
michael@0 | 87 | "Should have the right property name for 'dArg'."); |
michael@0 | 88 | is(localEnums[4].querySelector(".value").getAttribute("value"), "false", |
michael@0 | 89 | "Should have the right property value for 'dArg'."); |
michael@0 | 90 | ok(localEnums[4].querySelector(".value").className.contains("token-boolean"), |
michael@0 | 91 | "Should have the right token class for 'dArg'."); |
michael@0 | 92 | |
michael@0 | 93 | is(localEnums[5].querySelector(".name").getAttribute("value"), "eArg", |
michael@0 | 94 | "Should have the right property name for 'eArg'."); |
michael@0 | 95 | is(localEnums[5].querySelector(".value").getAttribute("value"), "null", |
michael@0 | 96 | "Should have the right property value for 'eArg'."); |
michael@0 | 97 | ok(localEnums[5].querySelector(".value").className.contains("token-null"), |
michael@0 | 98 | "Should have the right token class for 'eArg'."); |
michael@0 | 99 | |
michael@0 | 100 | is(localEnums[6].querySelector(".name").getAttribute("value"), "fArg", |
michael@0 | 101 | "Should have the right property name for 'fArg'."); |
michael@0 | 102 | is(localEnums[6].querySelector(".value").getAttribute("value"), "undefined", |
michael@0 | 103 | "Should have the right property value for 'fArg'."); |
michael@0 | 104 | ok(localEnums[6].querySelector(".value").className.contains("token-undefined"), |
michael@0 | 105 | "Should have the right token class for 'fArg'."); |
michael@0 | 106 | |
michael@0 | 107 | is(localEnums[7].querySelector(".name").getAttribute("value"), "a", |
michael@0 | 108 | "Should have the right property name for 'a'."); |
michael@0 | 109 | is(localEnums[7].querySelector(".value").getAttribute("value"), "1", |
michael@0 | 110 | "Should have the right property value for 'a'."); |
michael@0 | 111 | ok(localEnums[7].querySelector(".value").className.contains("token-number"), |
michael@0 | 112 | "Should have the right token class for 'a'."); |
michael@0 | 113 | |
michael@0 | 114 | is(localEnums[8].querySelector(".name").getAttribute("value"), "arguments", |
michael@0 | 115 | "Should have the right property name for 'arguments'."); |
michael@0 | 116 | is(localEnums[8].querySelector(".value").getAttribute("value"), "Arguments", |
michael@0 | 117 | "Should have the right property value for 'arguments'."); |
michael@0 | 118 | ok(localEnums[8].querySelector(".value").className.contains("token-other"), |
michael@0 | 119 | "Should have the right token class for 'arguments'."); |
michael@0 | 120 | |
michael@0 | 121 | is(localEnums[9].querySelector(".name").getAttribute("value"), "b", |
michael@0 | 122 | "Should have the right property name for 'b'."); |
michael@0 | 123 | is(localEnums[9].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 124 | "Should have the right property value for 'b'."); |
michael@0 | 125 | ok(localEnums[9].querySelector(".value").className.contains("token-other"), |
michael@0 | 126 | "Should have the right token class for 'b'."); |
michael@0 | 127 | |
michael@0 | 128 | is(localEnums[10].querySelector(".name").getAttribute("value"), "c", |
michael@0 | 129 | "Should have the right property name for 'c'."); |
michael@0 | 130 | is(localEnums[10].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 131 | "Should have the right property value for 'c'."); |
michael@0 | 132 | ok(localEnums[10].querySelector(".value").className.contains("token-other"), |
michael@0 | 133 | "Should have the right token class for 'c'."); |
michael@0 | 134 | |
michael@0 | 135 | is(localEnums[11].querySelector(".name").getAttribute("value"), "myVar", |
michael@0 | 136 | "Should have the right property name for 'myVar'."); |
michael@0 | 137 | is(localEnums[11].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 138 | "Should have the right property value for 'myVar'."); |
michael@0 | 139 | ok(localEnums[11].querySelector(".value").className.contains("token-other"), |
michael@0 | 140 | "Should have the right token class for 'myVar'."); |
michael@0 | 141 | } |
michael@0 | 142 | |
michael@0 | 143 | function testArgumentsProperties() { |
michael@0 | 144 | let deferred = promise.defer(); |
michael@0 | 145 | |
michael@0 | 146 | let argsVar = gVariables.getScopeAtIndex(0).get("arguments"); |
michael@0 | 147 | is(argsVar.expanded, false, |
michael@0 | 148 | "The 'arguments' variable should not be expanded by default."); |
michael@0 | 149 | |
michael@0 | 150 | let argsEnums = argsVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 151 | let argsNonEnums = argsVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 152 | |
michael@0 | 153 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 154 | is(argsEnums.length, 5, |
michael@0 | 155 | "The 'arguments' variable should contain all the created enumerable elements."); |
michael@0 | 156 | is(argsNonEnums.length, 3, |
michael@0 | 157 | "The 'arguments' variable should contain all the created non-enumerable elements."); |
michael@0 | 158 | |
michael@0 | 159 | is(argsEnums[0].querySelector(".name").getAttribute("value"), "0", |
michael@0 | 160 | "Should have the right property name for '0'."); |
michael@0 | 161 | is(argsEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 162 | "Should have the right property value for '0'."); |
michael@0 | 163 | ok(argsEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 164 | "Should have the right token class for '0'."); |
michael@0 | 165 | |
michael@0 | 166 | is(argsEnums[1].querySelector(".name").getAttribute("value"), "1", |
michael@0 | 167 | "Should have the right property name for '1'."); |
michael@0 | 168 | is(argsEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
michael@0 | 169 | "Should have the right property value for '1'."); |
michael@0 | 170 | ok(argsEnums[1].querySelector(".value").className.contains("token-string"), |
michael@0 | 171 | "Should have the right token class for '1'."); |
michael@0 | 172 | |
michael@0 | 173 | is(argsEnums[2].querySelector(".name").getAttribute("value"), "2", |
michael@0 | 174 | "Should have the right property name for '2'."); |
michael@0 | 175 | is(argsEnums[2].querySelector(".value").getAttribute("value"), "3", |
michael@0 | 176 | "Should have the right property name for '2'."); |
michael@0 | 177 | ok(argsEnums[2].querySelector(".value").className.contains("token-number"), |
michael@0 | 178 | "Should have the right token class for '2'."); |
michael@0 | 179 | |
michael@0 | 180 | is(argsEnums[3].querySelector(".name").getAttribute("value"), "3", |
michael@0 | 181 | "Should have the right property name for '3'."); |
michael@0 | 182 | is(argsEnums[3].querySelector(".value").getAttribute("value"), "false", |
michael@0 | 183 | "Should have the right property value for '3'."); |
michael@0 | 184 | ok(argsEnums[3].querySelector(".value").className.contains("token-boolean"), |
michael@0 | 185 | "Should have the right token class for '3'."); |
michael@0 | 186 | |
michael@0 | 187 | is(argsEnums[4].querySelector(".name").getAttribute("value"), "4", |
michael@0 | 188 | "Should have the right property name for '4'."); |
michael@0 | 189 | is(argsEnums[4].querySelector(".value").getAttribute("value"), "null", |
michael@0 | 190 | "Should have the right property name for '4'."); |
michael@0 | 191 | ok(argsEnums[4].querySelector(".value").className.contains("token-null"), |
michael@0 | 192 | "Should have the right token class for '4'."); |
michael@0 | 193 | |
michael@0 | 194 | is(argsNonEnums[0].querySelector(".name").getAttribute("value"), "callee", |
michael@0 | 195 | "Should have the right property name for 'callee'."); |
michael@0 | 196 | is(argsNonEnums[0].querySelector(".value").getAttribute("value"), |
michael@0 | 197 | "test(aArg,bArg,cArg,dArg,eArg,fArg)", |
michael@0 | 198 | "Should have the right property name for 'callee'."); |
michael@0 | 199 | ok(argsNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 200 | "Should have the right token class for 'callee'."); |
michael@0 | 201 | |
michael@0 | 202 | is(argsNonEnums[1].querySelector(".name").getAttribute("value"), "length", |
michael@0 | 203 | "Should have the right property name for 'length'."); |
michael@0 | 204 | is(argsNonEnums[1].querySelector(".value").getAttribute("value"), "5", |
michael@0 | 205 | "Should have the right property value for 'length'."); |
michael@0 | 206 | ok(argsNonEnums[1].querySelector(".value").className.contains("token-number"), |
michael@0 | 207 | "Should have the right token class for 'length'."); |
michael@0 | 208 | |
michael@0 | 209 | is(argsNonEnums[2].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 210 | "Should have the right property name for '__proto__'."); |
michael@0 | 211 | is(argsNonEnums[2].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 212 | "Should have the right property value for '__proto__'."); |
michael@0 | 213 | ok(argsNonEnums[2].querySelector(".value").className.contains("token-other"), |
michael@0 | 214 | "Should have the right token class for '__proto__'."); |
michael@0 | 215 | |
michael@0 | 216 | deferred.resolve(); |
michael@0 | 217 | }); |
michael@0 | 218 | |
michael@0 | 219 | argsVar.expand(); |
michael@0 | 220 | return deferred.promise; |
michael@0 | 221 | } |
michael@0 | 222 | |
michael@0 | 223 | function testSimpleObject() { |
michael@0 | 224 | let deferred = promise.defer(); |
michael@0 | 225 | |
michael@0 | 226 | let bVar = gVariables.getScopeAtIndex(0).get("b"); |
michael@0 | 227 | is(bVar.expanded, false, |
michael@0 | 228 | "The 'b' variable should not be expanded by default."); |
michael@0 | 229 | |
michael@0 | 230 | let bEnums = bVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 231 | let bNonEnums = bVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 232 | |
michael@0 | 233 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 234 | is(bEnums.length, 1, |
michael@0 | 235 | "The 'b' variable should contain all the created enumerable elements."); |
michael@0 | 236 | is(bNonEnums.length, 1, |
michael@0 | 237 | "The 'b' variable should contain all the created non-enumerable elements."); |
michael@0 | 238 | |
michael@0 | 239 | is(bEnums[0].querySelector(".name").getAttribute("value"), "a", |
michael@0 | 240 | "Should have the right property name for 'a'."); |
michael@0 | 241 | is(bEnums[0].querySelector(".value").getAttribute("value"), "1", |
michael@0 | 242 | "Should have the right property value for 'a'."); |
michael@0 | 243 | ok(bEnums[0].querySelector(".value").className.contains("token-number"), |
michael@0 | 244 | "Should have the right token class for 'a'."); |
michael@0 | 245 | |
michael@0 | 246 | is(bNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 247 | "Should have the right property name for '__proto__'."); |
michael@0 | 248 | is(bNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 249 | "Should have the right property value for '__proto__'."); |
michael@0 | 250 | ok(bNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 251 | "Should have the right token class for '__proto__'."); |
michael@0 | 252 | |
michael@0 | 253 | deferred.resolve(); |
michael@0 | 254 | }); |
michael@0 | 255 | |
michael@0 | 256 | bVar.expand(); |
michael@0 | 257 | return deferred.promise; |
michael@0 | 258 | } |
michael@0 | 259 | |
michael@0 | 260 | function testComplexObject() { |
michael@0 | 261 | let deferred = promise.defer(); |
michael@0 | 262 | |
michael@0 | 263 | let cVar = gVariables.getScopeAtIndex(0).get("c"); |
michael@0 | 264 | is(cVar.expanded, false, |
michael@0 | 265 | "The 'c' variable should not be expanded by default."); |
michael@0 | 266 | |
michael@0 | 267 | let cEnums = cVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 268 | let cNonEnums = cVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 269 | |
michael@0 | 270 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 271 | is(cEnums.length, 6, |
michael@0 | 272 | "The 'c' variable should contain all the created enumerable elements."); |
michael@0 | 273 | is(cNonEnums.length, 1, |
michael@0 | 274 | "The 'c' variable should contain all the created non-enumerable elements."); |
michael@0 | 275 | |
michael@0 | 276 | is(cEnums[0].querySelector(".name").getAttribute("value"), "a", |
michael@0 | 277 | "Should have the right property name for 'a'."); |
michael@0 | 278 | is(cEnums[0].querySelector(".value").getAttribute("value"), "1", |
michael@0 | 279 | "Should have the right property value for 'a'."); |
michael@0 | 280 | ok(cEnums[0].querySelector(".value").className.contains("token-number"), |
michael@0 | 281 | "Should have the right token class for 'a'."); |
michael@0 | 282 | |
michael@0 | 283 | is(cEnums[1].querySelector(".name").getAttribute("value"), "b", |
michael@0 | 284 | "Should have the right property name for 'b'."); |
michael@0 | 285 | is(cEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
michael@0 | 286 | "Should have the right property value for 'b'."); |
michael@0 | 287 | ok(cEnums[1].querySelector(".value").className.contains("token-string"), |
michael@0 | 288 | "Should have the right token class for 'b'."); |
michael@0 | 289 | |
michael@0 | 290 | is(cEnums[2].querySelector(".name").getAttribute("value"), "c", |
michael@0 | 291 | "Should have the right property name for 'c'."); |
michael@0 | 292 | is(cEnums[2].querySelector(".value").getAttribute("value"), "3", |
michael@0 | 293 | "Should have the right property value for 'c'."); |
michael@0 | 294 | ok(cEnums[2].querySelector(".value").className.contains("token-number"), |
michael@0 | 295 | "Should have the right token class for 'c'."); |
michael@0 | 296 | |
michael@0 | 297 | is(cEnums[3].querySelector(".name").getAttribute("value"), "d", |
michael@0 | 298 | "Should have the right property name for 'd'."); |
michael@0 | 299 | is(cEnums[3].querySelector(".value").getAttribute("value"), "false", |
michael@0 | 300 | "Should have the right property value for 'd'."); |
michael@0 | 301 | ok(cEnums[3].querySelector(".value").className.contains("token-boolean"), |
michael@0 | 302 | "Should have the right token class for 'd'."); |
michael@0 | 303 | |
michael@0 | 304 | is(cEnums[4].querySelector(".name").getAttribute("value"), "e", |
michael@0 | 305 | "Should have the right property name for 'e'."); |
michael@0 | 306 | is(cEnums[4].querySelector(".value").getAttribute("value"), "null", |
michael@0 | 307 | "Should have the right property value for 'e'."); |
michael@0 | 308 | ok(cEnums[4].querySelector(".value").className.contains("token-null"), |
michael@0 | 309 | "Should have the right token class for 'e'."); |
michael@0 | 310 | |
michael@0 | 311 | is(cEnums[5].querySelector(".name").getAttribute("value"), "f", |
michael@0 | 312 | "Should have the right property name for 'f'."); |
michael@0 | 313 | is(cEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
michael@0 | 314 | "Should have the right property value for 'f'."); |
michael@0 | 315 | ok(cEnums[5].querySelector(".value").className.contains("token-undefined"), |
michael@0 | 316 | "Should have the right token class for 'f'."); |
michael@0 | 317 | |
michael@0 | 318 | is(cNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 319 | "Should have the right property name for '__proto__'."); |
michael@0 | 320 | is(cNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 321 | "Should have the right property value for '__proto__'."); |
michael@0 | 322 | ok(cNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 323 | "Should have the right token class for '__proto__'."); |
michael@0 | 324 | |
michael@0 | 325 | deferred.resolve(); |
michael@0 | 326 | }); |
michael@0 | 327 | |
michael@0 | 328 | cVar.expand(); |
michael@0 | 329 | return deferred.promise; |
michael@0 | 330 | } |
michael@0 | 331 | |
michael@0 | 332 | function testArgumentObject() { |
michael@0 | 333 | let deferred = promise.defer(); |
michael@0 | 334 | |
michael@0 | 335 | let argVar = gVariables.getScopeAtIndex(0).get("aArg"); |
michael@0 | 336 | is(argVar.expanded, false, |
michael@0 | 337 | "The 'aArg' variable should not be expanded by default."); |
michael@0 | 338 | |
michael@0 | 339 | let argEnums = argVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 340 | let argNonEnums = argVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 341 | |
michael@0 | 342 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 343 | is(argEnums.length, 6, |
michael@0 | 344 | "The 'aArg' variable should contain all the created enumerable elements."); |
michael@0 | 345 | is(argNonEnums.length, 1, |
michael@0 | 346 | "The 'aArg' variable should contain all the created non-enumerable elements."); |
michael@0 | 347 | |
michael@0 | 348 | is(argEnums[0].querySelector(".name").getAttribute("value"), "a", |
michael@0 | 349 | "Should have the right property name for 'a'."); |
michael@0 | 350 | is(argEnums[0].querySelector(".value").getAttribute("value"), "1", |
michael@0 | 351 | "Should have the right property value for 'a'."); |
michael@0 | 352 | ok(argEnums[0].querySelector(".value").className.contains("token-number"), |
michael@0 | 353 | "Should have the right token class for 'a'."); |
michael@0 | 354 | |
michael@0 | 355 | is(argEnums[1].querySelector(".name").getAttribute("value"), "b", |
michael@0 | 356 | "Should have the right property name for 'b'."); |
michael@0 | 357 | is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
michael@0 | 358 | "Should have the right property value for 'b'."); |
michael@0 | 359 | ok(argEnums[1].querySelector(".value").className.contains("token-string"), |
michael@0 | 360 | "Should have the right token class for 'b'."); |
michael@0 | 361 | |
michael@0 | 362 | is(argEnums[2].querySelector(".name").getAttribute("value"), "c", |
michael@0 | 363 | "Should have the right property name for 'c'."); |
michael@0 | 364 | is(argEnums[2].querySelector(".value").getAttribute("value"), "3", |
michael@0 | 365 | "Should have the right property value for 'c'."); |
michael@0 | 366 | ok(argEnums[2].querySelector(".value").className.contains("token-number"), |
michael@0 | 367 | "Should have the right token class for 'c'."); |
michael@0 | 368 | |
michael@0 | 369 | is(argEnums[3].querySelector(".name").getAttribute("value"), "d", |
michael@0 | 370 | "Should have the right property name for 'd'."); |
michael@0 | 371 | is(argEnums[3].querySelector(".value").getAttribute("value"), "false", |
michael@0 | 372 | "Should have the right property value for 'd'."); |
michael@0 | 373 | ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), |
michael@0 | 374 | "Should have the right token class for 'd'."); |
michael@0 | 375 | |
michael@0 | 376 | is(argEnums[4].querySelector(".name").getAttribute("value"), "e", |
michael@0 | 377 | "Should have the right property name for 'e'."); |
michael@0 | 378 | is(argEnums[4].querySelector(".value").getAttribute("value"), "null", |
michael@0 | 379 | "Should have the right property value for 'e'."); |
michael@0 | 380 | ok(argEnums[4].querySelector(".value").className.contains("token-null"), |
michael@0 | 381 | "Should have the right token class for 'e'."); |
michael@0 | 382 | |
michael@0 | 383 | is(argEnums[5].querySelector(".name").getAttribute("value"), "f", |
michael@0 | 384 | "Should have the right property name for 'f'."); |
michael@0 | 385 | is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
michael@0 | 386 | "Should have the right property value for 'f'."); |
michael@0 | 387 | ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), |
michael@0 | 388 | "Should have the right token class for 'f'."); |
michael@0 | 389 | |
michael@0 | 390 | is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 391 | "Should have the right property name for '__proto__'."); |
michael@0 | 392 | is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 393 | "Should have the right property value for '__proto__'."); |
michael@0 | 394 | ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 395 | "Should have the right token class for '__proto__'."); |
michael@0 | 396 | |
michael@0 | 397 | deferred.resolve(); |
michael@0 | 398 | }); |
michael@0 | 399 | |
michael@0 | 400 | argVar.expand(); |
michael@0 | 401 | return deferred.promise; |
michael@0 | 402 | } |
michael@0 | 403 | |
michael@0 | 404 | function testInnerArgumentObject() { |
michael@0 | 405 | let deferred = promise.defer(); |
michael@0 | 406 | |
michael@0 | 407 | let argProp = gVariables.getScopeAtIndex(0).get("arguments").get("0"); |
michael@0 | 408 | is(argProp.expanded, false, |
michael@0 | 409 | "The 'arguments[0]' property should not be expanded by default."); |
michael@0 | 410 | |
michael@0 | 411 | let argEnums = argProp.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 412 | let argNonEnums = argProp.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 413 | |
michael@0 | 414 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 415 | is(argEnums.length, 6, |
michael@0 | 416 | "The 'arguments[0]' property should contain all the created enumerable elements."); |
michael@0 | 417 | is(argNonEnums.length, 1, |
michael@0 | 418 | "The 'arguments[0]' property should contain all the created non-enumerable elements."); |
michael@0 | 419 | |
michael@0 | 420 | is(argEnums[0].querySelector(".name").getAttribute("value"), "a", |
michael@0 | 421 | "Should have the right property name for 'a'."); |
michael@0 | 422 | is(argEnums[0].querySelector(".value").getAttribute("value"), "1", |
michael@0 | 423 | "Should have the right property value for 'a'."); |
michael@0 | 424 | ok(argEnums[0].querySelector(".value").className.contains("token-number"), |
michael@0 | 425 | "Should have the right token class for 'a'."); |
michael@0 | 426 | |
michael@0 | 427 | is(argEnums[1].querySelector(".name").getAttribute("value"), "b", |
michael@0 | 428 | "Should have the right property name for 'b'."); |
michael@0 | 429 | is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", |
michael@0 | 430 | "Should have the right property value for 'b'."); |
michael@0 | 431 | ok(argEnums[1].querySelector(".value").className.contains("token-string"), |
michael@0 | 432 | "Should have the right token class for 'b'."); |
michael@0 | 433 | |
michael@0 | 434 | is(argEnums[2].querySelector(".name").getAttribute("value"), "c", |
michael@0 | 435 | "Should have the right property name for 'c'."); |
michael@0 | 436 | is(argEnums[2].querySelector(".value").getAttribute("value"), "3", |
michael@0 | 437 | "Should have the right property value for 'c'."); |
michael@0 | 438 | ok(argEnums[2].querySelector(".value").className.contains("token-number"), |
michael@0 | 439 | "Should have the right token class for 'c'."); |
michael@0 | 440 | |
michael@0 | 441 | is(argEnums[3].querySelector(".name").getAttribute("value"), "d", |
michael@0 | 442 | "Should have the right property name for 'd'."); |
michael@0 | 443 | is(argEnums[3].querySelector(".value").getAttribute("value"), "false", |
michael@0 | 444 | "Should have the right property value for 'd'."); |
michael@0 | 445 | ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), |
michael@0 | 446 | "Should have the right token class for 'd'."); |
michael@0 | 447 | |
michael@0 | 448 | is(argEnums[4].querySelector(".name").getAttribute("value"), "e", |
michael@0 | 449 | "Should have the right property name for 'e'."); |
michael@0 | 450 | is(argEnums[4].querySelector(".value").getAttribute("value"), "null", |
michael@0 | 451 | "Should have the right property value for 'e'."); |
michael@0 | 452 | ok(argEnums[4].querySelector(".value").className.contains("token-null"), |
michael@0 | 453 | "Should have the right token class for 'e'."); |
michael@0 | 454 | |
michael@0 | 455 | is(argEnums[5].querySelector(".name").getAttribute("value"), "f", |
michael@0 | 456 | "Should have the right property name for 'f'."); |
michael@0 | 457 | is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", |
michael@0 | 458 | "Should have the right property value for 'f'."); |
michael@0 | 459 | ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), |
michael@0 | 460 | "Should have the right token class for 'f'."); |
michael@0 | 461 | |
michael@0 | 462 | is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 463 | "Should have the right property name for '__proto__'."); |
michael@0 | 464 | is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 465 | "Should have the right property value for '__proto__'."); |
michael@0 | 466 | ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 467 | "Should have the right token class for '__proto__'."); |
michael@0 | 468 | |
michael@0 | 469 | deferred.resolve(); |
michael@0 | 470 | }); |
michael@0 | 471 | |
michael@0 | 472 | argProp.expand(); |
michael@0 | 473 | return deferred.promise; |
michael@0 | 474 | } |
michael@0 | 475 | |
michael@0 | 476 | function testGetterSetterObject() { |
michael@0 | 477 | let deferred = promise.defer(); |
michael@0 | 478 | |
michael@0 | 479 | let myVar = gVariables.getScopeAtIndex(0).get("myVar"); |
michael@0 | 480 | is(myVar.expanded, false, |
michael@0 | 481 | "The myVar variable should not be expanded by default."); |
michael@0 | 482 | |
michael@0 | 483 | let myVarEnums = myVar.target.querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 484 | let myVarNonEnums = myVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 485 | |
michael@0 | 486 | gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { |
michael@0 | 487 | is(myVarEnums.length, 2, |
michael@0 | 488 | "The myVar should contain all the created enumerable elements."); |
michael@0 | 489 | is(myVarNonEnums.length, 1, |
michael@0 | 490 | "The myVar should contain all the created non-enumerable elements."); |
michael@0 | 491 | |
michael@0 | 492 | is(myVarEnums[0].querySelector(".name").getAttribute("value"), "_prop", |
michael@0 | 493 | "Should have the right property name for '_prop'."); |
michael@0 | 494 | is(myVarEnums[0].querySelector(".value").getAttribute("value"), "42", |
michael@0 | 495 | "Should have the right property value for '_prop'."); |
michael@0 | 496 | ok(myVarEnums[0].querySelector(".value").className.contains("token-number"), |
michael@0 | 497 | "Should have the right token class for '_prop'."); |
michael@0 | 498 | |
michael@0 | 499 | is(myVarEnums[1].querySelector(".name").getAttribute("value"), "prop", |
michael@0 | 500 | "Should have the right property name for 'prop'."); |
michael@0 | 501 | is(myVarEnums[1].querySelector(".value").getAttribute("value"), "", |
michael@0 | 502 | "Should have the right property value for 'prop'."); |
michael@0 | 503 | ok(!myVarEnums[1].querySelector(".value").className.contains("token"), |
michael@0 | 504 | "Should have no token class for 'prop'."); |
michael@0 | 505 | |
michael@0 | 506 | is(myVarNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", |
michael@0 | 507 | "Should have the right property name for '__proto__'."); |
michael@0 | 508 | is(myVarNonEnums[0].querySelector(".value").getAttribute("value"), "Object", |
michael@0 | 509 | "Should have the right property value for '__proto__'."); |
michael@0 | 510 | ok(myVarNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 511 | "Should have the right token class for '__proto__'."); |
michael@0 | 512 | |
michael@0 | 513 | let propEnums = myVarEnums[1].querySelector(".variables-view-element-details.enum").childNodes; |
michael@0 | 514 | let propNonEnums = myVarEnums[1].querySelector(".variables-view-element-details.nonenum").childNodes; |
michael@0 | 515 | |
michael@0 | 516 | is(propEnums.length, 0, |
michael@0 | 517 | "The propEnums should contain all the created enumerable elements."); |
michael@0 | 518 | is(propNonEnums.length, 2, |
michael@0 | 519 | "The propEnums should contain all the created non-enumerable elements."); |
michael@0 | 520 | |
michael@0 | 521 | is(propNonEnums[0].querySelector(".name").getAttribute("value"), "get", |
michael@0 | 522 | "Should have the right property name for 'get'."); |
michael@0 | 523 | is(propNonEnums[0].querySelector(".value").getAttribute("value"), |
michael@0 | 524 | "test/myVar.prop()", |
michael@0 | 525 | "Should have the right property value for 'get'."); |
michael@0 | 526 | ok(propNonEnums[0].querySelector(".value").className.contains("token-other"), |
michael@0 | 527 | "Should have the right token class for 'get'."); |
michael@0 | 528 | |
michael@0 | 529 | is(propNonEnums[1].querySelector(".name").getAttribute("value"), "set", |
michael@0 | 530 | "Should have the right property name for 'set'."); |
michael@0 | 531 | is(propNonEnums[1].querySelector(".value").getAttribute("value"), |
michael@0 | 532 | "test/myVar.prop(val)", |
michael@0 | 533 | "Should have the right property value for 'set'."); |
michael@0 | 534 | ok(propNonEnums[1].querySelector(".value").className.contains("token-other"), |
michael@0 | 535 | "Should have the right token class for 'set'."); |
michael@0 | 536 | |
michael@0 | 537 | deferred.resolve(); |
michael@0 | 538 | }); |
michael@0 | 539 | |
michael@0 | 540 | myVar.expand(); |
michael@0 | 541 | return deferred.promise; |
michael@0 | 542 | } |
michael@0 | 543 | |
michael@0 | 544 | registerCleanupFunction(function() { |
michael@0 | 545 | gTab = null; |
michael@0 | 546 | gDebuggee = null; |
michael@0 | 547 | gPanel = null; |
michael@0 | 548 | gDebugger = null; |
michael@0 | 549 | gVariables = null; |
michael@0 | 550 | }); |