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: * Tests that anonymous functions appear in the stack frame list with either michael@0: * their displayName property or a SpiderMonkey-inferred name. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_function-display-name.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; 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: michael@0: testAnonCall(); michael@0: }); michael@0: } michael@0: michael@0: function testAnonCall() { michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 15).then(() => { michael@0: ok(isCaretPos(gPanel, 15), michael@0: "The source editor caret position was incorrect."); michael@0: is(gDebugger.gThreadClient.state, "paused", michael@0: "Should only be getting stack frames while paused."); michael@0: is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, michael@0: "Should have three frames."); michael@0: is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), michael@0: "anonFunc", "Frame name should be 'anonFunc'."); michael@0: michael@0: testInferredName(); michael@0: }); michael@0: michael@0: gDebuggee.evalCall(); michael@0: } michael@0: michael@0: function testInferredName() { michael@0: waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => { michael@0: ok(isCaretPos(gPanel, 15), michael@0: "The source editor caret position was incorrect."); michael@0: is(gDebugger.gThreadClient.state, "paused", michael@0: "Should only be getting stack frames while paused."); michael@0: is(gDebugger.document.querySelectorAll(".dbg-stackframe").length, 3, michael@0: "Should have three frames."); michael@0: is(gDebugger.document.querySelector("#stackframe-0 .dbg-stackframe-title").getAttribute("value"), michael@0: "a/<", "Frame name should be 'a/<'."); michael@0: michael@0: resumeDebuggerThenCloseAndFinish(gPanel); michael@0: }); michael@0: michael@0: gDebugger.gThreadClient.resume(); 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: });