1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_stack-06.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,88 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Make sure that selecting a stack frame loads the right source in the editor 1.9 + * pane and highlights the proper line. 1.10 + */ 1.11 + 1.12 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.13 + 1.14 +let gTab, gDebuggee, gPanel, gDebugger; 1.15 +let gEditor, gSources, gFrames, gClassicFrames; 1.16 + 1.17 +function test() { 1.18 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.19 + gTab = aTab; 1.20 + gDebuggee = aDebuggee; 1.21 + gPanel = aPanel; 1.22 + gDebugger = gPanel.panelWin; 1.23 + gEditor = gDebugger.DebuggerView.editor; 1.24 + gSources = gDebugger.DebuggerView.Sources; 1.25 + gFrames = gDebugger.DebuggerView.StackFrames; 1.26 + gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; 1.27 + 1.28 + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); 1.29 + gDebuggee.firstCall(); 1.30 + }); 1.31 +} 1.32 + 1.33 +function performTest() { 1.34 + is(gFrames.selectedIndex, 3, 1.35 + "Newest frame should be selected by default."); 1.36 + is(gClassicFrames.selectedIndex, 0, 1.37 + "Newest frame should also be selected in the mirrored view."); 1.38 + is(gSources.selectedIndex, 1, 1.39 + "The second source is selected in the widget."); 1.40 + is(gEditor.getText().search(/firstCall/), -1, 1.41 + "The first source is not displayed."); 1.42 + is(gEditor.getText().search(/debugger/), 172, 1.43 + "The second source is displayed."); 1.44 + 1.45 + waitForSourceAndCaret(gPanel, "-01.js", 1).then(waitForTick).then(() => { 1.46 + is(gFrames.selectedIndex, 0, 1.47 + "Oldest frame should be selected after click."); 1.48 + is(gClassicFrames.selectedIndex, 3, 1.49 + "Oldest frame should also be selected in the mirrored view."); 1.50 + is(gSources.selectedIndex, 0, 1.51 + "The first source is now selected in the widget."); 1.52 + is(gEditor.getText().search(/firstCall/), 118, 1.53 + "The first source is displayed."); 1.54 + is(gEditor.getText().search(/debugger/), -1, 1.55 + "The second source is not displayed."); 1.56 + 1.57 + waitForSourceAndCaret(gPanel, "-02.js", 1).then(waitForTick).then(() => { 1.58 + is(gFrames.selectedIndex, 3, 1.59 + "Newest frame should be selected again after click."); 1.60 + is(gClassicFrames.selectedIndex, 0, 1.61 + "Newest frame should also be selected again in the mirrored view."); 1.62 + is(gSources.selectedIndex, 1, 1.63 + "The second source is selected in the widget."); 1.64 + is(gEditor.getText().search(/firstCall/), -1, 1.65 + "The first source is not displayed."); 1.66 + is(gEditor.getText().search(/debugger/), 172, 1.67 + "The second source is displayed."); 1.68 + 1.69 + resumeDebuggerThenCloseAndFinish(gPanel); 1.70 + }); 1.71 + 1.72 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.73 + gDebugger.document.querySelector("#classic-stackframe-0"), 1.74 + gDebugger); 1.75 + }); 1.76 + 1.77 + EventUtils.sendMouseEvent({ type: "mousedown" }, 1.78 + gDebugger.document.querySelector("#stackframe-3"), 1.79 + gDebugger); 1.80 +} 1.81 + 1.82 +registerCleanupFunction(function() { 1.83 + gTab = null; 1.84 + gDebuggee = null; 1.85 + gPanel = null; 1.86 + gDebugger = null; 1.87 + gEditor = null; 1.88 + gSources = null; 1.89 + gFrames = null; 1.90 + gClassicFrames = null; 1.91 +});