|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Check that thread-lifetime grips last past a resume. |
|
6 */ |
|
7 |
|
8 var gDebuggee; |
|
9 var gClient; |
|
10 var gThreadClient; |
|
11 |
|
12 function run_test() |
|
13 { |
|
14 initTestDebuggerServer(); |
|
15 gDebuggee = addTestGlobal("test-grips"); |
|
16 gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
|
17 gClient.connect(function() { |
|
18 attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { |
|
19 gThreadClient = aThreadClient; |
|
20 test_thread_lifetime(); |
|
21 }); |
|
22 }); |
|
23 do_test_pending(); |
|
24 } |
|
25 |
|
26 function test_thread_lifetime() |
|
27 { |
|
28 // Get three thread-lifetime grips. |
|
29 gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { |
|
30 let grips = []; |
|
31 |
|
32 let handler = function(aResponse) { |
|
33 if (aResponse.error) { |
|
34 do_check_eq(aResponse.error, ''); |
|
35 finishClient(gClient); |
|
36 } |
|
37 grips.push(aResponse.from); |
|
38 if (grips.length == 3) { |
|
39 test_release_many(grips); |
|
40 } |
|
41 }; |
|
42 for (let i = 0; i < 3; i++) { |
|
43 gClient.request({ to: aPacket.frame.arguments[i].actor, type: "threadGrip" }, |
|
44 handler); |
|
45 } |
|
46 }); |
|
47 |
|
48 gDebuggee.eval("(" + function() { |
|
49 function stopMe(arg1, arg2, arg3) { |
|
50 debugger; |
|
51 }; |
|
52 stopMe({obj: 1}, {obj: 2}, {obj: 3}); |
|
53 } + ")()"); |
|
54 } |
|
55 |
|
56 function test_release_many(grips) |
|
57 { |
|
58 // Release the first two grips, leave the third alive. |
|
59 |
|
60 let release = [grips[0], grips[1]]; |
|
61 |
|
62 gThreadClient.releaseMany(release, function(aResponse) { |
|
63 // First two actors should return a noSuchActor error, because |
|
64 // they're gone now. |
|
65 gClient.request({ to: grips[0], type: "bogusRequest" }, function(aResponse) { |
|
66 do_check_eq(aResponse.error, "noSuchActor"); |
|
67 gClient.request({ to: grips[1], type: "bogusRequest" }, function(aResponse) { |
|
68 do_check_eq(aResponse.error, "noSuchActor"); |
|
69 |
|
70 // Last actor should return unrecognizedPacketType, because it's still |
|
71 // alive. |
|
72 gClient.request({ to: grips[2], type: "bogusRequest" }, function(aResponse) { |
|
73 do_check_eq(aResponse.error, "unrecognizedPacketType"); |
|
74 gThreadClient.resume(function() { |
|
75 finishClient(gClient); |
|
76 }); |
|
77 }); |
|
78 }); |
|
79 }); |
|
80 }); |
|
81 } |