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.
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5 * Make sure that stepping out of a function displays the right return value.
6 */
8 const TAB_URL = EXAMPLE_URL + "doc_step-out.html";
10 let gTab, gDebuggee, gPanel, gDebugger;
11 let gVars;
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;
21 testNormalReturn();
22 });
23 }
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>");
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.");
36 resumeDebuggee().then(() => testReturnWithException());
37 });
39 EventUtils.sendMouseEvent({ type: "mousedown" },
40 gDebugger.document.getElementById("step-out"),
41 gDebugger);
42 });
44 EventUtils.sendMouseEvent({ type: "click" },
45 gDebuggee.document.getElementById("return"),
46 gDebuggee);
47 }
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>");
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.");
60 resumeDebuggee().then(() => closeDebuggerAndFinish(gPanel));
61 });
63 EventUtils.sendMouseEvent({ type: "mousedown" },
64 gDebugger.document.getElementById("step-out"),
65 gDebugger);
66 });
68 EventUtils.sendMouseEvent({ type: "click" },
69 gDebuggee.document.getElementById("throw"),
70 gDebuggee);
71 }
73 function resumeDebuggee() {
74 let deferred = promise.defer();
75 gDebugger.gThreadClient.resume(deferred.resolve);
76 return deferred.promise;
77 }
79 registerCleanupFunction(function() {
80 gTab = null;
81 gDebuggee = null;
82 gPanel = null;
83 gDebugger = null;
84 gVars = null;
85 });