toolkit/devtools/server/tests/unit/test_threadlifetime-06.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-06.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     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 promoting multiple pause-lifetime actors to thread-lifetime actors
     1.9 + * works as expected.
    1.10 + */
    1.11 +
    1.12 +var gDebuggee;
    1.13 +var gClient;
    1.14 +var gThreadClient;
    1.15 +
    1.16 +function run_test()
    1.17 +{
    1.18 +  initTestDebuggerServer();
    1.19 +  gDebuggee = addTestGlobal("test-grips");
    1.20 +  gClient = new DebuggerClient(DebuggerServer.connectPipe());
    1.21 +  gClient.connect(function() {
    1.22 +    attachTestTabAndResume(gClient, "test-grips", function(aResponse, aTabClient, aThreadClient) {
    1.23 +      gThreadClient = aThreadClient;
    1.24 +      test_thread_lifetime();
    1.25 +    });
    1.26 +  });
    1.27 +  do_test_pending();
    1.28 +}
    1.29 +
    1.30 +function test_thread_lifetime()
    1.31 +{
    1.32 +  gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.33 +    let actors = [];
    1.34 +    let last;
    1.35 +    for (let aGrip of aPacket.frame.arguments) {
    1.36 +      actors.push(aGrip.actor);
    1.37 +      last = aGrip.actor;
    1.38 +    }
    1.39 +
    1.40 +    // Create thread-lifetime actors for these objects.
    1.41 +    gThreadClient.threadGrips(actors, function(aResponse) {
    1.42 +      // Successful promotion won't return an error.
    1.43 +      do_check_eq(aResponse.error, undefined);
    1.44 +
    1.45 +      gThreadClient.addOneTimeListener("paused", function(aEvent, aPacket) {
    1.46 +        // Verify that the promoted actors are returned again.
    1.47 +        actors.forEach(function(actor, i) {
    1.48 +          do_check_eq(actor, aPacket.frame.arguments[i].actor);
    1.49 +        });
    1.50 +        // Now that we've resumed, release the thread-lifetime grips.
    1.51 +        gThreadClient.releaseMany(actors, function(aResponse) {
    1.52 +          // Successful release won't return an error.
    1.53 +          do_check_eq(aResponse.error, undefined);
    1.54 +
    1.55 +          gClient.request({ to: last, type: "bogusRequest" }, function(aResponse) {
    1.56 +            do_check_eq(aResponse.error, "noSuchActor");
    1.57 +            gThreadClient.resume(function(aResponse) {
    1.58 +              finishClient(gClient);
    1.59 +            });
    1.60 +          });
    1.61 +        });
    1.62 +      });
    1.63 +      gThreadClient.resume();
    1.64 +    });
    1.65 +  });
    1.66 +
    1.67 +  gDebuggee.eval("(" + function() {
    1.68 +    function stopMe(arg1, arg2, arg3) {
    1.69 +      debugger;
    1.70 +      debugger;
    1.71 +    };
    1.72 +    stopMe({obj: 1}, {obj: 2}, {obj: 3});
    1.73 +  } + ")()");
    1.74 +}

mercurial