browser_dbg_breakpoints-new-script.js 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
  2. /* Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4. /**
  5. * Bug 771452: Make sure that setting a breakpoint in an inline source doesn't
  6. * add it twice.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_inline-script.html";
  9. function test() {
  10. let options = {
  11. source: TAB_URL,
  12. line: 1
  13. };
  14. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  15. const gTab = aTab;
  16. const gPanel = aPanel;
  17. const gDebugger = gPanel.panelWin;
  18. const gSources = gDebugger.DebuggerView.Sources;
  19. const queries = gDebugger.require('./content/queries');
  20. const actions = bindActionCreators(gPanel);
  21. const getState = gDebugger.DebuggerController.getState;
  22. function testResume() {
  23. const deferred = promise.defer();
  24. is(gDebugger.gThreadClient.state, "paused",
  25. "The breakpoint wasn't hit yet.");
  26. gDebugger.gThreadClient.resume(() => {
  27. gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
  28. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
  29. is(aPacket.why.type, "breakpoint",
  30. "Execution has advanced to the next breakpoint.");
  31. isnot(aPacket.why.type, "debuggerStatement",
  32. "The breakpoint was hit before the debugger statement.");
  33. ok(isCaretPos(gPanel, 20),
  34. "The source editor caret position is incorrect (2).");
  35. deferred.resolve();
  36. });
  37. });
  38. generateMouseClickInTab(gTab, "content.document.querySelector('button')");
  39. });
  40. return deferred.promise;
  41. }
  42. function testBreakpointHit() {
  43. const deferred = promise.defer();
  44. is(gDebugger.gThreadClient.state, "paused",
  45. "The breakpoint was hit.");
  46. gDebugger.gThreadClient.addOneTimeListener("paused", (aEvent, aPacket) => {
  47. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.FETCHED_SCOPES).then(() => {
  48. is(aPacket.why.type, "debuggerStatement",
  49. "Execution has advanced to the next line.");
  50. isnot(aPacket.why.type, "breakpoint",
  51. "No ghost breakpoint was hit.");
  52. ok(isCaretPos(gPanel, 20),
  53. "The source editor caret position is incorrect (3).");
  54. deferred.resolve();
  55. });
  56. });
  57. EventUtils.sendMouseEvent({ type: "mousedown" },
  58. gDebugger.document.getElementById("resume"),
  59. gDebugger);
  60. return deferred.promise;
  61. }
  62. Task.spawn(function(){
  63. let onCaretUpdated = waitForCaretAndScopes(gPanel, 16);
  64. callInTab(gTab, "runDebuggerStatement");
  65. yield onCaretUpdated;
  66. is(gDebugger.gThreadClient.state, "paused",
  67. "The debugger statement was reached.");
  68. ok(isCaretPos(gPanel, 16),
  69. "The source editor caret position is incorrect (1).");
  70. yield actions.addBreakpoint({ actor: getSourceActor(gSources, TAB_URL), line: 20 });
  71. yield testResume();
  72. yield testBreakpointHit();
  73. resumeDebuggerThenCloseAndFinish(gPanel);
  74. });
  75. });
  76. }