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