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 | * Test that stackframes are added when debugger is paused in eval calls. |
michael@0 | 6 | */ |
michael@0 | 7 | |
michael@0 | 8 | const TAB_URL = EXAMPLE_URL + "doc_recursion-stack.html"; |
michael@0 | 9 | |
michael@0 | 10 | let gTab, gDebuggee, gPanel, gDebugger; |
michael@0 | 11 | let gFrames, gClassicFrames; |
michael@0 | 12 | |
michael@0 | 13 | function test() { |
michael@0 | 14 | initDebugger(TAB_URL).then(([aTab, aDebuggee, aPanel]) => { |
michael@0 | 15 | gTab = aTab; |
michael@0 | 16 | gDebuggee = aDebuggee; |
michael@0 | 17 | gPanel = aPanel; |
michael@0 | 18 | gDebugger = gPanel.panelWin; |
michael@0 | 19 | gFrames = gDebugger.DebuggerView.StackFrames; |
michael@0 | 20 | gClassicFrames = gDebugger.DebuggerView.StackFramesClassicList; |
michael@0 | 21 | |
michael@0 | 22 | waitForSourceAndCaretAndScopes(gPanel, ".html", 1).then(performTest); |
michael@0 | 23 | gDebuggee.evalCall(); |
michael@0 | 24 | }); |
michael@0 | 25 | } |
michael@0 | 26 | |
michael@0 | 27 | function performTest() { |
michael@0 | 28 | is(gDebugger.gThreadClient.state, "paused", |
michael@0 | 29 | "Should only be getting stack frames while paused."); |
michael@0 | 30 | is(gFrames.itemCount, 2, |
michael@0 | 31 | "Should have two frames."); |
michael@0 | 32 | is(gClassicFrames.itemCount, 2, |
michael@0 | 33 | "Should also have only two in the mirrored view."); |
michael@0 | 34 | |
michael@0 | 35 | is(gFrames.getItemAtIndex(0).attachment.title, |
michael@0 | 36 | "evalCall", "Oldest frame name should be correct."); |
michael@0 | 37 | is(gFrames.getItemAtIndex(0).attachment.url, |
michael@0 | 38 | TAB_URL, "Oldest frame url should be correct."); |
michael@0 | 39 | is(gClassicFrames.getItemAtIndex(0).attachment.depth, |
michael@0 | 40 | 0, "Oldest frame name is mirrored correctly."); |
michael@0 | 41 | |
michael@0 | 42 | is(gFrames.getItemAtIndex(1).attachment.title, |
michael@0 | 43 | "(eval)", "Newest frame name should be correct."); |
michael@0 | 44 | is(gFrames.getItemAtIndex(1).attachment.url, |
michael@0 | 45 | TAB_URL, "Newest frame url should be correct."); |
michael@0 | 46 | is(gClassicFrames.getItemAtIndex(1).attachment.depth, |
michael@0 | 47 | 1, "Newest frame name is mirrored correctly."); |
michael@0 | 48 | |
michael@0 | 49 | is(gFrames.selectedIndex, 1, |
michael@0 | 50 | "Newest frame should be selected by default."); |
michael@0 | 51 | is(gClassicFrames.selectedIndex, 0, |
michael@0 | 52 | "Newest frame should be selected by default in the mirrored view."); |
michael@0 | 53 | |
michael@0 | 54 | isnot(gFrames.selectedIndex, 0, |
michael@0 | 55 | "Oldest frame should not be selected."); |
michael@0 | 56 | isnot(gClassicFrames.selectedIndex, 1, |
michael@0 | 57 | "Oldest frame should not be selected in the mirrored view."); |
michael@0 | 58 | |
michael@0 | 59 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 60 | gFrames.getItemAtIndex(0).target, |
michael@0 | 61 | gDebugger); |
michael@0 | 62 | |
michael@0 | 63 | isnot(gFrames.selectedIndex, 1, |
michael@0 | 64 | "Newest frame should not be selected after click."); |
michael@0 | 65 | isnot(gClassicFrames.selectedIndex, 0, |
michael@0 | 66 | "Newest frame in the mirrored view should not be selected."); |
michael@0 | 67 | |
michael@0 | 68 | is(gFrames.selectedIndex, 0, |
michael@0 | 69 | "Oldest frame should be selected after click."); |
michael@0 | 70 | is(gClassicFrames.selectedIndex, 1, |
michael@0 | 71 | "Oldest frame in the mirrored view should be selected."); |
michael@0 | 72 | |
michael@0 | 73 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 74 | gFrames.getItemAtIndex(1).target.querySelector(".dbg-stackframe-title"), |
michael@0 | 75 | gDebugger); |
michael@0 | 76 | |
michael@0 | 77 | is(gFrames.selectedIndex, 1, |
michael@0 | 78 | "Newest frame should be selected after click inside the newest frame."); |
michael@0 | 79 | is(gClassicFrames.selectedIndex, 0, |
michael@0 | 80 | "Newest frame in the mirrored view should be selected."); |
michael@0 | 81 | |
michael@0 | 82 | isnot(gFrames.selectedIndex, 0, |
michael@0 | 83 | "Oldest frame should not be selected after click inside the newest frame."); |
michael@0 | 84 | isnot(gClassicFrames.selectedIndex, 1, |
michael@0 | 85 | "Oldest frame in the mirrored view should not be selected."); |
michael@0 | 86 | |
michael@0 | 87 | EventUtils.sendMouseEvent({ type: "mousedown" }, |
michael@0 | 88 | gFrames.getItemAtIndex(0).target.querySelector(".dbg-stackframe-details"), |
michael@0 | 89 | gDebugger); |
michael@0 | 90 | |
michael@0 | 91 | isnot(gFrames.selectedIndex, 1, |
michael@0 | 92 | "Newest frame should not be selected after click inside the oldest frame."); |
michael@0 | 93 | isnot(gClassicFrames.selectedIndex, 0, |
michael@0 | 94 | "Newest frame in the mirrored view should not be selected."); |
michael@0 | 95 | |
michael@0 | 96 | is(gFrames.selectedIndex, 0, |
michael@0 | 97 | "Oldest frame should be selected after click inside the oldest frame."); |
michael@0 | 98 | is(gClassicFrames.selectedIndex, 1, |
michael@0 | 99 | "Oldest frame in the mirrored view should be selected."); |
michael@0 | 100 | |
michael@0 | 101 | resumeDebuggerThenCloseAndFinish(gPanel); |
michael@0 | 102 | } |
michael@0 | 103 | |
michael@0 | 104 | registerCleanupFunction(function() { |
michael@0 | 105 | gTab = null; |
michael@0 | 106 | gDebuggee = null; |
michael@0 | 107 | gPanel = null; |
michael@0 | 108 | gDebugger = null; |
michael@0 | 109 | gFrames = null; |
michael@0 | 110 | gClassicFrames = null; |
michael@0 | 111 | }); |