toolkit/devtools/server/tests/unit/test_stepping-05.js

branch
TOR_BUG_3246
changeset 7
129ffea94266
equal deleted inserted replaced
-1:000000000000 0:34f8b55a34ca
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Make sure that stepping in the last statement of the last frame doesn't
6 * cause an unexpected pause, when another JS frame is pushed on the stack
7 * (bug 785689).
8 */
9
10 var gDebuggee;
11 var gClient;
12 var gThreadClient;
13
14 function run_test()
15 {
16 initTestDebuggerServer();
17 gDebuggee = addTestGlobal("test-stack");
18 gClient = new DebuggerClient(DebuggerServer.connectPipe());
19 gClient.connect(function () {
20 attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
21 gThreadClient = aThreadClient;
22 test_stepping_last();
23 });
24 });
25 do_test_pending();
26 }
27
28 function test_stepping_last()
29 {
30 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
31 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
32 // Check the return value.
33 do_check_eq(aPacket.type, "paused");
34 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 2);
35 do_check_eq(aPacket.why.type, "resumeLimit");
36 // Check that stepping worked.
37 do_check_eq(gDebuggee.a, undefined);
38 do_check_eq(gDebuggee.b, undefined);
39
40 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
41 // Check the return value.
42 do_check_eq(aPacket.type, "paused");
43 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
44 do_check_eq(aPacket.why.type, "resumeLimit");
45 // Check that stepping worked.
46 do_check_eq(gDebuggee.a, 1);
47 do_check_eq(gDebuggee.b, undefined);
48
49 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
50 // Check the return value.
51 do_check_eq(aPacket.type, "paused");
52 // When leaving a stack frame the line number doesn't change.
53 do_check_eq(aPacket.frame.where.line, gDebuggee.line0 + 3);
54 do_check_eq(aPacket.why.type, "resumeLimit");
55 // Check that stepping worked.
56 do_check_eq(gDebuggee.a, 1);
57 do_check_eq(gDebuggee.b, 2);
58
59 gThreadClient.stepIn(function () {
60 test_next_pause();
61 });
62 });
63 gThreadClient.stepIn();
64 });
65 gThreadClient.stepIn();
66
67 });
68 gThreadClient.stepIn();
69
70 });
71
72 gDebuggee.eval("var line0 = Error().lineNumber;\n" +
73 "debugger;\n" + // line0 + 1
74 "var a = 1;\n" + // line0 + 2
75 "var b = 2;\n"); // line0 + 3
76 }
77
78 function test_next_pause()
79 {
80 gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
81 // Check the return value.
82 do_check_eq(aPacket.type, "paused");
83 // Before fixing bug 785689, the type was resumeLimit.
84 do_check_eq(aPacket.why.type, "debuggerStatement");
85
86 gThreadClient.resume(function () {
87 finishClient(gClient);
88 });
89 });
90
91 gDebuggee.eval("debugger;");
92 }

mercurial