1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/debugger/test/browser_dbg_stack-07.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,109 @@ 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 after selecting a different stack frame, resuming reselects 1.9 + * the topmost stackframe, loads the right source in the editor pane and 1.10 + * highlights the proper line. 1.11 + */ 1.12 + 1.13 +const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; 1.14 + 1.15 +let gTab, gDebuggee, gPanel, gDebugger; 1.16 +let gEditor, gSources, gFrames, gClassicFrames, gToolbar; 1.17 + 1.18 +function test() { 1.19 + initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { 1.20 + gTab = aTab; 1.21 + gDebuggee = aDebuggee; 1.22 + gPanel = aPanel; 1.23 + gDebugger = gPanel.panelWin; 1.24 + gEditor = gDebugger.DebuggerView.editor; 1.25 + gSources = gDebugger.DebuggerView.Sources; 1.26 + gFrames = gDebugger.DebuggerView.StackFrames; 1.27 + gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; 1.28 + gToolbar = gDebugger.DebuggerView.Toolbar; 1.29 + 1.30 + waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); 1.31 + gDebuggee.firstCall(); 1.32 + }); 1.33 +} 1.34 + 1.35 +function performTest() { 1.36 + return Task.spawn(function() { 1.37 + yield selectBottomFrame(); 1.38 + testBottomFrame(0); 1.39 + 1.40 + yield performStep("StepOver"); 1.41 + testTopFrame(3); 1.42 + 1.43 + yield selectBottomFrame(); 1.44 + testBottomFrame(4); 1.45 + 1.46 + yield performStep("StepIn"); 1.47 + testTopFrame(2); 1.48 + 1.49 + yield selectBottomFrame(); 1.50 + testBottomFrame(4); 1.51 + 1.52 + yield performStep("StepOut"); 1.53 + testTopFrame(2); 1.54 + 1.55 + yield resumeDebuggerThenCloseAndFinish(gPanel); 1.56 + }); 1.57 + 1.58 + function selectBottomFrame() { 1.59 + let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); 1.60 + gClassicFrames.selectedIndex = gClassicFrames.itemCount - 1; 1.61 + return updated.then(waitForTick); 1.62 + } 1.63 + 1.64 + function testBottomFrame(debugLocation) { 1.65 + is(gFrames.selectedIndex, 0, 1.66 + "Oldest frame should be selected after click."); 1.67 + is(gClassicFrames.selectedIndex, gFrames.itemCount - 1, 1.68 + "Oldest frame should also be selected in the mirrored view."); 1.69 + is(gSources.selectedIndex, 0, 1.70 + "The first source is now selected in the widget."); 1.71 + is(gEditor.getText().search(/firstCall/), 118, 1.72 + "The first source is displayed."); 1.73 + is(gEditor.getText().search(/debugger/), -1, 1.74 + "The second source is not displayed."); 1.75 + 1.76 + is(gEditor.getDebugLocation(), debugLocation, 1.77 + "Editor debugger location is correct."); 1.78 + ok(gEditor.hasLineClass(debugLocation, "debug-line"), 1.79 + "The debugged line is highlighted appropriately."); 1.80 + } 1.81 + 1.82 + function performStep(type) { 1.83 + let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); 1.84 + gToolbar["_on" + type + "Pressed"](); 1.85 + return updated.then(waitForTick); 1.86 + } 1.87 + 1.88 + function testTopFrame(frameIndex) { 1.89 + is(gFrames.selectedIndex, frameIndex, 1.90 + "Topmost frame should be selected after click."); 1.91 + is(gClassicFrames.selectedIndex, gFrames.itemCount - frameIndex - 1, 1.92 + "Topmost frame should also be selected in the mirrored view."); 1.93 + is(gSources.selectedIndex, 1, 1.94 + "The second source is now selected in the widget."); 1.95 + is(gEditor.getText().search(/firstCall/), -1, 1.96 + "The second source is displayed."); 1.97 + is(gEditor.getText().search(/debugger/), 172, 1.98 + "The first source is not displayed."); 1.99 + } 1.100 +} 1.101 + 1.102 +registerCleanupFunction(function() { 1.103 + gTab = null; 1.104 + gDebuggee = null; 1.105 + gPanel = null; 1.106 + gDebugger = null; 1.107 + gEditor = null; 1.108 + gSources = null; 1.109 + gFrames = null; 1.110 + gClassicFrames = null; 1.111 + gToolbar = null; 1.112 +});