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 selecting a stack frame loads the right source in the editor michael@0: * pane and highlights the proper line. michael@0: */ michael@0: michael@0: const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; michael@0: michael@0: let gTab, gDebuggee, gPanel, gDebugger; michael@0: let gEditor, gSources, 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: gEditor = gDebugger.DebuggerView.editor; michael@0: gSources = gDebugger.DebuggerView.Sources; michael@0: gFrames = gDebugger.DebuggerView.StackFrames; michael@0: gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; michael@0: michael@0: waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); michael@0: gDebuggee.firstCall(); michael@0: }); michael@0: } michael@0: michael@0: function performTest() { michael@0: is(gFrames.selectedIndex, 3, michael@0: "Newest frame should be selected by default."); michael@0: is(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame should also be selected in the mirrored view."); michael@0: is(gSources.selectedIndex, 1, michael@0: "The second source is selected in the widget."); michael@0: is(gEditor.getText().search(/firstCall/), -1, michael@0: "The first source is not displayed."); michael@0: is(gEditor.getText().search(/debugger/), 172, michael@0: "The second source is displayed."); michael@0: michael@0: waitForSourceAndCaret(gPanel, "-01.js", 1).then(waitForTick).then(() => { michael@0: is(gFrames.selectedIndex, 0, michael@0: "Oldest frame should be selected after click."); michael@0: is(gClassicFrames.selectedIndex, 3, michael@0: "Oldest frame should also be selected in the mirrored view."); michael@0: is(gSources.selectedIndex, 0, michael@0: "The first source is now selected in the widget."); michael@0: is(gEditor.getText().search(/firstCall/), 118, michael@0: "The first source is displayed."); michael@0: is(gEditor.getText().search(/debugger/), -1, michael@0: "The second source is not displayed."); michael@0: michael@0: waitForSourceAndCaret(gPanel, "-02.js", 1).then(waitForTick).then(() => { michael@0: is(gFrames.selectedIndex, 3, michael@0: "Newest frame should be selected again after click."); michael@0: is(gClassicFrames.selectedIndex, 0, michael@0: "Newest frame should also be selected again in the mirrored view."); michael@0: is(gSources.selectedIndex, 1, michael@0: "The second source is selected in the widget."); michael@0: is(gEditor.getText().search(/firstCall/), -1, michael@0: "The first source is not displayed."); michael@0: is(gEditor.getText().search(/debugger/), 172, michael@0: "The second source is displayed."); michael@0: michael@0: resumeDebuggerThenCloseAndFinish(gPanel); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.querySelector("#classic-stackframe-0"), michael@0: gDebugger); michael@0: }); michael@0: michael@0: EventUtils.sendMouseEvent({ type: "mousedown" }, michael@0: gDebugger.document.querySelector("#stackframe-3"), michael@0: gDebugger); 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: gEditor = null; michael@0: gSources = null; michael@0: gFrames = null; michael@0: gClassicFrames = null; michael@0: });