Bug 1287388 - wait for popupshown event in debugger conditional breakpoint tests;r=jlongster draft
authorJulian Descottes <jdescottes@mozilla.com>
Mon, 11 Jul 2016 10:01:18 +0200
changeset 397783 e3ab635af89936ce94b3b7b035c0f3642d9c38f0
parent 397782 46dede080ba1b6bcaaf5af7b00fc5e356c66faac
child 527539 819278d7c08985c78ae25448f8ac3a19478098a6
push id25393
push userjdescottes@mozilla.com
push dateMon, 08 Aug 2016 09:37:06 +0000
reviewersjlongster
bugs1287388
milestone51.0a1
Bug 1287388 - wait for popupshown event in debugger conditional breakpoint tests;r=jlongster MozReview-Commit-ID: CXCoUKSLiGb
devtools/client/debugger/content/views/sources-view.js
devtools/client/debugger/debugger-controller.js
devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-03.js
devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js
devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-03.js
--- a/devtools/client/debugger/content/views/sources-view.js
+++ b/devtools/client/debugger/content/views/sources-view.js
@@ -1163,25 +1163,25 @@ SourcesView.prototype = Heritage.extend(
     e.stopPropagation();
   },
 
   /**
    * The popup showing listener for the breakpoints conditional expression panel.
    */
   _onConditionalPopupShowing: function () {
     this._conditionalPopupVisible = true; // Used in tests.
-    window.emit(EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
   },
 
   /**
    * The popup shown listener for the breakpoints conditional expression panel.
    */
   _onConditionalPopupShown: function () {
     this._cbTextbox.focus();
     this._cbTextbox.select();
+    window.emit(EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
   },
 
   /**
    * The popup hiding listener for the breakpoints conditional expression panel.
    */
   _onConditionalPopupHiding: function () {
     this._conditionalPopupVisible = false; // Used in tests.
 
@@ -1194,16 +1194,17 @@ SourcesView.prototype = Heritage.extend(
     }
   },
 
   /**
    * The popup hidden listener for the breakpoints conditional expression panel.
    */
   _onConditionalPopupHidden: function () {
     this._cbPanel.hidden = true;
+    window.emit(EVENTS.CONDITIONAL_BREAKPOINT_POPUP_HIDDEN);
   },
 
   /**
    * The keypress listener for the breakpoints conditional expression textbox.
    */
   _onConditionalTextboxKeyPress: function (e) {
     if (e.keyCode == e.DOM_VK_RETURN) {
       this._hideConditionalPopup();
--- a/devtools/client/debugger/debugger-controller.js
+++ b/devtools/client/debugger/debugger-controller.js
@@ -46,19 +46,19 @@ const EVENTS = {
 
   // When a breakpoint has been shown or hidden in the source editor
   // or the pane.
   BREAKPOINT_SHOWN_IN_EDITOR: "Debugger:BreakpointShownInEditor",
   BREAKPOINT_SHOWN_IN_PANE: "Debugger:BreakpointShownInPane",
   BREAKPOINT_HIDDEN_IN_EDITOR: "Debugger:BreakpointHiddenInEditor",
   BREAKPOINT_HIDDEN_IN_PANE: "Debugger:BreakpointHiddenInPane",
 
-  // When a conditional breakpoint's popup is showing or hiding.
-  CONDITIONAL_BREAKPOINT_POPUP_SHOWING: "Debugger:ConditionalBreakpointPopupShowing",
-  CONDITIONAL_BREAKPOINT_POPUP_HIDING: "Debugger:ConditionalBreakpointPopupHiding",
+  // When a conditional breakpoint's popup is shown/hidden.
+  CONDITIONAL_BREAKPOINT_POPUP_SHOWN: "Debugger:ConditionalBreakpointPopupShown",
+  CONDITIONAL_BREAKPOINT_POPUP_HIDDEN: "Debugger:ConditionalBreakpointPopupHidden",
 
   // When event listeners are fetched or event breakpoints are updated.
   EVENT_LISTENERS_FETCHED: "Debugger:EventListenersFetched",
   EVENT_BREAKPOINTS_UPDATED: "Debugger:EventBreakpointsUpdated",
 
   // When a file search was performed.
   FILE_SEARCH_MATCH_FOUND: "Debugger:FileSearch:MatchFound",
   FILE_SEARCH_MATCH_NOT_FOUND: "Debugger:FileSearch:MatchNotFound",
--- a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
@@ -19,16 +19,17 @@ function test() {
     const gPanel = aPanel;
     const gDebugger = gPanel.panelWin;
     const gEditor = gDebugger.DebuggerView.editor;
     const gSources = gDebugger.DebuggerView.Sources;
     const queries = gDebugger.require("./content/queries");
     const constants = gDebugger.require("./content/constants");
     const actions = bindActionCreators(gPanel);
     const getState = gDebugger.DebuggerController.getState;
+    const CONDITIONAL_POPUP_SHOWN = gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN;
 
     // This test forces conditional breakpoints to be evaluated on the
     // client-side
     var client = gPanel.target.client;
     client.mainRoot.traits.conditionalBreakpoints = false;
 
     function addBreakpoint1() {
       return actions.addBreakpoint({ actor: gSources.selectedValue, line: 18 });
@@ -38,33 +39,42 @@ function test() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
       setCaretPosition(19);
       gSources._onCmdAddBreakpoint();
       return finished;
     }
 
     function modBreakpoint2() {
       setCaretPosition(19);
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
       gSources._onCmdAddConditionalBreakpoint();
+      return popupShown;
     }
 
-    function addBreakpoint3() {
+    function* addBreakpoint3() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
       setCaretPosition(20);
       gSources._onCmdAddConditionalBreakpoint();
-      return finished;
+      yield finished;
+      yield popupShown;
     }
 
-    function modBreakpoint3() {
-      let finished = waitForDispatch(gPanel, constants.SET_BREAKPOINT_CONDITION);
+    function* modBreakpoint3() {
       setCaretPosition(20);
+
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
       gSources._onCmdAddConditionalBreakpoint();
+      yield popupShown;
+
       typeText(gSources._cbTextbox, "bamboocha");
+
+      let finished = waitForDispatch(gPanel, constants.SET_BREAKPOINT_CONDITION);
       EventUtils.sendKey("RETURN", gDebugger);
-      return finished;
+      yield finished;
     }
 
     function addBreakpoint4() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
       setCaretPosition(21);
       gSources._onCmdAddBreakpoint();
       return finished;
     }
--- a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-03.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-03.js
@@ -44,31 +44,31 @@ function test() {
 
       yield actions.addBreakpoint(location, "hello");
       yield actions.disableBreakpoint(location);
       yield actions.addBreakpoint(location);
 
       const bp = queries.getBreakpoint(getState(), location);
       is(bp.condition, "hello", "The conditional expression is correct.");
 
-      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
+      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
       EventUtils.sendMouseEvent({ type: "click" },
                                 gDebugger.document.querySelector(".dbg-breakpoint"),
                                 gDebugger);
       yield finished;
 
       const textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
       is(textbox.value, "hello", "The expression is correct (2).");
 
       yield waitForConditionUpdate();
       yield actions.disableBreakpoint(location);
       yield actions.setBreakpointCondition(location, "foo");
       yield actions.addBreakpoint(location);
 
-      finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
+      finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
       EventUtils.sendMouseEvent({ type: "click" },
                                 gDebugger.document.querySelector(".dbg-breakpoint"),
                                 gDebugger);
       yield finished;
       is(textbox.value, "foo", "The expression is correct (3).");
 
       // Reset traits back to default value
       client.mainRoot.traits.conditionalBreakpoints = true;
--- a/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js
@@ -19,47 +19,59 @@ function test() {
     const gPanel = aPanel;
     const gDebugger = gPanel.panelWin;
     const gEditor = gDebugger.DebuggerView.editor;
     const gSources = gDebugger.DebuggerView.Sources;
     const queries = gDebugger.require("./content/queries");
     const constants = gDebugger.require("./content/constants");
     const actions = bindActionCreators(gPanel);
     const getState = gDebugger.DebuggerController.getState;
+    const CONDITIONAL_POPUP_SHOWN = gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN;
 
     function addBreakpoint1() {
       return actions.addBreakpoint({ actor: gSources.selectedValue, line: 18 });
     }
 
     function addBreakpoint2() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
       setCaretPosition(19);
       gSources._onCmdAddBreakpoint();
       return finished;
     }
 
     function modBreakpoint2() {
       setCaretPosition(19);
+
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
       gSources._onCmdAddConditionalBreakpoint();
+      return popupShown;
     }
 
-    function addBreakpoint3() {
+    function* addBreakpoint3() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
+
       setCaretPosition(20);
       gSources._onCmdAddConditionalBreakpoint();
-      return finished;
+      yield finished;
+      yield popupShown;
     }
 
-    function modBreakpoint3() {
-      let finished = waitForDispatch(gPanel, constants.SET_BREAKPOINT_CONDITION);
+    function* modBreakpoint3() {
       setCaretPosition(20);
+
+      let popupShown = waitForDebuggerEvents(gPanel, CONDITIONAL_POPUP_SHOWN);
       gSources._onCmdAddConditionalBreakpoint();
+      yield popupShown;
+
       typeText(gSources._cbTextbox, "bamboocha");
+
+      let finished = waitForDispatch(gPanel, constants.SET_BREAKPOINT_CONDITION);
       EventUtils.sendKey("RETURN", gDebugger);
-      return finished;
+      yield finished;
     }
 
     function addBreakpoint4() {
       let finished = waitForDispatch(gPanel, constants.ADD_BREAKPOINT);
       setCaretPosition(21);
       gSources._onCmdAddBreakpoint();
       return finished;
     }
--- a/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-03.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-03.js
@@ -41,31 +41,31 @@ function test() {
 
       yield actions.addBreakpoint(location, "hello");
       yield actions.disableBreakpoint(location);
       yield actions.addBreakpoint(location);
 
       const bp = queries.getBreakpoint(getState(), location);
       is(bp.condition, "hello", "The conditional expression is correct.");
 
-      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
+      let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
       EventUtils.sendMouseEvent({ type: "click" },
                                 gDebugger.document.querySelector(".dbg-breakpoint"),
                                 gDebugger);
       yield finished;
 
       const textbox = gDebugger.document.getElementById("conditional-breakpoint-panel-textbox");
       is(textbox.value, "hello", "The expression is correct (2).");
 
       yield waitForConditionUpdate();
       yield actions.disableBreakpoint(location);
       yield actions.setBreakpointCondition(location, "foo");
       yield actions.addBreakpoint(location);
 
-      finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWING);
+      finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.CONDITIONAL_BREAKPOINT_POPUP_SHOWN);
       EventUtils.sendMouseEvent({ type: "click" },
                                 gDebugger.document.querySelector(".dbg-breakpoint"),
                                 gDebugger);
       yield finished;
       is(textbox.value, "foo", "The expression is correct (3).");
 
       yield resumeDebuggerThenCloseAndFinish(gPanel);
     });