diff -r 000000000000 -r 6474c204b198 browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/devtools/debugger/test/browser_dbg_variables-view-webidl.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,260 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/** + * Make sure that the variables view correctly displays WebIDL attributes in DOM + * objects. + */ + +const TAB_URL = EXAMPLE_URL + "doc_frame-parameters.html"; + +let gTab, gDebuggee, gPanel, gDebugger; +let gVariables; + +function test() { + // Debug test slaves are a bit slow at this test. + requestLongerTimeout(2); + + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { + gTab = aTab; + gDebuggee = aDebuggee; + gPanel = aPanel; + gDebugger = gPanel.panelWin; + gVariables = gDebugger.DebuggerView.Variables; + + waitForSourceAndCaretAndScopes(gPanel, ".html", 24) + .then(expandGlobalScope) + .then(performTest) + .then(() => resumeDebuggerThenCloseAndFinish(gPanel)) + .then(null, aError => { + ok(false, "Got an error: " + aError.message + "\n" + aError.stack); + }); + + EventUtils.sendMouseEvent({ type: "click" }, + gDebuggee.document.querySelector("button"), + gDebuggee); + }); +} + +function expandGlobalScope() { + let deferred = promise.defer(); + + let globalScope = gVariables.getScopeAtIndex(1); + is(globalScope.expanded, false, + "The global scope should not be expanded by default."); + + gDebugger.once(gDebugger.EVENTS.FETCHED_VARIABLES, deferred.resolve); + + EventUtils.sendMouseEvent({ type: "mousedown" }, + globalScope.target.querySelector(".name"), + gDebugger); + + return deferred.promise; +} + +function performTest() { + let deferred = promise.defer(); + let globalScope = gVariables.getScopeAtIndex(1); + + let buttonVar = globalScope.get("button"); + let buttonAsProtoVar = globalScope.get("buttonAsProto"); + let documentVar = globalScope.get("document"); + + is(buttonVar.target.querySelector(".name").getAttribute("value"), "button", + "Should have the right property name for 'button'."); + is(buttonVar.target.querySelector(".value").getAttribute("value"), "