test_breakpoint-10.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check that setting a breakpoint in a line with multiple entry points
  5. * triggers no matter which entry point we reach.
  6. */
  7. var gDebuggee;
  8. var gClient;
  9. var gThreadClient;
  10. var gCallback;
  11. function run_test()
  12. {
  13. run_test_with_server(DebuggerServer, function () {
  14. run_test_with_server(WorkerDebuggerServer, do_test_finished);
  15. });
  16. do_test_pending();
  17. }
  18. function run_test_with_server(aServer, aCallback)
  19. {
  20. gCallback = aCallback;
  21. initTestDebuggerServer(aServer);
  22. gDebuggee = addTestGlobal("test-stack", aServer);
  23. gClient = new DebuggerClient(aServer.connectPipe());
  24. gClient.connect().then(function () {
  25. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  26. gThreadClient = aThreadClient;
  27. test_child_breakpoint();
  28. });
  29. });
  30. }
  31. function test_child_breakpoint()
  32. {
  33. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  34. let source = gThreadClient.source(aPacket.frame.where.source);
  35. let location = { line: gDebuggee.line0 + 3 };
  36. source.setBreakpoint(location, function (aResponse, bpClient) {
  37. // actualLocation is not returned when breakpoints don't skip forward.
  38. do_check_eq(aResponse.actualLocation, undefined);
  39. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  40. // Check the return value.
  41. do_check_eq(aPacket.type, "paused");
  42. do_check_eq(aPacket.why.type, "breakpoint");
  43. do_check_eq(aPacket.why.actors[0], bpClient.actor);
  44. // Check that the breakpoint worked.
  45. do_check_eq(gDebuggee.i, 0);
  46. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  47. // Check the return value.
  48. do_check_eq(aPacket.type, "paused");
  49. do_check_eq(aPacket.why.type, "breakpoint");
  50. do_check_eq(aPacket.why.actors[0], bpClient.actor);
  51. // Check that the breakpoint worked.
  52. do_check_eq(gDebuggee.i, 1);
  53. // Remove the breakpoint.
  54. bpClient.remove(function (aResponse) {
  55. gThreadClient.resume(function () {
  56. gClient.close().then(gCallback);
  57. });
  58. });
  59. });
  60. // Continue until the breakpoint is hit again.
  61. gThreadClient.resume();
  62. });
  63. // Continue until the breakpoint is hit.
  64. gThreadClient.resume();
  65. });
  66. });
  67. Cu.evalInSandbox("var line0 = Error().lineNumber;\n" +
  68. "debugger;\n" + // line0 + 1
  69. "var a, i = 0;\n" + // line0 + 2
  70. "for (i = 1; i <= 2; i++) {\n" + // line0 + 3
  71. " a = i;\n" + // line0 + 4
  72. "}\n", // line0 + 5
  73. gDebuggee);
  74. }