browser_dbg_pause-no-step.js 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. * Tests that pausing / stepping is only enabled when there is a
  6. * location.
  7. */
  8. const TAB_URL = EXAMPLE_URL + "doc_pause-exceptions.html";
  9. var gTab, gPanel, gDebugger;
  10. var gResumeButton, gStepOverButton, gStepOutButton, gStepInButton;
  11. var gResumeKey, gFrames;
  12. function test() {
  13. let options = {
  14. source: TAB_URL,
  15. line: 1
  16. };
  17. initDebugger(TAB_URL, options).then(([aTab,, aPanel]) => {
  18. gTab = aTab;
  19. gPanel = aPanel;
  20. gDebugger = gPanel.panelWin;
  21. gResumeButton = gDebugger.document.getElementById("resume");
  22. gStepOverButton = gDebugger.document.getElementById("step-over");
  23. gStepInButton = gDebugger.document.getElementById("step-in");
  24. gStepOutButton = gDebugger.document.getElementById("step-out");
  25. gResumeKey = gDebugger.document.getElementById("resumeKey");
  26. gFrames = gDebugger.DebuggerView.StackFrames;
  27. testPause();
  28. });
  29. }
  30. function testPause() {
  31. ok(!gDebugger.gThreadClient.paused, "Should be running after starting the test.");
  32. ok(gStepOutButton.disabled, "Stepping out button should be disabled");
  33. ok(gStepInButton.disabled, "Stepping in button should be disabled");
  34. ok(gStepOverButton.disabled, "Stepping over button should be disabled");
  35. gDebugger.gThreadClient.addOneTimeListener("paused", () => {
  36. ok(gDebugger.gThreadClient.paused,
  37. "Should be paused after an interrupt request.");
  38. ok(!gStepOutButton.disabled, "Stepping out button should be enabled");
  39. ok(!gStepInButton.disabled, "Stepping in button should be enabled");
  40. ok(!gStepOverButton.disabled, "Stepping over button should be enabled");
  41. waitForDebuggerEvents(gPanel, gDebugger.EVENTS.AFTER_FRAMES_REFILLED).then(() => {
  42. is(gFrames.itemCount, 1,
  43. "Should have 1 frame from the evalInTab call.");
  44. gDebugger.gThreadClient.resume(testBreakAtLocation);
  45. });
  46. });
  47. EventUtils.sendMouseEvent({ type: "mousedown" }, gResumeButton, gDebugger);
  48. ok(!gDebugger.gThreadClient.paused,
  49. "Shouldn't be paused until the next script is executed.");
  50. ok(gStepOutButton.disabled, "Stepping out button should be disabled");
  51. ok(gStepInButton.disabled, "Stepping in button should be disabled");
  52. ok(gStepOverButton.disabled, "Stepping over button should be disabled");
  53. // Evaluate a script to fully pause the debugger
  54. once(gDebugger.gClient, "willInterrupt").then(() => {
  55. evalInTab(gTab, "1+1;");
  56. });
  57. }
  58. function testBreakAtLocation() {
  59. gDebugger.gThreadClient.addOneTimeListener("paused", () => {
  60. ok(!gStepOutButton.disabled, "Stepping out button should be enabled");
  61. ok(!gStepInButton.disabled, "Stepping in button should be enabled");
  62. ok(!gStepOverButton.disabled, "Stepping over button should be enabled");
  63. resumeDebuggerThenCloseAndFinish(gPanel);
  64. });
  65. BrowserTestUtils.synthesizeMouseAtCenter("button", {}, gBrowser.selectedBrowser);
  66. }
  67. registerCleanupFunction(function () {
  68. gPanel = null;
  69. gDebugger = null;
  70. gResumeButton = null;
  71. gStepOverButton = null;
  72. gStepInButton = null;
  73. gStepOutButton = null;
  74. gResumeKey = null;
  75. gFrames = null;
  76. });