|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 /** |
|
5 * Test that reattaching to a previously detached thread works. |
|
6 */ |
|
7 |
|
8 var gClient, gDebuggee, gThreadClient, gTabClient; |
|
9 |
|
10 function run_test() |
|
11 { |
|
12 initTestDebuggerServer(); |
|
13 gDebuggee = testGlobal("test-reattach"); |
|
14 DebuggerServer.addTestGlobal(gDebuggee); |
|
15 |
|
16 let transport = DebuggerServer.connectPipe(); |
|
17 gClient = new DebuggerClient(transport); |
|
18 gClient.connect(() => { |
|
19 attachTestTab(gClient, "test-reattach", (aReply, aTabClient) => { |
|
20 gTabClient = aTabClient; |
|
21 test_attach(); |
|
22 }); |
|
23 }); |
|
24 do_test_pending(); |
|
25 } |
|
26 |
|
27 function test_attach() |
|
28 { |
|
29 gTabClient.attachThread({}, (aResponse, aThreadClient) => { |
|
30 do_check_eq(aThreadClient.state, "paused"); |
|
31 gThreadClient = aThreadClient; |
|
32 aThreadClient.resume(test_detach); |
|
33 }); |
|
34 } |
|
35 |
|
36 function test_detach() |
|
37 { |
|
38 gThreadClient.detach(() => { |
|
39 do_check_eq(gThreadClient.state, "detached"); |
|
40 do_check_eq(gTabClient.thread, null); |
|
41 test_reattach(); |
|
42 }); |
|
43 } |
|
44 |
|
45 function test_reattach() |
|
46 { |
|
47 gTabClient.attachThread({}, (aResponse, aThreadClient) => { |
|
48 do_check_neq(gThreadClient, aThreadClient); |
|
49 do_check_eq(aThreadClient.state, "paused"); |
|
50 do_check_eq(gTabClient.thread, aThreadClient); |
|
51 aThreadClient.resume(cleanup); |
|
52 }); |
|
53 } |
|
54 |
|
55 function cleanup() |
|
56 { |
|
57 gClient.close(do_test_finished); |
|
58 } |