Bug 1205305 - Fix a race condition in browser_dbg_server-conditional-bp-02.js;r=jlong
authorEddy Bruel <ejpbruel@mozilla.com>
Thu, 08 Oct 2015 16:33:37 +0200
changeset 266923 e0a91b61e9c27928f4fa277fb748b614152ffe96
parent 266922 797f58646eb6e4c3ae0591c3ced01cd18cf37138
child 266924 a6abbca3d2e8af13f08acdc899aba317bbbd2bd2
push id66331
push userkwierso@gmail.com
push dateThu, 08 Oct 2015 21:35:51 +0000
treeherdermozilla-inbound@1a5167cd7688 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlong
bugs1205305
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1205305 - Fix a race condition in browser_dbg_server-conditional-bp-02.js;r=jlong
devtools/client/debugger/debugger-controller.js
devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
devtools/client/debugger/test/mochitest/browser_dbg_server-conditional-bp-02.js
devtools/client/debugger/views/sources-view.js
--- a/devtools/client/debugger/debugger-controller.js
+++ b/devtools/client/debugger/debugger-controller.js
@@ -37,16 +37,17 @@ const EVENTS = {
   FETCHED_VARIABLES: "Debugger:FetchedVariables",
   FETCHED_PROPERTIES: "Debugger:FetchedProperties",
   FETCHED_BUBBLE_PROPERTIES: "Debugger:FetchedBubbleProperties",
   FETCHED_WATCH_EXPRESSIONS: "Debugger:FetchedWatchExpressions",
 
   // When a breakpoint has been added or removed on the debugger server.
   BREAKPOINT_ADDED: "Debugger:BreakpointAdded",
   BREAKPOINT_REMOVED: "Debugger:BreakpointRemoved",
+  BREAKPOINT_CLICKED: "Debugger:BreakpointClicked",
 
   // 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",
 
--- a/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_conditional-breakpoints-02.js
@@ -190,13 +190,15 @@ function test() {
       "The editor caret position is not properly set.");
   }
 
   function setCaretPosition(aLine) {
     gEditor.setCursor({ line: aLine - 1, ch: 0 });
   }
 
   function clickOnBreakpoint(aIndex) {
+    let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_CLICKED);
     EventUtils.sendMouseEvent({ type: "click" },
       gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
       gDebugger);
+    return finished;
   }
 }
--- 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
@@ -179,13 +179,15 @@ function test() {
       "The editor caret position is not properly set.");
   }
 
   function setCaretPosition(aLine) {
     gEditor.setCursor({ line: aLine - 1, ch: 0 });
   }
 
   function clickOnBreakpoint(aIndex) {
+    let finished = waitForDebuggerEvents(gPanel, gDebugger.EVENTS.BREAKPOINT_CLICKED);
     EventUtils.sendMouseEvent({ type: "click" },
       gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
       gDebugger);
+    return finished;
   }
 }
--- a/devtools/client/debugger/views/sources-view.js
+++ b/devtools/client/debugger/views/sources-view.js
@@ -461,19 +461,19 @@ SourcesView.prototype = Heritage.extend(
     // Update the editor location if necessary.
     if (!aOptions.noEditorUpdate) {
       this.DebuggerView.setEditorLocation(aLocation.actor, aLocation.line, { noDebug: true });
     }
 
     // If the breakpoint requires a new conditional expression, display
     // the panel to input the corresponding expression.
     if (aOptions.openPopup) {
-      this._openConditionalPopup();
+      return this._openConditionalPopup();
     } else {
-      this._hideConditionalPopup();
+      return this._hideConditionalPopup();
     }
   },
 
   /**
    * Highlight the breakpoint on the current currently focused line/column
    * if it exists.
    */
   highlightBreakpointAtCursor: function() {
@@ -712,23 +712,23 @@ SourcesView.prototype = Heritage.extend(
    */
   _openConditionalPopup: function() {
     let breakpointItem = this._selectedBreakpointItem;
     let attachment = breakpointItem.attachment;
     // Check if this is an enabled conditional breakpoint, and if so,
     // retrieve the current conditional epression.
     let breakpointPromise = this.Breakpoints._getAdded(attachment);
     if (breakpointPromise) {
-      breakpointPromise.then(aBreakpointClient => {
+      return breakpointPromise.then(aBreakpointClient => {
         let isConditionalBreakpoint = aBreakpointClient.hasCondition();
         let condition = aBreakpointClient.getCondition();
-        doOpen.call(this, isConditionalBreakpoint ? condition : "")
+        return doOpen.call(this, isConditionalBreakpoint ? condition : "")
       });
     } else {
-      doOpen.call(this, "")
+      return doOpen.call(this, "")
     }
 
     function doOpen(aConditionalExpression) {
       // Update the conditional expression textbox. If no expression was
       // previously set, revert to using an empty string by default.
       this._cbTextbox.value = aConditionalExpression;
 
       // Show the conditional expression panel. The popup arrow should be pointing
@@ -1035,28 +1035,34 @@ SourcesView.prototype = Heritage.extend(
    * The click listener for a breakpoint container.
    */
   _onBreakpointClick: function(e) {
     let sourceItem = this.getItemForElement(e.target);
     let breakpointItem = this.getItemForElement.call(sourceItem, e.target);
     let attachment = breakpointItem.attachment;
 
     // Check if this is an enabled conditional breakpoint.
-    let breakpointPromise = this.Breakpoints._getAdded(attachment);
-    if (breakpointPromise) {
-      breakpointPromise.then(aBreakpointClient => {
-        doHighlight.call(this, aBreakpointClient.hasCondition());
+    let promise = this.Breakpoints._getAdded(attachment);
+    if (promise) {
+      promise = promise.then(aBreakpointClient => {
+        return doHighlight.call(this, aBreakpointClient.hasCondition());
       });
     } else {
-      doHighlight.call(this, false);
+      promise = Promise.resolve().then(() => {
+        return doHighlight.call(this, false)
+      });
     }
 
+    promise.then(() => {
+      window.emit(EVENTS.BREAKPOINT_CLICKED);
+    });
+
     function doHighlight(aConditionalBreakpointFlag) {
       // Highlight the breakpoint in this pane and in the editor.
-      this.highlightBreakpoint(attachment, {
+      return this.highlightBreakpoint(attachment, {
         // Don't show the conditional expression popup if this is not a
         // conditional breakpoint, or the right mouse button was pressed (to
         // avoid clashing the popup with the context menu).
         openPopup: aConditionalBreakpointFlag && e.button == 0
       });
     }
   },