|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Make sure that stepping out of a function displays the right return value. |
|
6 */ |
|
7 |
|
8 const TAB_URL = EXAMPLE_URL + "doc_step-out.html"; |
|
9 |
|
10 let gTab, gDebuggee, gPanel, gDebugger; |
|
11 let gVars; |
|
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 gVars = gDebugger.DebuggerView.Variables; |
|
20 |
|
21 testNormalReturn(); |
|
22 }); |
|
23 } |
|
24 |
|
25 function testNormalReturn() { |
|
26 waitForSourceAndCaretAndScopes(gPanel, ".html", 17).then(() => { |
|
27 waitForCaretAndScopes(gPanel, 19).then(() => { |
|
28 let innerScope = gVars.getScopeAtIndex(0); |
|
29 let returnVar = innerScope.get("<return>"); |
|
30 |
|
31 is(returnVar.name, "<return>", |
|
32 "Should have the right property name for the returned value."); |
|
33 is(returnVar.value, 10, |
|
34 "Should have the right property value for the returned value."); |
|
35 |
|
36 resumeDebuggee().then(() => testReturnWithException()); |
|
37 }); |
|
38 |
|
39 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
40 gDebugger.document.getElementById("step-out"), |
|
41 gDebugger); |
|
42 }); |
|
43 |
|
44 EventUtils.sendMouseEvent({ type: "click" }, |
|
45 gDebuggee.document.getElementById("return"), |
|
46 gDebuggee); |
|
47 } |
|
48 |
|
49 function testReturnWithException() { |
|
50 waitForCaretAndScopes(gPanel, 24).then(() => { |
|
51 waitForCaretAndScopes(gPanel, 27).then(() => { |
|
52 let innerScope = gVars.getScopeAtIndex(0); |
|
53 let exceptionVar = innerScope.get("<exception>"); |
|
54 |
|
55 is(exceptionVar.name, "<exception>", |
|
56 "Should have the right property name for the returned value."); |
|
57 is(exceptionVar.value, "boom", |
|
58 "Should have the right property value for the returned value."); |
|
59 |
|
60 resumeDebuggee().then(() => closeDebuggerAndFinish(gPanel)); |
|
61 }); |
|
62 |
|
63 EventUtils.sendMouseEvent({ type: "mousedown" }, |
|
64 gDebugger.document.getElementById("step-out"), |
|
65 gDebugger); |
|
66 }); |
|
67 |
|
68 EventUtils.sendMouseEvent({ type: "click" }, |
|
69 gDebuggee.document.getElementById("throw"), |
|
70 gDebuggee); |
|
71 } |
|
72 |
|
73 function resumeDebuggee() { |
|
74 let deferred = promise.defer(); |
|
75 gDebugger.gThreadClient.resume(deferred.resolve); |
|
76 return deferred.promise; |
|
77 } |
|
78 |
|
79 registerCleanupFunction(function() { |
|
80 gTab = null; |
|
81 gDebuggee = null; |
|
82 gPanel = null; |
|
83 gDebugger = null; |
|
84 gVars = null; |
|
85 }); |