test_threadlifetime-06.js 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check that promoting multiple pause-lifetime actors to thread-lifetime actors
  5. * works as expected.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. function run_test()
  11. {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-grips");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.connect().then(function () {
  16. attachTestTabAndResume(gClient, "test-grips", function (aResponse, aTabClient, aThreadClient) {
  17. gThreadClient = aThreadClient;
  18. test_thread_lifetime();
  19. });
  20. });
  21. do_test_pending();
  22. }
  23. function test_thread_lifetime()
  24. {
  25. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  26. let actors = [];
  27. let last;
  28. for (let aGrip of aPacket.frame.arguments) {
  29. actors.push(aGrip.actor);
  30. last = aGrip.actor;
  31. }
  32. // Create thread-lifetime actors for these objects.
  33. gThreadClient.threadGrips(actors, function (aResponse) {
  34. // Successful promotion won't return an error.
  35. do_check_eq(aResponse.error, undefined);
  36. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  37. // Verify that the promoted actors are returned again.
  38. actors.forEach(function (actor, i) {
  39. do_check_eq(actor, aPacket.frame.arguments[i].actor);
  40. });
  41. // Now that we've resumed, release the thread-lifetime grips.
  42. gThreadClient.releaseMany(actors, function (aResponse) {
  43. // Successful release won't return an error.
  44. do_check_eq(aResponse.error, undefined);
  45. gClient.request({ to: last, type: "bogusRequest" }, function (aResponse) {
  46. do_check_eq(aResponse.error, "noSuchActor");
  47. gThreadClient.resume(function (aResponse) {
  48. finishClient(gClient);
  49. });
  50. });
  51. });
  52. });
  53. gThreadClient.resume();
  54. });
  55. });
  56. gDebuggee.eval("(" + function () {
  57. function stopMe(arg1, arg2, arg3) {
  58. debugger;
  59. debugger;
  60. }
  61. stopMe({obj: 1}, {obj: 2}, {obj: 3});
  62. } + ")()");
  63. }