toolkit/devtools/server/tests/unit/test_threadlifetime-02.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/toolkit/devtools/server/tests/unit/test_threadlifetime-02.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     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 thread-lifetime grips last past 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-grips");
    1.19 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.20 +  gClient.connect(function() {
    1.21 +    attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    1.22 +      gThreadClient = aThreadClient;
    1.23 +      test_thread_lifetime();
    1.24 +    });
    1.25 +  });
    1.26 +  do_test_pending();
    1.27 +}
    1.28 +
    1.29 +function test_thread_lifetime()
    1.30 +{
    1.31 +  gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.32 +    let pauseGrip = aPacket.frame.arguments[0];
    1.33 +
    1.34 +    // Create a thread-lifetime actor for this object.
    1.35 +    gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function(aResponse) {
    1.36 +      // Successful promotion won't return an error.
    1.37 +      do_check_eq(aResponse.error, undefined);
    1.38 +      gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.39 +        // Verify that the promoted actor is returned again.
    1.40 +        do_check_eq(pauseGrip.actor, aPacket.frame.arguments[0].actor);
    1.41 +        // Now that we've resumed, release the thread-lifetime grip.
    1.42 +        gClient.release(pauseGrip.actor, function(aResponse) {
    1.43 +          gClient.request({ to: pauseGrip.actor, type: "bogusRequest" }, function(aResponse) {
    1.44 +            do_check_eq(aResponse.error, "noSuchActor");
    1.45 +            gThreadClient.resume(function(aResponse) {
    1.46 +              finishClient(gClient);
    1.47 +            });
    1.48 +          });
    1.49 +        });
    1.50 +      });
    1.51 +      gThreadClient.resume();
    1.52 +    });
    1.53 +  });
    1.54 +
    1.55 +  gDebuggee.eval("(" + function() {
    1.56 +    function stopMe(arg1) {
    1.57 +      debugger;
    1.58 +      debugger;
    1.59 +    };
    1.60 +    stopMe({obj: true});
    1.61 +  } + ")()");
    1.62 +}

mercurial