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: * Test that stackframes are added when debugger is paused in eval calls. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gFrames, gClassicFrames; 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: gFrames = gDebugger.DebuggerView.StackFrames; michael@0: gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest); michael@0: gDebuggee.evalCall(); michael@0: }); michael@0: } michael@0: michael@0: function performTest() { michael@0: is(gDebugger.gThreadClient.state, "paused", michael@0: "Should only be getting stack frames while paused."); michael@0: is(gFrames.itemCount, 2, michael@0: "Should have two frames."); michael@0: is(gClassicFrames.itemCount, 2, michael@0: "Should also have only two in the mirrored view."); michael@0: michael@0: is(gFrames.getItemAtIndex(0).attachment.title, michael@0: "evalCall", "Oldest frame name should be correct."); michael@0: is(gFrames.getItemAtIndex(0).attachment.url, michael@0: TAB_URL, "Oldest frame url should be correct."); michael@0: is(gClassicFrames.getItemAtIndex(0).attachment.depth, michael@0: 0, "Oldest frame name is mirrored correctly."); michael@0: michael@0: is(gFrames.getItemAtIndex(1).attachment.title, michael@0: "(eval)", "Newest frame name should be correct."); michael@0: is(gFrames.getItemAtIndex(1).attachment.url, michael@0: TAB_URL, "Newest frame url should be correct."); michael@0: is(gClassicFrames.getItemAtIndex(1).attachment.depth, michael@0: 1, "Newest frame name is mirrored correctly."); michael@0: michael@0: is(gFrames.selectedIndex, 1, michael@0: "Newest frame should be selected by default."); michael@0: is(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame should be selected by default in the mirrored view."); michael@0: michael@0: isnot(gFrames.selectedIndex, 0, michael@0: "Oldest frame should not be selected."); michael@0: isnot(gClassicFrames.selectedIndex, 1, michael@0: "Oldest frame should not be selected in the mirrored view."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gFrames.getItemAtIndex(0).target, michael@0: gDebugger); michael@0: michael@0: isnot(gFrames.selectedIndex, 1, michael@0: "Newest frame should not be selected after click."); michael@0: isnot(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame in the mirrored view should not be selected."); michael@0: michael@0: is(gFrames.selectedIndex, 0, michael@0: "Oldest frame should be selected after click."); michael@0: is(gClassicFrames.selectedIndex, 1, michael@0: "Oldest frame in the mirrored view should be selected."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gFrames.getItemAtIndex(1).target.querySelector(".dbg-stackframe-title"), michael@0: gDebugger); michael@0: michael@0: is(gFrames.selectedIndex, 1, michael@0: "Newest frame should be selected after click inside the newest frame."); michael@0: is(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame in the mirrored view should be selected."); michael@0: michael@0: isnot(gFrames.selectedIndex, 0, michael@0: "Oldest frame should not be selected after click inside the newest frame."); michael@0: isnot(gClassicFrames.selectedIndex, 1, michael@0: "Oldest frame in the mirrored view should not be selected."); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gFrames.getItemAtIndex(0).target.querySelector(".dbg-stackframe-details"), michael@0: gDebugger); michael@0: michael@0: isnot(gFrames.selectedIndex, 1, michael@0: "Newest frame should not be selected after click inside the oldest frame."); michael@0: isnot(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame in the mirrored view should not be selected."); michael@0: michael@0: is(gFrames.selectedIndex, 0, michael@0: "Oldest frame should be selected after click inside the oldest frame."); michael@0: is(gClassicFrames.selectedIndex, 1, michael@0: "Oldest frame in the mirrored view should be selected."); michael@0: michael@0: resumeDebuggerThenCloseAndFinish(gPanel); 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: gFrames = null; michael@0: gClassicFrames = null; michael@0: });