michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Make sure that the variables view displays the right variables and michael@0: * properties when debugger is paused. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gVariables; michael@0: michael@0: function test() { michael@0: // Debug test slaves are a bit slow at this test. michael@0: requestLongerTimeout(2); michael@0: michael@0: initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { michael@0: gTab = aTab; michael@0: gDebuggee = aDebuggee; michael@0: gPanel = aPanel; michael@0: gDebugger = gPanel.panelWin; michael@0: gVariables = gDebugger.DebuggerView.Variables; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 24) michael@0: .then(testScopeVariables) michael@0: .then(testArgumentsProperties) michael@0: .then(testSimpleObject) michael@0: .then(testComplexObject) michael@0: .then(testArgumentObject) michael@0: .then(testInnerArgumentObject) michael@0: .then(testGetterSetterObject) michael@0: .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) michael@0: .then(null, aError => { michael@0: ok(false, "Got an error: " + aError.message + "\n" + aError.stack); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.querySelector("button"), michael@0: gDebuggee); michael@0: }); michael@0: } michael@0: michael@0: function testScopeVariables() { michael@0: let localScope = gVariables.getScopeAtIndex(0); michael@0: is(localScope.expanded, true, michael@0: "The local scope should be expanded by default."); michael@0: michael@0: let localEnums = localScope.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let localNonEnums = localScope.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: is(localEnums.length, 12, michael@0: "The local scope should contain all the created enumerable elements."); michael@0: is(localNonEnums.length, 0, michael@0: "The local scope should contain all the created non-enumerable elements."); michael@0: michael@0: is(localEnums[0].querySelector(".name").getAttribute("value"), "this", michael@0: "Should have the right property name for 'this'."); michael@0: is(localEnums[0].querySelector(".value").getAttribute("value"), michael@0: "Window \u2192 doc_frame-parameters.html", michael@0: "Should have the right property value for 'this'."); michael@0: ok(localEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'this'."); michael@0: michael@0: is(localEnums[1].querySelector(".name").getAttribute("value"), "aArg", michael@0: "Should have the right property name for 'aArg'."); michael@0: is(localEnums[1].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for 'aArg'."); michael@0: ok(localEnums[1].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'aArg'."); michael@0: michael@0: is(localEnums[2].querySelector(".name").getAttribute("value"), "bArg", michael@0: "Should have the right property name for 'bArg'."); michael@0: is(localEnums[2].querySelector(".value").getAttribute("value"), "\"beta\"", michael@0: "Should have the right property value for 'bArg'."); michael@0: ok(localEnums[2].querySelector(".value").className.contains("token-string"), michael@0: "Should have the right token class for 'bArg'."); michael@0: michael@0: is(localEnums[3].querySelector(".name").getAttribute("value"), "cArg", michael@0: "Should have the right property name for 'cArg'."); michael@0: is(localEnums[3].querySelector(".value").getAttribute("value"), "3", michael@0: "Should have the right property value for 'cArg'."); michael@0: ok(localEnums[3].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'cArg'."); michael@0: michael@0: is(localEnums[4].querySelector(".name").getAttribute("value"), "dArg", michael@0: "Should have the right property name for 'dArg'."); michael@0: is(localEnums[4].querySelector(".value").getAttribute("value"), "false", michael@0: "Should have the right property value for 'dArg'."); michael@0: ok(localEnums[4].querySelector(".value").className.contains("token-boolean"), michael@0: "Should have the right token class for 'dArg'."); michael@0: michael@0: is(localEnums[5].querySelector(".name").getAttribute("value"), "eArg", michael@0: "Should have the right property name for 'eArg'."); michael@0: is(localEnums[5].querySelector(".value").getAttribute("value"), "null", michael@0: "Should have the right property value for 'eArg'."); michael@0: ok(localEnums[5].querySelector(".value").className.contains("token-null"), michael@0: "Should have the right token class for 'eArg'."); michael@0: michael@0: is(localEnums[6].querySelector(".name").getAttribute("value"), "fArg", michael@0: "Should have the right property name for 'fArg'."); michael@0: is(localEnums[6].querySelector(".value").getAttribute("value"), "undefined", michael@0: "Should have the right property value for 'fArg'."); michael@0: ok(localEnums[6].querySelector(".value").className.contains("token-undefined"), michael@0: "Should have the right token class for 'fArg'."); michael@0: michael@0: is(localEnums[7].querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right property name for 'a'."); michael@0: is(localEnums[7].querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right property value for 'a'."); michael@0: ok(localEnums[7].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'a'."); michael@0: michael@0: is(localEnums[8].querySelector(".name").getAttribute("value"), "arguments", michael@0: "Should have the right property name for 'arguments'."); michael@0: is(localEnums[8].querySelector(".value").getAttribute("value"), "Arguments", michael@0: "Should have the right property value for 'arguments'."); michael@0: ok(localEnums[8].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'arguments'."); michael@0: michael@0: is(localEnums[9].querySelector(".name").getAttribute("value"), "b", michael@0: "Should have the right property name for 'b'."); michael@0: is(localEnums[9].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for 'b'."); michael@0: ok(localEnums[9].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'b'."); michael@0: michael@0: is(localEnums[10].querySelector(".name").getAttribute("value"), "c", michael@0: "Should have the right property name for 'c'."); michael@0: is(localEnums[10].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for 'c'."); michael@0: ok(localEnums[10].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'c'."); michael@0: michael@0: is(localEnums[11].querySelector(".name").getAttribute("value"), "myVar", michael@0: "Should have the right property name for 'myVar'."); michael@0: is(localEnums[11].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for 'myVar'."); michael@0: ok(localEnums[11].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'myVar'."); michael@0: } michael@0: michael@0: function testArgumentsProperties() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let argsVar = gVariables.getScopeAtIndex(0).get("arguments"); michael@0: is(argsVar.expanded, false, michael@0: "The 'arguments' variable should not be expanded by default."); michael@0: michael@0: let argsEnums = argsVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let argsNonEnums = argsVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(argsEnums.length, 5, michael@0: "The 'arguments' variable should contain all the created enumerable elements."); michael@0: is(argsNonEnums.length, 3, michael@0: "The 'arguments' variable should contain all the created non-enumerable elements."); michael@0: michael@0: is(argsEnums[0].querySelector(".name").getAttribute("value"), "0", michael@0: "Should have the right property name for '0'."); michael@0: is(argsEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '0'."); michael@0: ok(argsEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '0'."); michael@0: michael@0: is(argsEnums[1].querySelector(".name").getAttribute("value"), "1", michael@0: "Should have the right property name for '1'."); michael@0: is(argsEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", michael@0: "Should have the right property value for '1'."); michael@0: ok(argsEnums[1].querySelector(".value").className.contains("token-string"), michael@0: "Should have the right token class for '1'."); michael@0: michael@0: is(argsEnums[2].querySelector(".name").getAttribute("value"), "2", michael@0: "Should have the right property name for '2'."); michael@0: is(argsEnums[2].querySelector(".value").getAttribute("value"), "3", michael@0: "Should have the right property name for '2'."); michael@0: ok(argsEnums[2].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for '2'."); michael@0: michael@0: is(argsEnums[3].querySelector(".name").getAttribute("value"), "3", michael@0: "Should have the right property name for '3'."); michael@0: is(argsEnums[3].querySelector(".value").getAttribute("value"), "false", michael@0: "Should have the right property value for '3'."); michael@0: ok(argsEnums[3].querySelector(".value").className.contains("token-boolean"), michael@0: "Should have the right token class for '3'."); michael@0: michael@0: is(argsEnums[4].querySelector(".name").getAttribute("value"), "4", michael@0: "Should have the right property name for '4'."); michael@0: is(argsEnums[4].querySelector(".value").getAttribute("value"), "null", michael@0: "Should have the right property name for '4'."); michael@0: ok(argsEnums[4].querySelector(".value").className.contains("token-null"), michael@0: "Should have the right token class for '4'."); michael@0: michael@0: is(argsNonEnums[0].querySelector(".name").getAttribute("value"), "callee", michael@0: "Should have the right property name for 'callee'."); michael@0: is(argsNonEnums[0].querySelector(".value").getAttribute("value"), michael@0: "test(aArg,bArg,cArg,dArg,eArg,fArg)", michael@0: "Should have the right property name for 'callee'."); michael@0: ok(argsNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'callee'."); michael@0: michael@0: is(argsNonEnums[1].querySelector(".name").getAttribute("value"), "length", michael@0: "Should have the right property name for 'length'."); michael@0: is(argsNonEnums[1].querySelector(".value").getAttribute("value"), "5", michael@0: "Should have the right property value for 'length'."); michael@0: ok(argsNonEnums[1].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'length'."); michael@0: michael@0: is(argsNonEnums[2].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(argsNonEnums[2].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(argsNonEnums[2].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: argsVar.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testSimpleObject() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let bVar = gVariables.getScopeAtIndex(0).get("b"); michael@0: is(bVar.expanded, false, michael@0: "The 'b' variable should not be expanded by default."); michael@0: michael@0: let bEnums = bVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let bNonEnums = bVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(bEnums.length, 1, michael@0: "The 'b' variable should contain all the created enumerable elements."); michael@0: is(bNonEnums.length, 1, michael@0: "The 'b' variable should contain all the created non-enumerable elements."); michael@0: michael@0: is(bEnums[0].querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right property name for 'a'."); michael@0: is(bEnums[0].querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right property value for 'a'."); michael@0: ok(bEnums[0].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'a'."); michael@0: michael@0: is(bNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(bNonEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(bNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: bVar.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testComplexObject() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let cVar = gVariables.getScopeAtIndex(0).get("c"); michael@0: is(cVar.expanded, false, michael@0: "The 'c' variable should not be expanded by default."); michael@0: michael@0: let cEnums = cVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let cNonEnums = cVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(cEnums.length, 6, michael@0: "The 'c' variable should contain all the created enumerable elements."); michael@0: is(cNonEnums.length, 1, michael@0: "The 'c' variable should contain all the created non-enumerable elements."); michael@0: michael@0: is(cEnums[0].querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right property name for 'a'."); michael@0: is(cEnums[0].querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right property value for 'a'."); michael@0: ok(cEnums[0].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'a'."); michael@0: michael@0: is(cEnums[1].querySelector(".name").getAttribute("value"), "b", michael@0: "Should have the right property name for 'b'."); michael@0: is(cEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", michael@0: "Should have the right property value for 'b'."); michael@0: ok(cEnums[1].querySelector(".value").className.contains("token-string"), michael@0: "Should have the right token class for 'b'."); michael@0: michael@0: is(cEnums[2].querySelector(".name").getAttribute("value"), "c", michael@0: "Should have the right property name for 'c'."); michael@0: is(cEnums[2].querySelector(".value").getAttribute("value"), "3", michael@0: "Should have the right property value for 'c'."); michael@0: ok(cEnums[2].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'c'."); michael@0: michael@0: is(cEnums[3].querySelector(".name").getAttribute("value"), "d", michael@0: "Should have the right property name for 'd'."); michael@0: is(cEnums[3].querySelector(".value").getAttribute("value"), "false", michael@0: "Should have the right property value for 'd'."); michael@0: ok(cEnums[3].querySelector(".value").className.contains("token-boolean"), michael@0: "Should have the right token class for 'd'."); michael@0: michael@0: is(cEnums[4].querySelector(".name").getAttribute("value"), "e", michael@0: "Should have the right property name for 'e'."); michael@0: is(cEnums[4].querySelector(".value").getAttribute("value"), "null", michael@0: "Should have the right property value for 'e'."); michael@0: ok(cEnums[4].querySelector(".value").className.contains("token-null"), michael@0: "Should have the right token class for 'e'."); michael@0: michael@0: is(cEnums[5].querySelector(".name").getAttribute("value"), "f", michael@0: "Should have the right property name for 'f'."); michael@0: is(cEnums[5].querySelector(".value").getAttribute("value"), "undefined", michael@0: "Should have the right property value for 'f'."); michael@0: ok(cEnums[5].querySelector(".value").className.contains("token-undefined"), michael@0: "Should have the right token class for 'f'."); michael@0: michael@0: is(cNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(cNonEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(cNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: cVar.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testArgumentObject() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let argVar = gVariables.getScopeAtIndex(0).get("aArg"); michael@0: is(argVar.expanded, false, michael@0: "The 'aArg' variable should not be expanded by default."); michael@0: michael@0: let argEnums = argVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let argNonEnums = argVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(argEnums.length, 6, michael@0: "The 'aArg' variable should contain all the created enumerable elements."); michael@0: is(argNonEnums.length, 1, michael@0: "The 'aArg' variable should contain all the created non-enumerable elements."); michael@0: michael@0: is(argEnums[0].querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right property name for 'a'."); michael@0: is(argEnums[0].querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right property value for 'a'."); michael@0: ok(argEnums[0].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'a'."); michael@0: michael@0: is(argEnums[1].querySelector(".name").getAttribute("value"), "b", michael@0: "Should have the right property name for 'b'."); michael@0: is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", michael@0: "Should have the right property value for 'b'."); michael@0: ok(argEnums[1].querySelector(".value").className.contains("token-string"), michael@0: "Should have the right token class for 'b'."); michael@0: michael@0: is(argEnums[2].querySelector(".name").getAttribute("value"), "c", michael@0: "Should have the right property name for 'c'."); michael@0: is(argEnums[2].querySelector(".value").getAttribute("value"), "3", michael@0: "Should have the right property value for 'c'."); michael@0: ok(argEnums[2].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'c'."); michael@0: michael@0: is(argEnums[3].querySelector(".name").getAttribute("value"), "d", michael@0: "Should have the right property name for 'd'."); michael@0: is(argEnums[3].querySelector(".value").getAttribute("value"), "false", michael@0: "Should have the right property value for 'd'."); michael@0: ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), michael@0: "Should have the right token class for 'd'."); michael@0: michael@0: is(argEnums[4].querySelector(".name").getAttribute("value"), "e", michael@0: "Should have the right property name for 'e'."); michael@0: is(argEnums[4].querySelector(".value").getAttribute("value"), "null", michael@0: "Should have the right property value for 'e'."); michael@0: ok(argEnums[4].querySelector(".value").className.contains("token-null"), michael@0: "Should have the right token class for 'e'."); michael@0: michael@0: is(argEnums[5].querySelector(".name").getAttribute("value"), "f", michael@0: "Should have the right property name for 'f'."); michael@0: is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", michael@0: "Should have the right property value for 'f'."); michael@0: ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), michael@0: "Should have the right token class for 'f'."); michael@0: michael@0: is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: argVar.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testInnerArgumentObject() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let argProp = gVariables.getScopeAtIndex(0).get("arguments").get("0"); michael@0: is(argProp.expanded, false, michael@0: "The 'arguments[0]' property should not be expanded by default."); michael@0: michael@0: let argEnums = argProp.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let argNonEnums = argProp.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(argEnums.length, 6, michael@0: "The 'arguments[0]' property should contain all the created enumerable elements."); michael@0: is(argNonEnums.length, 1, michael@0: "The 'arguments[0]' property should contain all the created non-enumerable elements."); michael@0: michael@0: is(argEnums[0].querySelector(".name").getAttribute("value"), "a", michael@0: "Should have the right property name for 'a'."); michael@0: is(argEnums[0].querySelector(".value").getAttribute("value"), "1", michael@0: "Should have the right property value for 'a'."); michael@0: ok(argEnums[0].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'a'."); michael@0: michael@0: is(argEnums[1].querySelector(".name").getAttribute("value"), "b", michael@0: "Should have the right property name for 'b'."); michael@0: is(argEnums[1].querySelector(".value").getAttribute("value"), "\"beta\"", michael@0: "Should have the right property value for 'b'."); michael@0: ok(argEnums[1].querySelector(".value").className.contains("token-string"), michael@0: "Should have the right token class for 'b'."); michael@0: michael@0: is(argEnums[2].querySelector(".name").getAttribute("value"), "c", michael@0: "Should have the right property name for 'c'."); michael@0: is(argEnums[2].querySelector(".value").getAttribute("value"), "3", michael@0: "Should have the right property value for 'c'."); michael@0: ok(argEnums[2].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for 'c'."); michael@0: michael@0: is(argEnums[3].querySelector(".name").getAttribute("value"), "d", michael@0: "Should have the right property name for 'd'."); michael@0: is(argEnums[3].querySelector(".value").getAttribute("value"), "false", michael@0: "Should have the right property value for 'd'."); michael@0: ok(argEnums[3].querySelector(".value").className.contains("token-boolean"), michael@0: "Should have the right token class for 'd'."); michael@0: michael@0: is(argEnums[4].querySelector(".name").getAttribute("value"), "e", michael@0: "Should have the right property name for 'e'."); michael@0: is(argEnums[4].querySelector(".value").getAttribute("value"), "null", michael@0: "Should have the right property value for 'e'."); michael@0: ok(argEnums[4].querySelector(".value").className.contains("token-null"), michael@0: "Should have the right token class for 'e'."); michael@0: michael@0: is(argEnums[5].querySelector(".name").getAttribute("value"), "f", michael@0: "Should have the right property name for 'f'."); michael@0: is(argEnums[5].querySelector(".value").getAttribute("value"), "undefined", michael@0: "Should have the right property value for 'f'."); michael@0: ok(argEnums[5].querySelector(".value").className.contains("token-undefined"), michael@0: "Should have the right token class for 'f'."); michael@0: michael@0: is(argNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(argNonEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(argNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: argProp.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: function testGetterSetterObject() { michael@0: let deferred = promise.defer(); michael@0: michael@0: let myVar = gVariables.getScopeAtIndex(0).get("myVar"); michael@0: is(myVar.expanded, false, michael@0: "The myVar variable should not be expanded by default."); michael@0: michael@0: let myVarEnums = myVar.target.querySelector(".variables-view-element-details.enum").childNodes; michael@0: let myVarNonEnums = myVar.target.querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: gDebugger.once(gDebugger.EVENTS.FETCHED_PROPERTIES, () => { michael@0: is(myVarEnums.length, 2, michael@0: "The myVar should contain all the created enumerable elements."); michael@0: is(myVarNonEnums.length, 1, michael@0: "The myVar should contain all the created non-enumerable elements."); michael@0: michael@0: is(myVarEnums[0].querySelector(".name").getAttribute("value"), "_prop", michael@0: "Should have the right property name for '_prop'."); michael@0: is(myVarEnums[0].querySelector(".value").getAttribute("value"), "42", michael@0: "Should have the right property value for '_prop'."); michael@0: ok(myVarEnums[0].querySelector(".value").className.contains("token-number"), michael@0: "Should have the right token class for '_prop'."); michael@0: michael@0: is(myVarEnums[1].querySelector(".name").getAttribute("value"), "prop", michael@0: "Should have the right property name for 'prop'."); michael@0: is(myVarEnums[1].querySelector(".value").getAttribute("value"), "", michael@0: "Should have the right property value for 'prop'."); michael@0: ok(!myVarEnums[1].querySelector(".value").className.contains("token"), michael@0: "Should have no token class for 'prop'."); michael@0: michael@0: is(myVarNonEnums[0].querySelector(".name").getAttribute("value"), "__proto__", michael@0: "Should have the right property name for '__proto__'."); michael@0: is(myVarNonEnums[0].querySelector(".value").getAttribute("value"), "Object", michael@0: "Should have the right property value for '__proto__'."); michael@0: ok(myVarNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for '__proto__'."); michael@0: michael@0: let propEnums = myVarEnums[1].querySelector(".variables-view-element-details.enum").childNodes; michael@0: let propNonEnums = myVarEnums[1].querySelector(".variables-view-element-details.nonenum").childNodes; michael@0: michael@0: is(propEnums.length, 0, michael@0: "The propEnums should contain all the created enumerable elements."); michael@0: is(propNonEnums.length, 2, michael@0: "The propEnums should contain all the created non-enumerable elements."); michael@0: michael@0: is(propNonEnums[0].querySelector(".name").getAttribute("value"), "get", michael@0: "Should have the right property name for 'get'."); michael@0: is(propNonEnums[0].querySelector(".value").getAttribute("value"), michael@0: "test/myVar.prop()", michael@0: "Should have the right property value for 'get'."); michael@0: ok(propNonEnums[0].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'get'."); michael@0: michael@0: is(propNonEnums[1].querySelector(".name").getAttribute("value"), "set", michael@0: "Should have the right property name for 'set'."); michael@0: is(propNonEnums[1].querySelector(".value").getAttribute("value"), michael@0: "test/myVar.prop(val)", michael@0: "Should have the right property value for 'set'."); michael@0: ok(propNonEnums[1].querySelector(".value").className.contains("token-other"), michael@0: "Should have the right token class for 'set'."); michael@0: michael@0: deferred.resolve(); michael@0: }); michael@0: michael@0: myVar.expand(); michael@0: return deferred.promise; michael@0: } michael@0: michael@0: registerCleanupFunction(function() { michael@0: gTab = null; michael@0: gDebuggee = null; michael@0: gPanel = null; michael@0: gDebugger = null; michael@0: gVariables = null; michael@0: });