toolkit/devtools/server/tests/unit/test_frameactor-04.js

changeset 0
6474c204b198
equal deleted inserted replaced
-1:000000000000 0:cc88cb640295
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
3
4 /**
5 * Verify the "frames" request on the thread.
6 */
7
8 var gDebuggee;
9 var gClient;
10 var gThreadClient;
11
12 function run_test()
13 {
14 initTestDebuggerServer();
15 gDebuggee = addTestGlobal("test-stack");
16 gClient = new DebuggerClient(DebuggerServer.connectPipe());
17 gClient.connect(function() {
18 attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) {
19 gThreadClient = aThreadClient;
20 test_pause_frame();
21 });
22 });
23 do_test_pending();
24 }
25
26 var gFrames = [
27 // Function calls...
28 { type: "call", callee: { name: "depth3" } },
29 { type: "call", callee: { name: "depth2" } },
30 { type: "call", callee: { name: "depth1" } },
31
32 // Anonymous function call in our eval...
33 { type: "call", callee: { name: undefined } },
34
35 // The eval itself.
36 { type: "eval", callee: { name: undefined } },
37 ];
38
39 var gSliceTests = [
40 { start: 0, count: undefined, resetActors: true },
41 { start: 0, count: 1 },
42 { start: 2, count: 2 },
43 { start: 1, count: 15 },
44 { start: 15, count: undefined },
45 ];
46
47 function test_frame_slice() {
48 if (gSliceTests.length == 0) {
49 gThreadClient.resume(function() { finishClient(gClient); });
50 return;
51 }
52
53 let test = gSliceTests.shift();
54 gThreadClient.getFrames(test.start, test.count, function(aResponse) {
55 var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined);
56 do_check_eq(testFrames.length, aResponse.frames.length);
57 for (var i = 0; i < testFrames.length; i++) {
58 let expected = testFrames[i];
59 let actual = aResponse.frames[i];
60
61 if (test.resetActors) {
62 expected.actor = actual.actor;
63 }
64
65 for each (let key in ["type", "callee-name"]) {
66 do_check_eq(expected[key], actual[key]);
67 }
68 }
69 test_frame_slice();
70 });
71 }
72
73 function test_pause_frame()
74 {
75 gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket1) {
76 test_frame_slice();
77 });
78
79 gDebuggee.eval("(" + function() {
80 function depth3() {
81 debugger;
82 }
83 function depth2() {
84 depth3();
85 }
86 function depth1() {
87 depth2();
88 };
89 depth1();
90 } + ")()");
91 }

mercurial