Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | /** |
michael@0 | 5 | * Make sure that after selecting a different stack frame, resuming reselects |
michael@0 | 6 | * the topmost stackframe, loads the right source in the editor pane and |
michael@0 | 7 | * highlights the proper line. |
michael@0 | 8 | */ |
michael@0 | 9 | |
michael@0 | 10 | const TAB_URL = EXAMPLE_URL + "doc_script-switching-01.html"; |
michael@0 | 11 | |
michael@0 | 12 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 13 | let gEditor, gSources, gFrames, gClassicFrames, gToolbar; |
michael@0 | 14 | |
michael@0 | 15 | function test() { |
michael@0 | 16 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 17 | gTab = aTab; |
michael@0 | 18 | gDebuggee = aDebuggee; |
michael@0 | 19 | gPanel = aPanel; |
michael@0 | 20 | gDebugger = gPanel.panelWin; |
michael@0 | 21 | gEditor = gDebugger.DebuggerView.editor; |
michael@0 | 22 | gSources = gDebugger.DebuggerView.Sources; |
michael@0 | 23 | gFrames = gDebugger.DebuggerView.StackFrames; |
michael@0 | 24 | gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; |
michael@0 | 25 | gToolbar = gDebugger.DebuggerView.Toolbar; |
michael@0 | 26 | |
michael@0 | 27 | waitForSourceAndCaretAndScopes(gPanel, "-02.js", 1).then(performTest); |
michael@0 | 28 | gDebuggee.firstCall(); |
michael@0 | 29 | }); |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | function performTest() { |
michael@0 | 33 | return Task.spawn(function() { |
michael@0 | 34 | yield selectBottomFrame(); |
michael@0 | 35 | testBottomFrame(0); |
michael@0 | 36 | |
michael@0 | 37 | yield performStep("StepOver"); |
michael@0 | 38 | testTopFrame(3); |
michael@0 | 39 | |
michael@0 | 40 | yield selectBottomFrame(); |
michael@0 | 41 | testBottomFrame(4); |
michael@0 | 42 | |
michael@0 | 43 | yield performStep("StepIn"); |
michael@0 | 44 | testTopFrame(2); |
michael@0 | 45 | |
michael@0 | 46 | yield selectBottomFrame(); |
michael@0 | 47 | testBottomFrame(4); |
michael@0 | 48 | |
michael@0 | 49 | yield performStep("StepOut"); |
michael@0 | 50 | testTopFrame(2); |
michael@0 | 51 | |
michael@0 | 52 | yield resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 53 | }); |
michael@0 | 54 | |
michael@0 | 55 | function selectBottomFrame() { |
michael@0 | 56 | let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); |
michael@0 | 57 | gClassicFrames.selectedIndex = gClassicFrames.itemCount - 1; |
michael@0 | 58 | return updated.then(waitForTick); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | function testBottomFrame(debugLocation) { |
michael@0 | 62 | is(gFrames.selectedIndex, 0, |
michael@0 | 63 | "Oldest frame should be selected after click."); |
michael@0 | 64 | is(gClassicFrames.selectedIndex, gFrames.itemCount - 1, |
michael@0 | 65 | "Oldest frame should also be selected in the mirrored view."); |
michael@0 | 66 | is(gSources.selectedIndex, 0, |
michael@0 | 67 | "The first source is now selected in the widget."); |
michael@0 | 68 | is(gEditor.getText().search(/firstCall/), 118, |
michael@0 | 69 | "The first source is displayed."); |
michael@0 | 70 | is(gEditor.getText().search(/debugger/), -1, |
michael@0 | 71 | "The second source is not displayed."); |
michael@0 | 72 | |
michael@0 | 73 | is(gEditor.getDebugLocation(), debugLocation, |
michael@0 | 74 | "Editor debugger location is correct."); |
michael@0 | 75 | ok(gEditor.hasLineClass(debugLocation, "debug-line"), |
michael@0 | 76 | "The debugged line is highlighted appropriately."); |
michael@0 | 77 | } |
michael@0 | 78 | |
michael@0 | 79 | function performStep(type) { |
michael@0 | 80 | let updated = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES); |
michael@0 | 81 | gToolbar["_on" + type + "Pressed"](); |
michael@0 | 82 | return updated.then(waitForTick); |
michael@0 | 83 | } |
michael@0 | 84 | |
michael@0 | 85 | function testTopFrame(frameIndex) { |
michael@0 | 86 | is(gFrames.selectedIndex, frameIndex, |
michael@0 | 87 | "Topmost frame should be selected after click."); |
michael@0 | 88 | is(gClassicFrames.selectedIndex, gFrames.itemCount - frameIndex - 1, |
michael@0 | 89 | "Topmost frame should also be selected in the mirrored view."); |
michael@0 | 90 | is(gSources.selectedIndex, 1, |
michael@0 | 91 | "The second source is now selected in the widget."); |
michael@0 | 92 | is(gEditor.getText().search(/firstCall/), -1, |
michael@0 | 93 | "The second source is displayed."); |
michael@0 | 94 | is(gEditor.getText().search(/debugger/), 172, |
michael@0 | 95 | "The first source is not displayed."); |
michael@0 | 96 | } |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | registerCleanupFunction(function() { |
michael@0 | 100 | gTab = null; |
michael@0 | 101 | gDebuggee = null; |
michael@0 | 102 | gPanel = null; |
michael@0 | 103 | gDebugger = null; |
michael@0 | 104 | gEditor = null; |
michael@0 | 105 | gSources = null; |
michael@0 | 106 | gFrames = null; |
michael@0 | 107 | gClassicFrames = null; |
michael@0 | 108 | gToolbar = null; |
michael@0 | 109 | }); |