Bug 1332708 - Open start dragging on a menuitem when dropdown is open. r=mconley, a=ritu
authorNeil Deakin <neil@mozilla.com>
Thu, 26 Jan 2017 05:43:30 -0500
changeset 378098 63fb517341961a9f731fb9b0ac82e0bd6289284b
parent 378097 cc89652117d41bd39286611a20b92acfc2f6125d
child 378099 385b4f5d1c495855e16e6b62ebfb246610e7dc9a
push id1419
push userjlund@mozilla.com
push dateMon, 10 Apr 2017 20:44:07 +0000
treeherdermozilla-release@5e6801b73ef6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, ritu
bugs1332708
milestone53.0a2
Bug 1332708 - Open start dragging on a menuitem when dropdown is open. r=mconley, a=ritu
toolkit/content/tests/chrome/test_menulist.xul
toolkit/content/widgets/popup.xml
--- a/toolkit/content/tests/chrome/test_menulist.xul
+++ b/toolkit/content/tests/chrome/test_menulist.xul
@@ -358,16 +358,25 @@ function dragScroll()
     scrollPos = popup.scrollBox.scrollTop;
     synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 25, { type: "mouseup" });
     is(popup.scrollBox.scrollTop, scrollPos, "scroll position at mouseup should not change");
 
     synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" });
     is(popup.scrollBox.scrollTop, scrollPos, "scroll position at mousemove after mouseup should not change");
 
     menulist.open = false;
+
+    let mouseMoveTarget = null;
+    popup.childNodes[4].click();
+    addEventListener("mousemove", function checkMouseMove(event) {
+      mouseMoveTarget = event.target;
+    }, {once: true});
+    synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" });
+    isnot(mouseMoveTarget, popup, "clicking on item when popup closed doesn't start dragging");
+
     SimpleTest.finish();
   });
 
   menulist.open = true;
 }
 
 ]]>
 </script>
--- a/toolkit/content/widgets/popup.xml
+++ b/toolkit/content/widgets/popup.xml
@@ -689,19 +689,20 @@
         this._draggingState = this.NOT_DRAGGING;
         this._clearScrollTimer();
         this.releaseCapture();
       ]]>
       </handler>
 
       <handler event="mousedown" button="0">
       <![CDATA[
-        if (event.target.localName == "menuitem" ||
-            event.target.localName == "menu" ||
-            event.target.localName == "menucaption") {
+        if (this.state == "open" &&
+            (event.target.localName == "menuitem" ||
+             event.target.localName == "menu" ||
+             event.target.localName == "menucaption")) {
           this.enableDragScrolling(true);
         }
       ]]>
       </handler>
       <handler event="mouseup" button="0">
       <![CDATA[
         this._draggingState = this.NOT_DRAGGING;
         this._clearScrollTimer();