test_conditional_breakpoint-01.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /* Any copyright is dedicated to the Public Domain.
  2. http://creativecommons.org/publicdomain/zero/1.0/ */
  3. /**
  4. * Check conditional breakpoint when condition evaluates to true.
  5. */
  6. var gDebuggee;
  7. var gClient;
  8. var gThreadClient;
  9. function run_test()
  10. {
  11. initTestDebuggerServer();
  12. gDebuggee = addTestGlobal("test-conditional-breakpoint");
  13. gClient = new DebuggerClient(DebuggerServer.connectPipe());
  14. gClient.connect().then(function () {
  15. attachTestTabAndResume(gClient, "test-conditional-breakpoint", function (aResponse, aTabClient, aThreadClient) {
  16. gThreadClient = aThreadClient;
  17. test_simple_breakpoint();
  18. });
  19. });
  20. do_test_pending();
  21. }
  22. function test_simple_breakpoint()
  23. {
  24. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  25. let source = gThreadClient.source(aPacket.frame.where.source);
  26. source.setBreakpoint({
  27. line: 3,
  28. condition: "a === 1"
  29. }, function (aResponse, bpClient) {
  30. gThreadClient.addOneTimeListener("paused", function (aEvent, aPacket) {
  31. // Check the return value.
  32. do_check_eq(aPacket.why.type, "breakpoint");
  33. do_check_eq(aPacket.frame.where.line, 3);
  34. // Remove the breakpoint.
  35. bpClient.remove(function (aResponse) {
  36. gThreadClient.resume(function () {
  37. finishClient(gClient);
  38. });
  39. });
  40. });
  41. // Continue until the breakpoint is hit.
  42. gThreadClient.resume();
  43. });
  44. });
  45. Components.utils.evalInSandbox("debugger;\n" + // 1
  46. "var a = 1;\n" + // 2
  47. "var b = 2;\n", // 3
  48. gDebuggee,
  49. "1.8",
  50. "test.js",
  51. 1);
  52. }