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 | * Make sure that releasing a pause-lifetime actorin a releaseMany returns an |
michael@0 | 6 | * error, but releases all the thread-lifetime actors. |
michael@0 | 7 | */ |
michael@0 | 8 | |
michael@0 | 9 | var gDebuggee; |
michael@0 | 10 | var gClient; |
michael@0 | 11 | var gThreadClient; |
michael@0 | 12 | var gPauseGrip; |
michael@0 | 13 | |
michael@0 | 14 | function run_test() |
michael@0 | 15 | { |
michael@0 | 16 | initTestDebuggerServer(); |
michael@0 | 17 | gDebuggee = addTestGlobal("test-grips"); |
michael@0 | 18 | gClient = new DebuggerClient(DebuggerServer.connectPipe()); |
michael@0 | 19 | gClient.connect(function() { |
michael@0 | 20 | attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { |
michael@0 | 21 | gThreadClient = aThreadClient; |
michael@0 | 22 | test_thread_lifetime(); |
michael@0 | 23 | }); |
michael@0 | 24 | }); |
michael@0 | 25 | do_test_pending(); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function arg_grips(aFrameArgs, aOnResponse) { |
michael@0 | 29 | let grips = []; |
michael@0 | 30 | let handler = function (aResponse) { |
michael@0 | 31 | if (aResponse.error) { |
michael@0 | 32 | grips.push(aResponse.error); |
michael@0 | 33 | } else { |
michael@0 | 34 | grips.push(aResponse.from); |
michael@0 | 35 | } |
michael@0 | 36 | if (grips.length == aFrameArgs.length) { |
michael@0 | 37 | aOnResponse(grips); |
michael@0 | 38 | } |
michael@0 | 39 | }; |
michael@0 | 40 | for (let i = 0; i < aFrameArgs.length; i++) { |
michael@0 | 41 | gClient.request({ to: aFrameArgs[i].actor, type: "threadGrip" }, |
michael@0 | 42 | handler); |
michael@0 | 43 | } |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function test_thread_lifetime() |
michael@0 | 47 | { |
michael@0 | 48 | // Get two thread-lifetime grips. |
michael@0 | 49 | gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) { |
michael@0 | 50 | |
michael@0 | 51 | let frameArgs = [ aPacket.frame.arguments[0], aPacket.frame.arguments[1] ]; |
michael@0 | 52 | gPauseGrip = aPacket.frame.arguments[2]; |
michael@0 | 53 | arg_grips(frameArgs, function (aGrips) { |
michael@0 | 54 | release_grips(frameArgs, aGrips); |
michael@0 | 55 | }); |
michael@0 | 56 | }); |
michael@0 | 57 | |
michael@0 | 58 | gDebuggee.eval("(" + function() { |
michael@0 | 59 | function stopMe(arg1, arg2, arg3) { |
michael@0 | 60 | debugger; |
michael@0 | 61 | }; |
michael@0 | 62 | stopMe({obj: 1}, {obj: 2}, {obj: 3}); |
michael@0 | 63 | } + ")()"); |
michael@0 | 64 | } |
michael@0 | 65 | |
michael@0 | 66 | |
michael@0 | 67 | function release_grips(aFrameArgs, aThreadGrips) |
michael@0 | 68 | { |
michael@0 | 69 | // Release all actors with releaseMany... |
michael@0 | 70 | let release = [aThreadGrips[0], aThreadGrips[1], gPauseGrip.actor]; |
michael@0 | 71 | gThreadClient.releaseMany(release, function (aResponse) { |
michael@0 | 72 | do_check_eq(aResponse.error, "notReleasable"); |
michael@0 | 73 | // Now ask for thread grips again, they should not exist. |
michael@0 | 74 | arg_grips(aFrameArgs, function (aNewGrips) { |
michael@0 | 75 | for (let i = 0; i < aNewGrips.length; i++) { |
michael@0 | 76 | do_check_eq(aNewGrips[i], "noSuchActor"); |
michael@0 | 77 | } |
michael@0 | 78 | gThreadClient.resume(function () { |
michael@0 | 79 | finishClient(gClient); |
michael@0 | 80 | }); |
michael@0 | 81 | }); |
michael@0 | 82 | }); |
michael@0 | 83 | } |