test_breakpoint-15.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check that adding a breakpoint in the same place returns the same actor.
  5. */
  6. var gDebuggee;
  7. var gClient;
  8. var gThreadClient;
  9. function run_test()
  10. {
  11. initTestDebuggerServer();
  12. gDebuggee = addTestGlobal("test-stack");
  13. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  14. gClient.connect().then(function () {
  15. attachTestTabAndResume(gClient, "test-stack", function (aResponse, aTabClient, aThreadClient) {
  16. gThreadClient = aThreadClient;
  17. testSameBreakpoint();
  18. });
  19. });
  20. do_test_pending();
  21. }
  22. const SOURCE_URL = "http://example.com/source.js";
  23. const testSameBreakpoint = Task.async(function* () {
  24. let packet = yield executeOnNextTickAndWaitForPause(evalCode, gClient);
  25. let source = gThreadClient.source(packet.frame.where.source);
  26. // Whole line
  27. let wholeLineLocation = {
  28. line: 2
  29. };
  30. let [firstResponse, firstBpClient] = yield setBreakpoint(source, wholeLineLocation);
  31. let [secondResponse, secondBpClient] = yield setBreakpoint(source, wholeLineLocation);
  32. do_check_eq(firstBpClient.actor, secondBpClient.actor, "Should get the same actor w/ whole line breakpoints");
  33. // Specific column
  34. let columnLocation = {
  35. line: 2,
  36. column: 6
  37. };
  38. [firstResponse, firstBpClient] = yield setBreakpoint(source, columnLocation);
  39. [secondResponse, secondBpClient] = yield setBreakpoint(source, columnLocation);
  40. do_check_eq(secondBpClient.actor, secondBpClient.actor, "Should get the same actor column breakpoints");
  41. finishClient(gClient);
  42. });
  43. function evalCode() {
  44. Components.utils.evalInSandbox(
  45. "" + function doStuff(k) { // line 1
  46. let arg = 15; // line 2 - Step in here
  47. k(arg); // line 3
  48. } + "\n" // line 4
  49. + "debugger;", // line 5
  50. gDebuggee,
  51. "1.8",
  52. SOURCE_URL,
  53. 1
  54. );
  55. }