1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/devtools/server/tests/unit/test_pauselifetime-03.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,61 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +/** 1.8 + * Check that pause-lifetime grip clients are marked invalid after a resume. 1.9 + */ 1.10 + 1.11 +var gDebuggee; 1.12 +var gClient; 1.13 +var gThreadClient; 1.14 + 1.15 +function run_test() 1.16 +{ 1.17 + initTestDebuggerServer(); 1.18 + gDebuggee = addTestGlobal("test-stack"); 1.19 + gClient = new DebuggerClient(DebuggerServer.connectPipe()); 1.20 + gClient.connect(function() { 1.21 + attachTestTabAndResume(gClient, "test-stack", function(aResponse, aTabClient, aThreadClient) { 1.22 + gThreadClient = aThreadClient; 1.23 + test_pause_frame(); 1.24 + }); 1.25 + }); 1.26 + do_test_pending(); 1.27 +} 1.28 + 1.29 +function test_pause_frame() 1.30 +{ 1.31 + gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) { 1.32 + let args = aPacket.frame.arguments; 1.33 + let objActor = args[0].actor; 1.34 + do_check_eq(args[0].class, "Object"); 1.35 + do_check_true(!!objActor); 1.36 + 1.37 + let objClient = gThreadClient.pauseGrip(args[0]); 1.38 + do_check_true(objClient.valid); 1.39 + 1.40 + // Make a bogus request to the grip actor. Should get 1.41 + // unrecognized-packet-type (and not no-such-actor). 1.42 + gClient.request({ to: objActor, type: "bogusRequest" }, function(aResponse) { 1.43 + do_check_eq(aResponse.error, "unrecognizedPacketType"); 1.44 + do_check_true(objClient.valid); 1.45 + 1.46 + gThreadClient.resume(function() { 1.47 + // Now that we've resumed, should get no-such-actor for the 1.48 + // same request. 1.49 + gClient.request({ to: objActor, type: "bogusRequest" }, function(aResponse) { 1.50 + do_check_false(objClient.valid); 1.51 + do_check_eq(aResponse.error, "noSuchActor"); 1.52 + finishClient(gClient); 1.53 + }); 1.54 + }); 1.55 + }); 1.56 + }); 1.57 + 1.58 + gDebuggee.eval("(" + function() { 1.59 + function stopMe(aObject) { 1.60 + debugger; 1.61 + }; 1.62 + stopMe({ foo: "bar" }); 1.63 + } + ")()"); 1.64 +}