browser_dbg_conditional-breakpoints-03.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 conditional breakpoint expressions survive disabled breakpoints.
  6. */
  7. const TAB_URL = EXAMPLE_URL + "doc_conditional-breakpoints.html";
  8. function test() {
  9. initDebugger().then(([aTab,, aPanel]) => {
  10. const gTab = aTab;
  11. const gPanel = aPanel;
  12. const gDebugger = gPanel.panelWin;
  13. const gSources = gDebugger.DebuggerView.Sources;
  14. const queries = gDebugger.require("./content/queries");
  15. const constants = gDebugger.require("./content/constants");
  16. const actions = bindActionCreators(gPanel);
  17. const getState = gDebugger.DebuggerController.getState;
  18. // This test forces conditional breakpoints to be evaluated on the
  19. // client-side
  20. var client = gPanel.target.client;
  21. client.mainRoot.traits.conditionalBreakpoints = false;
  22. function waitForConditionUpdate() {
  23. // This will close the popup and send another request to update
  24. // the condition
  25. gSources._hideConditionalPopup();
  26. return waitForDispatch(gPanel, constants.SET_BREAKPOINT_CONDITION);
  27. }
  28. Task.spawn(function* () {
  29. let onCaretUpdated = waitForCaretUpdated(gPanel, 17);
  30. yield navigateActiveTabTo(gPanel,
  31. TAB_URL,
  32. gDebugger.EVENTS.SOURCE_SHOWN);
  33. callInTab(gTab, "ermahgerd");
  34. yield onCaretUpdated;
  35. const location = { actor: gSources.selectedValue, line: 18 };
  36. yield actions.addBreakpoint(location, "hello");
  37. yield actions.disableBreakpoint(location);
  38. yield actions.addBreakpoint(location);
  39. const bp = queries.getBreakpoint(getState(), location);
  40. is(bp.condition, "hello", "The conditional expression is correct.");
  41. let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
  42. EventUtils.sendMouseEvent({ type: "click" },
  43. gDebugger.document.querySelector(".dbg-breakpoint"),
  44. gDebugger);
  45. yield finished;
  46. const textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
  47. is(textbox.value, "hello", "The expression is correct (2).");
  48. yield waitForConditionUpdate();
  49. yield actions.disableBreakpoint(location);
  50. yield actions.setBreakpointCondition(location, "foo");
  51. yield actions.addBreakpoint(location);
  52. finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
  53. EventUtils.sendMouseEvent({ type: "click" },
  54. gDebugger.document.querySelector(".dbg-breakpoint"),
  55. gDebugger);
  56. yield finished;
  57. is(textbox.value, "foo", "The expression is correct (3).");
  58. // Reset traits back to default value
  59. client.mainRoot.traits.conditionalBreakpoints = true;
  60. resumeDebuggerThenCloseAndFinish(gPanel);
  61. });
  62. });
  63. }