Bug 1251492 - Don't prevent default behavior of unrelated mouse events in HSplitBox. r=linclark
authorNick Fitzgerald <fitzgen@gmail.com>
Wed, 02 Mar 2016 11:05:00 -0500
changeset 322965 579da5ef8ccf4417fb472947e4cd5665f7f90a46
parent 322964 d208534148ecee3c49b525fa8207680840074114
child 322966 cd697b51aed416ac3be564b7b2dff6b44178481b
push id5913
push userjlund@mozilla.com
push dateMon, 25 Apr 2016 16:57:49 +0000
treeherdermozilla-beta@dcaf0a6fa115 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerslinclark
bugs1251492
milestone47.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 1251492 - Don't prevent default behavior of unrelated mouse events in HSplitBox. r=linclark
devtools/client/shared/components/h-split-box.js
devtools/client/shared/components/test/mochitest/test_HSplitBox_01.html
--- a/devtools/client/shared/components/h-split-box.js
+++ b/devtools/client/shared/components/h-split-box.js
@@ -64,21 +64,29 @@ module.exports = createClass({
 
     // A callback fired when the user drags the splitter to resize the relative
     // pane widths. The function is passed the startWidth value that would put
     // the splitter underneath the users mouse.
     onResize: PropTypes.func.isRequired,
   },
 
   _onMouseDown(event) {
+    if (event.button !== 0) {
+      return;
+    }
+
     this.setState({ mouseDown: true });
     event.preventDefault();
   },
 
   _onMouseUp(event) {
+    if (event.button !== 0 || !this.state.mouseDown) {
+      return;
+    }
+
     this.setState({ mouseDown: false });
     event.preventDefault();
   },
 
   _onMouseMove(event) {
     if (!this.state.mouseDown) {
       return;
     }
--- a/devtools/client/shared/components/test/mochitest/test_HSplitBox_01.html
+++ b/devtools/client/shared/components/test/mochitest/test_HSplitBox_01.html
@@ -75,17 +75,17 @@ window.onload = Task.async(function* () 
     is(newSizes.length, 0, "Mouse moves without dragging the splitter should have no effect");
 
     // Send a mouse down on the splitter, and then move the mouse a couple
     // times. Now we should get resizes.
 
     const splitter = document.querySelector(".h-split-box-splitter");
     ok(splitter, "Should get our splitter");
 
-    synthesizeMouseAtCenter(splitter, { button: 1, type: "mousedown" }, window);
+    synthesizeMouseAtCenter(splitter, { button: 0, type: "mousedown" }, window);
 
     function mouseMove(clientX) {
       const event = new MouseEvent("mousemove", { clientX });
       document.defaultView.top.dispatchEvent(event);
     }
 
     mouseMove(middle);
     is(newSizes.length, 1, "Should get 1 resize");
@@ -98,17 +98,17 @@ window.onload = Task.async(function* () 
     mouseMove(oneQuarter);
     is(newSizes.length, 3, "Sould get 3 resizes");
     ok(aboutEq(newSizes[2], .25), "New size should be ~.25");
 
     mouseMove(threeQuarters);
     is(newSizes.length, 4, "Should get 4 resizes");
     ok(aboutEq(newSizes[3], .75), "New size should be ~.75");
 
-    synthesizeMouseAtCenter(splitter, { button: 1, type: "mouseup" }, window);
+    synthesizeMouseAtCenter(splitter, { button: 0, type: "mouseup" }, window);
 
     // Now that we have let go of the splitter, mouse moves should not result in resizes.
 
     synthesizeMouse(container, middle, top, { type: "mousemove" }, window);
     is(newSizes.length, 4, "Should still have 4 resizes");
 
   } catch(e) {
     ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));