michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: /** michael@0: * Check that thread-lifetime grips last past a resume. michael@0: */ michael@0: michael@0: var gDebuggee; michael@0: var gClient; michael@0: var gThreadClient; michael@0: michael@0: function run_test() michael@0: { michael@0: initTestDebuggerServer(); michael@0: gDebuggee = addTestGlobal("test-grips"); michael@0: gClient = new DebuggerClient(DebuggerServer.connectPipe()); michael@0: gClient.connect(function() { michael@0: attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) { michael@0: gThreadClient = aThreadClient; michael@0: test_thread_lifetime(); michael@0: }); michael@0: }); michael@0: do_test_pending(); michael@0: } michael@0: michael@0: function test_thread_lifetime() michael@0: { michael@0: // Get three thread-lifetime grips. michael@0: gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { michael@0: let grips = []; michael@0: michael@0: let handler = function(aResponse) { michael@0: if (aResponse.error) { michael@0: do_check_eq(aResponse.error, ''); michael@0: finishClient(gClient); michael@0: } michael@0: grips.push(aResponse.from); michael@0: if (grips.length == 3) { michael@0: test_release_many(grips); michael@0: } michael@0: }; michael@0: for (let i = 0; i < 3; i++) { michael@0: gClient.request({ to: aPacket.frame.arguments[i].actor, type: "threadGrip" }, michael@0: handler); michael@0: } michael@0: }); michael@0: michael@0: gDebuggee.eval("(" + function() { michael@0: function stopMe(arg1, arg2, arg3) { michael@0: debugger; michael@0: }; michael@0: stopMe({obj: 1}, {obj: 2}, {obj: 3}); michael@0: } + ")()"); michael@0: } michael@0: michael@0: function test_release_many(grips) michael@0: { michael@0: // Release the first two grips, leave the third alive. michael@0: michael@0: let release = [grips[0], grips[1]]; michael@0: michael@0: gThreadClient.releaseMany(release, function(aResponse) { michael@0: // First two actors should return a noSuchActor error, because michael@0: // they're gone now. michael@0: gClient.request({ to: grips[0], type: "bogusRequest" }, function(aResponse) { michael@0: do_check_eq(aResponse.error, "noSuchActor"); michael@0: gClient.request({ to: grips[1], type: "bogusRequest" }, function(aResponse) { michael@0: do_check_eq(aResponse.error, "noSuchActor"); michael@0: michael@0: // Last actor should return unrecognizedPacketType, because it's still michael@0: // alive. michael@0: gClient.request({ to: grips[2], type: "bogusRequest" }, function(aResponse) { michael@0: do_check_eq(aResponse.error, "unrecognizedPacketType"); michael@0: gThreadClient.resume(function() { michael@0: finishClient(gClient); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }); michael@0: }