Bug 1159276 - Prevent showing the source context menu if the breakpoint context menu is also going to be shown;r=jlongster
authorBrian Grinstead <bgrinstead@mozilla.com>
Tue, 28 Apr 2015 14:10:08 -0700
changeset 273002 dd8c914eb1f22ff9cccf1c1a1e46b7ad40ae00d4
parent 273001 2696c3d2ee5118bc1be664eb9528485584b58d8a
child 273003 925dd58e0035db4c14f5d5096ff4f1ed761f0cdf
push id863
push userraliiev@mozilla.com
push dateMon, 03 Aug 2015 13:22:43 +0000
treeherdermozilla-release@f6321b14228d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjlongster
bugs1159276
milestone40.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 1159276 - Prevent showing the source context menu if the breakpoint context menu is also going to be shown;r=jlongster
browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
browser/devtools/shared/widgets/SideMenuWidget.jsm
--- a/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
+++ b/browser/devtools/debugger/test/browser_dbg_breakpoints-contextmenu.js
@@ -96,42 +96,53 @@ function test() {
     ok(isCaretPos(gPanel, 9),
       "The editor location is correct before pausing.");
 
     sendMouseClickToTab(gTab, content.document.querySelector("button"));
 
     return finished;
   }
 
-  function initialChecks() {
+  let initialChecks = Task.async(function*() {
     for (let source of gSources) {
       for (let breakpoint of source) {
         ok(gBreakpoints._getAdded(breakpoint.attachment),
           "All breakpoint items should have corresponding promises (1).");
         ok(!gBreakpoints._getRemoving(breakpoint.attachment),
           "All breakpoint items should have corresponding promises (2).");
         ok(breakpoint.attachment.actor,
           "All breakpoint items should have corresponding promises (3).");
         is(!!breakpoint.attachment.disabled, false,
           "All breakpoints should initially be enabled.");
 
         let prefix = "bp-cMenu-"; // "breakpoints context menu"
         let identifier = gBreakpoints.getIdentifier(breakpoint.attachment);
         let enableSelfId = prefix + "enableSelf-" + identifier + "-menuitem";
         let disableSelfId = prefix + "disableSelf-" + identifier + "-menuitem";
 
+        // Check to make sure that only the bp context menu is shown when right clicking
+        // this node (Bug 1159276).
+        let menu = gDebugger.document.getElementById("bp-mPop-" + identifier);
+        let contextMenuShown = once(gDebugger.document, "popupshown");
+        EventUtils.synthesizeMouseAtCenter(breakpoint.prebuiltNode, {type: 'contextmenu', button: 2}, gDebugger);
+        let event = yield contextMenuShown;
+        is (event.originalTarget.id, menu.id, "The correct context menu was shown");
+        let contextMenuHidden = once(gDebugger.document, "popuphidden");
+        menu.hidePopup();
+        yield contextMenuHidden;
+
         is(gDebugger.document.getElementById(enableSelfId).getAttribute("hidden"), "true",
           "The 'Enable breakpoint' context menu item should initially be hidden'.");
         ok(!gDebugger.document.getElementById(disableSelfId).hasAttribute("hidden"),
           "The 'Disable breakpoint' context menu item should initially not be hidden'.");
         is(breakpoint.attachment.view.checkbox.getAttribute("checked"), "true",
           "All breakpoints should initially have a checked checkbox.");
       }
     }
-  }
+  });
 
   function checkBreakpointToggleSelf(aIndex) {
     let deferred = promise.defer();
 
     EventUtils.sendMouseEvent({ type: "click" },
       gDebugger.document.querySelectorAll(".dbg-breakpoint")[aIndex],
       gDebugger);
 
--- a/browser/devtools/shared/widgets/SideMenuWidget.jsm
+++ b/browser/devtools/shared/widgets/SideMenuWidget.jsm
@@ -395,16 +395,25 @@ SideMenuWidget.prototype = {
   /**
    * Shows the contextMenu element.
    */
   _showContextMenu: function(e) {
     if (!this._contextMenu) {
       return;
     }
 
+    // Don't show the menu if a descendant node is going to be visible also.
+    let node = e.originalTarget;
+    while (node && node !== this._list) {
+      if (node.hasAttribute("contextmenu")) {
+        return;
+      }
+      node = node.parentNode;
+    }
+
     this._contextMenu.openPopupAtScreen(e.screenX, e.screenY, true);
   },
 
   window: null,
   document: null,
   _showArrows: false,
   _showItemCheckboxes: false,
   _showGroupCheckboxes: false,