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 stepping out of a function displays the right return value. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_step-out.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gVars; michael@0: michael@0: function test() { 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: gVars = gDebugger.DebuggerView.Variables; michael@0: michael@0: testNormalReturn(); michael@0: }); michael@0: } michael@0: michael@0: function testNormalReturn() { michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 17).then(() => { michael@0: waitForCaretAndScopes(gPanel, 19).then(() => { michael@0: let innerScope = gVars.getScopeAtIndex(0); michael@0: let returnVar = innerScope.get(""); michael@0: michael@0: is(returnVar.name, "", michael@0: "Should have the right property name for the returned value."); michael@0: is(returnVar.value, 10, michael@0: "Should have the right property value for the returned value."); michael@0: michael@0: resumeDebuggee().then(() => testReturnWithException()); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.getElementById("step-out"), michael@0: gDebugger); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.getElementById("return"), michael@0: gDebuggee); michael@0: } michael@0: michael@0: function testReturnWithException() { michael@0: waitForCaretAndScopes(gPanel, 24).then(() => { michael@0: waitForCaretAndScopes(gPanel, 27).then(() => { michael@0: let innerScope = gVars.getScopeAtIndex(0); michael@0: let exceptionVar = innerScope.get(""); michael@0: michael@0: is(exceptionVar.name, "", michael@0: "Should have the right property name for the returned value."); michael@0: is(exceptionVar.value, "boom", michael@0: "Should have the right property value for the returned value."); michael@0: michael@0: resumeDebuggee().then(() => closeDebuggerAndFinish(gPanel)); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.getElementById("step-out"), michael@0: gDebugger); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "click" }, michael@0: gDebuggee.document.getElementById("throw"), michael@0: gDebuggee); michael@0: } michael@0: michael@0: function resumeDebuggee() { michael@0: let deferred = promise.defer(); michael@0: gDebugger.gThreadClient.resume(deferred.resolve); 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: gVars = null; michael@0: });