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