From e4f7b97c1524c4233cb0de56bd9d5ebe6a41f94d Mon Sep 17 00:00:00 2001 From: Ho-Pang Date: Tue, 27 Dec 2016 03:18:00 -0500 Subject: [PATCH] Bug 1299209 - Part 3: Use the default pointerId if needed in EventUtils.js. f=sshih, r=smaug --HG-- extra : rebase_source : 2b67489658ade21ed6304c4c2f0eb2f01155d47e --- .../mochitest/tests/SimpleTest/EventUtils.js | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index 17243625dbf3..9eee924499cd 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -360,7 +360,20 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) var clickCount = aEvent.clickCount || 1; var modifiers = _parseModifiers(aEvent, aWindow); var pressure = ("pressure" in aEvent) ? aEvent.pressure : 0; - var inputSource = ("inputSource" in aEvent) ? aEvent.inputSource : 0; + + // Default source to mouse. + var inputSource = ("inputSource" in aEvent) ? aEvent.inputSource : + _EU_Ci.nsIDOMMouseEvent.MOZ_SOURCE_MOUSE; + // Compute a pointerId if needed. + var id; + if ("id" in aEvent) { + id = aEvent.id; + } else { + var isFromPen = inputSource === _EU_Ci.nsIDOMMouseEvent.MOZ_SOURCE_PEN; + id = isFromPen ? utils.DEFAULT_PEN_POINTER_ID : + utils.DEFAULT_MOUSE_POINTER_ID; + } + var isDOMEventSynthesized = ("isSynthesized" in aEvent) ? aEvent.isSynthesized : true; var isWidgetEventSynthesized = @@ -373,15 +386,15 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) pressure, inputSource, isDOMEventSynthesized, isWidgetEventSynthesized, - buttons); + buttons, id); } else { utils.sendMouseEvent("mousedown", left, top, button, clickCount, modifiers, false, pressure, inputSource, isDOMEventSynthesized, - isWidgetEventSynthesized, buttons); + isWidgetEventSynthesized, buttons, id); utils.sendMouseEvent("mouseup", left, top, button, clickCount, modifiers, false, pressure, inputSource, isDOMEventSynthesized, - isWidgetEventSynthesized, buttons); + isWidgetEventSynthesized, buttons, id); } } @@ -393,7 +406,7 @@ function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) var utils = _getDOMWindowUtils(aWindow); if (utils) { - var id = aEvent.id || 0; + var id = aEvent.id || utils.DEFAULT_TOUCH_POINTER_ID; var rx = aEvent.rx || 1; var ry = aEvent.rx || 1; var angle = aEvent.angle || 0;