Bug 1258821 - Cannot open the expression panel of conditional breakpoint. r=jlong
authorJason Laster <jlaster@mozilla.com>
Wed, 30 Mar 2016 07:46:00 +0200
changeset 329196 646cc46e3cfc57fde0a898635a866bb7341750aa
parent 329195 64550b75f51b8a8a4c155e93f55d8c3d7494aa22
child 329197 3eb3406f08b594fe2b54926c6649eb8c5347104d
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlong
bugs1258821
milestone48.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 1258821 - Cannot open the expression panel of conditional breakpoint. r=jlong
devtools/client/debugger/content/views/sources-view.js
--- a/devtools/client/debugger/content/views/sources-view.js
+++ b/devtools/client/debugger/content/views/sources-view.js
@@ -61,16 +61,17 @@ function SourcesView(controller, Debugge
   this._onBreakpointCheckboxClick = this._onBreakpointCheckboxClick.bind(this);
   this._onConditionalPopupShowing = this._onConditionalPopupShowing.bind(this);
   this._onConditionalPopupShown = this._onConditionalPopupShown.bind(this);
   this._onConditionalPopupHiding = this._onConditionalPopupHiding.bind(this);
   this._onConditionalTextboxKeyPress = this._onConditionalTextboxKeyPress.bind(this);
   this._onEditorContextMenuOpen = this._onEditorContextMenuOpen.bind(this);
   this._onCopyUrlCommand = this._onCopyUrlCommand.bind(this);
   this._onNewTabCommand = this._onNewTabCommand.bind(this);
+  this._onConditionalPopupHidden = this._onConditionalPopupHidden.bind(this);
 }
 
 SourcesView.prototype = Heritage.extend(WidgetMethods, {
   /**
    * Initialization function, called when the debugger is started.
    */
   initialize: function() {
     dumpn("Initializing the SourcesView");
@@ -108,20 +109,22 @@ SourcesView.prototype = Heritage.extend(
     this._editorContainer.addEventListener("mousedown", this._onMouseDown, false);
 
     this.widget.addEventListener("select", this._onSourceSelect, false);
 
     this._stopBlackBoxButton.addEventListener("click", this._onStopBlackBoxing, false);
     this._cbPanel.addEventListener("popupshowing", this._onConditionalPopupShowing, false);
     this._cbPanel.addEventListener("popupshown", this._onConditionalPopupShown, false);
     this._cbPanel.addEventListener("popuphiding", this._onConditionalPopupHiding, false);
+    this._cbPanel.addEventListener("popuphidden", this._onConditionalPopupHidden, false);
     this._cbTextbox.addEventListener("keypress", this._onConditionalTextboxKeyPress, false);
     this._copyUrlMenuItem.addEventListener("command", this._onCopyUrlCommand, false);
     this._newTabMenuItem.addEventListener("command", this._onNewTabCommand, false);
 
+    this._cbPanel.hidden = true;
     this.allowFocusOnRightClick = true;
     this.autoFocusOnSelection = false;
     this.autoFocusOnFirstItem = false;
 
     // Sort the contents by the displayed label.
     this.sortContents((aFirst, aSecond) => {
       return +(aFirst.attachment.label.toLowerCase() >
                aSecond.attachment.label.toLowerCase());
@@ -146,16 +149,17 @@ SourcesView.prototype = Heritage.extend(
   destroy: function() {
     dumpn("Destroying the SourcesView");
 
     this.widget.removeEventListener("select", this._onSourceSelect, false);
     this._stopBlackBoxButton.removeEventListener("click", this._onStopBlackBoxing, false);
     this._cbPanel.removeEventListener("popupshowing", this._onConditionalPopupShowing, false);
     this._cbPanel.removeEventListener("popupshown", this._onConditionalPopupShown, false);
     this._cbPanel.removeEventListener("popuphiding", this._onConditionalPopupHiding, false);
+    this._cbPanel.removeEventListener("popuphidden", this._onConditionalPopupHidden, false);
     this._cbTextbox.removeEventListener("keypress", this._onConditionalTextboxKeyPress, false);
     this._copyUrlMenuItem.removeEventListener("command", this._onCopyUrlCommand, false);
     this._newTabMenuItem.removeEventListener("command", this._onNewTabCommand, false);
     this.DebuggerView.editor.off("popupOpen", this._onEditorContextMenuOpen, false);
   },
 
   empty: function() {
     WidgetMethods.empty.call(this);
@@ -672,36 +676,47 @@ SourcesView.prototype = Heritage.extend(
    */
   _openConditionalPopup: function() {
     let breakpointItem = this._getBreakpoint(this._selectedBreakpoint);
     let attachment = breakpointItem.attachment;
     // Check if this is an enabled conditional breakpoint, and if so,
     // retrieve the current conditional epression.
     let bp = getBreakpoint(this.getState(), attachment);
     let expr = (bp ? (bp.condition || "") : "");
+    let cbPanel = this._cbPanel;
 
     // Update the conditional expression textbox. If no expression was
     // previously set, revert to using an empty string by default.
     this._cbTextbox.value = expr;
 
-    // Show the conditional expression panel. The popup arrow should be pointing
-    // at the line number node in the breakpoint item view.
-    this._cbPanel.hidden = false;
-    this._cbPanel.openPopup(breakpointItem.attachment.view.lineNumber,
-                            BREAKPOINT_CONDITIONAL_POPUP_POSITION,
-                            BREAKPOINT_CONDITIONAL_POPUP_OFFSET_X,
-                            BREAKPOINT_CONDITIONAL_POPUP_OFFSET_Y);
+
+    function openPopup() {
+      // Show the conditional expression panel. The popup arrow should be pointing
+      // at the line number node in the breakpoint item view.
+      cbPanel.hidden = false;
+      cbPanel.openPopup(breakpointItem.attachment.view.lineNumber,
+                              BREAKPOINT_CONDITIONAL_POPUP_POSITION,
+                              BREAKPOINT_CONDITIONAL_POPUP_OFFSET_X,
+                              BREAKPOINT_CONDITIONAL_POPUP_OFFSET_Y);
+
+      cbPanel.removeEventListener('popuphidden', openPopup, false);
+    }
+
+    // Wait until the other cb panel is closed
+    if (!this._cbPanel.hidden) {
+      this._cbPanel.addEventListener('popuphidden', openPopup, false);
+    } else {
+      openPopup();
+    }
   },
 
   /**
    * Hides a conditional breakpoint's expression input popup.
    */
   _hideConditionalPopup: function() {
-    this._cbPanel.hidden = true;
-
     // Sometimes this._cbPanel doesn't have hidePopup method which doesn't
     // break anything but simply outputs an exception to the console.
     if (this._cbPanel.hidePopup) {
       this._cbPanel.hidePopup();
     }
   },
 
   /**
@@ -1168,16 +1183,23 @@ SourcesView.prototype = Heritage.extend(
     let bp = this._selectedBreakpoint;
     if (bp) {
       let condition = this._cbTextbox.value;
       this.actions.setBreakpointCondition(bp.location, condition);
     }
   },
 
   /**
+   * The popup hidden listener for the breakpoints conditional expression panel.
+   */
+  _onConditionalPopupHidden: function() {
+    this._cbPanel.hidden = true;
+  },
+
+  /**
    * The keypress listener for the breakpoints conditional expression textbox.
    */
   _onConditionalTextboxKeyPress: function(e) {
     if (e.keyCode == e.DOM_VK_RETURN) {
       this._hideConditionalPopup();
     }
   },