toolkit/devtools/server/tests/unit/test_threadlifetime-04.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-04.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,53 @@
     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 requesting a thread-lifetime actor twice for the same
     1.9 + * value returns the same actor.
    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 pauseGrip = aPacket.frame.arguments[0];
    1.34 +
    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 +
    1.39 +      let threadGrip1 = aResponse.from;
    1.40 +
    1.41 +      gClient.request({ to: pauseGrip.actor, type: "threadGrip" }, function (aResponse) {
    1.42 +        do_check_eq(threadGrip1, aResponse.from);
    1.43 +        gThreadClient.resume(function() {
    1.44 +          finishClient(gClient);
    1.45 +        });
    1.46 +      });
    1.47 +    });
    1.48 +  });
    1.49 +
    1.50 +  gDebuggee.eval("(" + function() {
    1.51 +    function stopMe(arg1) {
    1.52 +      debugger;
    1.53 +    };
    1.54 +    stopMe({obj: true});
    1.55 +  } + ")()");
    1.56 +}

mercurial