test_frameactor-05.js 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Verify that frame actors retrieved with the frames request
  5. * are included in the pause packet's popped-frames property.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. function run_test()
  11. {
  12. initTestDebuggerServer();
  13. gDebuggee = addTestGlobal("test-stack");
  14. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  15. gClient.connect().then(function () {
  16. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  17. gThreadClient = aThreadClient;
  18. test_pause_frame();
  19. });
  20. });
  21. do_test_pending();
  22. }
  23. function test_frame_slice() {
  24. if (gSliceTests.length == 0) {
  25. gThreadClient.resume(function () { finishClient(gClient); });
  26. return;
  27. }
  28. let test = gSliceTests.shift();
  29. gThreadClient.getFrames(test.start, test.count, function (aResponse) {
  30. var testFrames = gFrames.slice(test.start, test.count ? test.start + test.count : undefined);
  31. do_check_eq(testFrames.length, aResponse.frames.length);
  32. for (var i = 0; i < testFrames.length; i++) {
  33. let expected = testFrames[i];
  34. let actual = aResponse.frames[i];
  35. if (test.resetActors) {
  36. expected.actor = actual.actor;
  37. }
  38. for (var key in expected) {
  39. do_check_eq(expected[key], actual[key]);
  40. }
  41. }
  42. test_frame_slice();
  43. });
  44. }
  45. function test_pause_frame()
  46. {
  47. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket1) {
  48. gThreadClient.getFrames(0, null, function (aFrameResponse) {
  49. do_check_eq(aFrameResponse.frames.length, 5);
  50. // Now wait for the next pause, after which the three
  51. // youngest actors should be popped..
  52. let expectPopped = aFrameResponse.frames.slice(0, 3).map(frame => frame.actor);
  53. expectPopped.sort();
  54. gThreadClient.addOneTimeListener("paused", function (aEvent, aPausePacket) {
  55. let popped = aPausePacket.poppedFrames.sort();
  56. do_check_eq(popped.length, 3);
  57. for (let i = 0; i < 3; i++) {
  58. do_check_eq(expectPopped[i], popped[i]);
  59. }
  60. gThreadClient.resume(function () { finishClient(gClient); });
  61. });
  62. gThreadClient.resume();
  63. });
  64. });
  65. gDebuggee.eval("(" + function () {
  66. function depth3() {
  67. debugger;
  68. }
  69. function depth2() {
  70. depth3();
  71. }
  72. function depth1() {
  73. depth2();
  74. }
  75. depth1();
  76. debugger;
  77. } + ")()");
  78. }