diff --git a/dom/base/nsDOMWindowUtils.cpp b/dom/base/nsDOMWindowUtils.cpp index 28701daa6572..0a755d51e1c7 100644 --- a/dom/base/nsDOMWindowUtils.cpp +++ b/dom/base/nsDOMWindowUtils.cpp @@ -774,156 +774,6 @@ nsDOMWindowUtils::SendMouseEventCommon(const nsAString& aType, aIsDOMEventSynthesized, aIsWidgetEventSynthesized); } -NS_IMETHODIMP -nsDOMWindowUtils::SendPointerEventCommon(const nsAString& aType, - float aX, - float aY, - int32_t aButton, - int32_t aClickCount, - int32_t aModifiers, - bool aIgnoreRootScrollFrame, - float aPressure, - unsigned short aInputSourceArg, - int32_t aPointerId, - int32_t aWidth, - int32_t aHeight, - int32_t aTiltX, - int32_t aTiltY, - bool aIsPrimary, - bool aIsSynthesized, - uint8_t aOptionalArgCount, - bool aToWindow, - bool* aPreventDefault) -{ - // get the widget to send the event to - nsPoint offset; - nsCOMPtr widget = GetWidget(&offset); - if (!widget) { - return NS_ERROR_FAILURE; - } - - EventMessage msg; - if (aType.EqualsLiteral("pointerdown")) { - msg = ePointerDown; - } else if (aType.EqualsLiteral("pointerup")) { - msg = ePointerUp; - } else if (aType.EqualsLiteral("pointermove")) { - msg = ePointerMove; - } else if (aType.EqualsLiteral("pointerover")) { - msg = ePointerOver; - } else if (aType.EqualsLiteral("pointerout")) { - msg = ePointerOut; - } else { - return NS_ERROR_FAILURE; - } - - if (aInputSourceArg == nsIDOMMouseEvent::MOZ_SOURCE_UNKNOWN) { - aInputSourceArg = nsIDOMMouseEvent::MOZ_SOURCE_MOUSE; - } - - WidgetPointerEvent event(true, msg, widget); - event.mModifiers = nsContentUtils::GetWidgetModifiers(aModifiers); - event.button = aButton; - event.buttons = nsContentUtils::GetButtonsFlagForButton(aButton); - event.pressure = aPressure; - event.inputSource = aInputSourceArg; - event.pointerId = aPointerId; - event.mWidth = aWidth; - event.mHeight = aHeight; - event.tiltX = aTiltX; - event.tiltY = aTiltY; - event.mIsPrimary = - (nsIDOMMouseEvent::MOZ_SOURCE_MOUSE == aInputSourceArg) ? true : aIsPrimary; - event.mClickCount = aClickCount; - event.mTime = PR_IntervalNow(); - event.mFlags.mIsSynthesizedForTests = aOptionalArgCount >= 10 ? aIsSynthesized : true; - - nsPresContext* presContext = GetPresContext(); - if (!presContext) { - return NS_ERROR_FAILURE; - } - - event.mRefPoint = - nsContentUtils::ToWidgetPoint(CSSPoint(aX, aY), offset, presContext); - event.mIgnoreRootScrollFrame = aIgnoreRootScrollFrame; - - nsEventStatus status; - if (aToWindow) { - nsCOMPtr presShell; - nsView* view = nsContentUtils::GetViewToDispatchEvent(presContext, getter_AddRefs(presShell)); - if (!presShell || !view) { - return NS_ERROR_FAILURE; - } - status = nsEventStatus_eIgnore; - return presShell->HandleEvent(view->GetFrame(), &event, false, &status); - } - nsresult rv = widget->DispatchEvent(&event, status); - if (aPreventDefault) { - *aPreventDefault = (status == nsEventStatus_eConsumeNoDefault); - } - - return rv; -} - -NS_IMETHODIMP -nsDOMWindowUtils::SendPointerEvent(const nsAString& aType, - float aX, - float aY, - int32_t aButton, - int32_t aClickCount, - int32_t aModifiers, - bool aIgnoreRootScrollFrame, - float aPressure, - unsigned short aInputSourceArg, - int32_t aPointerId, - int32_t aWidth, - int32_t aHeight, - int32_t aTiltX, - int32_t aTiltY, - bool aIsPrimary, - bool aIsSynthesized, - uint8_t aOptionalArgCount, - bool* aPreventDefault) -{ - AUTO_PROFILER_LABEL("nsDOMWindowUtils::SendPointerEvent", EVENTS); - - return SendPointerEventCommon(aType, aX, aY, aButton, aClickCount, - aModifiers, aIgnoreRootScrollFrame, - aPressure, aInputSourceArg, aPointerId, - aWidth, aHeight, aTiltX, aTiltY, - aIsPrimary, aIsSynthesized, - aOptionalArgCount, false, aPreventDefault); -} - -NS_IMETHODIMP -nsDOMWindowUtils::SendPointerEventToWindow(const nsAString& aType, - float aX, - float aY, - int32_t aButton, - int32_t aClickCount, - int32_t aModifiers, - bool aIgnoreRootScrollFrame, - float aPressure, - unsigned short aInputSourceArg, - int32_t aPointerId, - int32_t aWidth, - int32_t aHeight, - int32_t aTiltX, - int32_t aTiltY, - bool aIsPrimary, - bool aIsSynthesized, - uint8_t aOptionalArgCount) -{ - AUTO_PROFILER_LABEL("nsDOMWindowUtils::SendPointerEventToWindow", EVENTS); - - return SendPointerEventCommon(aType, aX, aY, aButton, aClickCount, - aModifiers, aIgnoreRootScrollFrame, - aPressure, aInputSourceArg, aPointerId, - aWidth, aHeight, aTiltX, aTiltY, - aIsPrimary, aIsSynthesized, - aOptionalArgCount, true, nullptr); -} - NS_IMETHODIMP nsDOMWindowUtils::SendWheelEvent(float aX, float aY, diff --git a/dom/base/nsDOMWindowUtils.h b/dom/base/nsDOMWindowUtils.h index 76f07a4596a0..815d13f4c0fa 100644 --- a/dom/base/nsDOMWindowUtils.h +++ b/dom/base/nsDOMWindowUtils.h @@ -100,26 +100,6 @@ protected: bool aIsWidgetEventSynthesized, int32_t aButtons); - NS_IMETHOD SendPointerEventCommon(const nsAString& aType, - float aX, - float aY, - int32_t aButton, - int32_t aClickCount, - int32_t aModifiers, - bool aIgnoreRootScrollFrame, - float aPressure, - unsigned short aInputSourceArg, - int32_t aPointerId, - int32_t aWidth, - int32_t aHeight, - int32_t aTiltX, - int32_t aTiltY, - bool aIsPrimary, - bool aIsSynthesized, - uint8_t aOptionalArgCount, - bool aToWindow, - bool* aPreventDefault); - NS_IMETHOD SendTouchEventCommon(const nsAString& aType, uint32_t* aIdentifiers, int32_t* aXs, diff --git a/dom/events/test/test_bug967796.html b/dom/events/test/test_bug967796.html index 3fcb5b7e2326..77c69a52cd77 100644 --- a/dom/events/test/test_bug967796.html +++ b/dom/events/test/test_bug967796.html @@ -43,9 +43,9 @@ var pointerleavecount = 0; var pointerovercount = 0; var pointeroutcount = 0; -function sendPointerEvent(t, elem) { +function sendMouseEventToElement(t, elem) { var r = elem.getBoundingClientRect(); - synthesizePointer(elem, r.width / 2, r.height / 2, {type: t}); + synthesizeMouse(elem, r.width / 2, r.height / 2, {type: t}); } var expectedPointerEnterTargets = []; @@ -68,7 +68,7 @@ function runTests() { iframe.addEventListener("pointerover", pover); // Make sure ESM thinks pointer is outside the test elements. - sendPointerEvent("pointermove", outside); + sendMouseEventToElement("mousemove", outside); pointerentercount = 0; pointerleavecount = 0; @@ -78,7 +78,7 @@ function runTests() { expectedRelatedEnter = outside; expectedRelatedLeave = inner; expectedPointerEnterTargets = ["outertest", "middletest", "innertest"]; - sendPointerEvent("pointermove", inner); + sendMouseEventToElement("mousemove", inner); is(pointerentercount, 3, "Unexpected pointerenter event count!"); is(pointerovercount, 1, "Unexpected pointerover event count!"); is(pointeroutcount, 0, "Unexpected pointerout event count!"); @@ -86,7 +86,7 @@ function runTests() { expectedRelatedEnter = inner; expectedRelatedLeave = outside; expectedPointerLeaveTargets = ["innertest", "middletest", "outertest"]; - sendPointerEvent("pointermove", outside); + sendMouseEventToElement("mousemove", outside); is(pointerentercount, 3, "Unexpected pointerenter event count!"); is(pointerovercount, 1, "Unexpected pointerover event count!"); is(pointeroutcount, 1, "Unexpected pointerout event count!"); @@ -96,14 +96,14 @@ function runTests() { var r = file.getBoundingClientRect(); expectedRelatedEnter = outside; expectedRelatedLeave = file; - synthesizePointer(file, r.width / 6, r.height / 2, {type: "pointermove"}); + synthesizeMouse(file, r.width / 6, r.height / 2, {type: "mousemove"}); is(pointerentercount, 4, "Unexpected pointerenter event count!"); is(pointerovercount, 2, "Unexpected pointerover event count!"); is(pointeroutcount, 1, "Unexpected pointerout event count!"); is(pointerleavecount, 3, "Unexpected pointerleave event count!"); // Moving pointer over type="file" shouldn't cause pointerover/out/enter/leave events - synthesizePointer(file, r.width - (r.width / 6), r.height / 2, {type: "pointermove"}); + synthesizeMouse(file, r.width - (r.width / 6), r.height / 2, {type: "mousemove"}); is(pointerentercount, 4, "Unexpected pointerenter event count!"); is(pointerovercount, 2, "Unexpected pointerover event count!"); is(pointeroutcount, 1, "Unexpected pointerout event count!"); @@ -111,7 +111,7 @@ function runTests() { expectedRelatedEnter = file; expectedRelatedLeave = outside; - sendPointerEvent("pointermove", outside); + sendMouseEventToElement("mousemove", outside); is(pointerentercount, 4, "Unexpected pointerenter event count!"); is(pointerovercount, 2, "Unexpected pointerover event count!"); is(pointeroutcount, 2, "Unexpected pointerout event count!"); @@ -135,17 +135,17 @@ function runTests() { expectedRelatedEnter = outside; expectedRelatedLeave = iframe; // Move pointer inside the iframe. - synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointermove"}, - iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousemove"}, + iframe.contentWindow); is(pointerentercount, 6, "Unexpected pointerenter event count!"); is(pointerleavecount, 4, "Unexpected pointerleave event count!"); - synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "pointermove"}, - iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "mousemove"}, + iframe.contentWindow); is(pointerentercount, 7, "Unexpected pointerenter event count!"); is(pointerleavecount, 5, "Unexpected pointerleave event count!"); expectedRelatedEnter = iframe; expectedRelatedLeave = outside; - sendPointerEvent("pointermove", outside); + sendMouseEventToElement("mousemove", outside); is(pointerentercount, 7, "Unexpected pointerenter event count!"); is(pointerleavecount, 7, "Unexpected pointerleave event count!"); @@ -153,19 +153,19 @@ function runTests() { expectedRelatedEnter = outside; expectedRelatedLeave = iframe; // Move pointer inside the iframe. - synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointerdown"}, - iframe.contentWindow); - synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "pointerdown"}, - iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousedown"}, + iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height - (r.height / 4), {type: "mousedown"}, + iframe.contentWindow); is(pointerentercount, 10, "Unexpected pointerenter event count!"); // pointerdown + pointermove must produce single pointerenter event expectedRelatedEnter = outside; expectedRelatedLeave = iframe; - synthesizePointer(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "pointerdown"}, - iframe.contentWindow); - synthesizePointer(iframe.contentDocument.body, r.width / 2 + 1, r.height / 4 + 1, {type: "pointermove"}, - iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2, r.height / 4, {type: "mousedown"}, + iframe.contentWindow); + synthesizeMouse(iframe.contentDocument.body, r.width / 2 + 1, r.height / 4 + 1, {type: "mousemove"}, + iframe.contentWindow); is(pointerentercount, 11, "Unexpected pointerenter event count!"); Array.from(document.querySelectorAll('*')) diff --git a/dom/interfaces/base/nsIDOMWindowUtils.idl b/dom/interfaces/base/nsIDOMWindowUtils.idl index 26746fe76daf..376bf7fc6477 100644 --- a/dom/interfaces/base/nsIDOMWindowUtils.idl +++ b/dom/interfaces/base/nsIDOMWindowUtils.idl @@ -342,73 +342,6 @@ interface nsIDOMWindowUtils : nsISupports { [optional] in long aButtons, [optional] in unsigned long aIdentifier); - - /** Synthesize a pointer event. The event types supported are: - * pointerdown, pointerup, pointermove, pointerover, pointerout - * - * Events are sent in coordinates offset by aX and aY from the window. - * - * Note that additional events may be fired as a result of this call. For - * instance, typically a click event will be fired as a result of a - * mousedown and mouseup in sequence. - * - * Normally at this level of events, the pointerover and pointerout events are - * only fired when the window is entered or exited. For inter-element - * pointerover and pointerout events, a movemove event fired on the new element - * should be sufficient to generate the correct over and out events as well. - * - * Cannot be accessed from unprivileged context (not content-accessible) - * Will throw a DOM security error if called without chrome privileges. - * - * The event is dispatched via the toplevel window, so it could go to any - * window under the toplevel window, in some cases it could never reach this - * window at all. - * - * @param aType event type - * @param aX x offset in CSS pixels - * @param aY y offset in CSS pixels - * @param aButton button to synthesize - * @param aClickCount number of clicks that have been performed - * @param aModifiers modifiers pressed, using constants defined as MODIFIER_* - * @param aIgnoreRootScrollFrame whether the event should ignore viewport bounds - * during dispatch - * @param aPressure touch input pressure: 0.0 -> 1.0 - * @param aInputSourceArg input source, see nsIDOMMouseEvent for values, - * defaults to mouse input. - * @param aPointerId A unique identifier for the pointer causing the event, - * defaulting to nsIDOMWindowUtils::DEFAULT_MOUSE_POINTER_ID. - * @param aWidth The width (magnitude on the X axis), default is 0 - * @param aHeight The height (magnitude on the Y axis), default is 0 - * @param aTilt The plane angle between the Y-Z plane - * and the plane containing both the transducer (e.g. pen stylus) axis and the Y axis. default is 0 - * @param aTiltX The plane angle between the X-Z plane - * and the plane containing both the transducer (e.g. pen stylus) axis and the X axis. default is 0 - * @param aIsPrimary Indicates if the pointer represents the primary pointer of this pointer type. - * @param aIsSynthesized controls nsIDOMEvent.isSynthesized value - * that helps identifying test related events, - * defaults to true - * - * returns true if the page called prevent default on this event - */ - - [optional_argc] - boolean sendPointerEvent(in AString aType, - in float aX, - in float aY, - in long aButton, - in long aClickCount, - in long aModifiers, - [optional] in boolean aIgnoreRootScrollFrame, - [optional] in float aPressure, - [optional] in unsigned short aInputSourceArg, - [optional] in long aPointerId, - [optional] in long aWidth, - [optional] in long aHeight, - [optional] in long aTiltX, - [optional] in long aTiltY, - [optional] in boolean aIsPrimary, - [optional] in boolean aIsSynthesized); - /** Synthesize a touch event. The event types supported are: * touchstart, touchend, touchmove, and touchcancel * @@ -465,27 +398,6 @@ interface nsIDOMWindowUtils : nsISupports { [optional] in long aButtons, [optional] in unsigned long aIdentifier); - /** The same as sendPointerEvent but ensures that the event - * is dispatched to this DOM window or one of its children. - */ - [optional_argc] - void sendPointerEventToWindow(in AString aType, - in float aX, - in float aY, - in long aButton, - in long aClickCount, - in long aModifiers, - [optional] in boolean aIgnoreRootScrollFrame, - [optional] in float aPressure, - [optional] in unsigned short aInputSourceArg, - [optional] in long aPointerId, - [optional] in long aWidth, - [optional] in long aHeight, - [optional] in long aTiltX, - [optional] in long aTiltY, - [optional] in boolean aIsPrimary, - [optional] in boolean aIsSynthesized); - /** The same as sendTouchEvent but ensures that the event is dispatched to * this DOM window or one of its children. */ diff --git a/layout/base/tests/bug1078327_inner.html b/layout/base/tests/bug1078327_inner.html index 0d05eb0f4706..9e5f080e1c67 100644 --- a/layout/base/tests/bug1078327_inner.html +++ b/layout/base/tests/bug1078327_inner.html @@ -74,14 +74,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1078327 var rect_t = target.getBoundingClientRect(); var rect_m = mediator.getBoundingClientRect(); var rect_l = listener.getBoundingClientRect(); - synthesizePointer(target, rect_t.width/2, rect_t.height/20, {type: "pointerdown"}); - synthesizePointer(target, rect_t.width/2, rect_t.height/20, {type: "pointermove"}); - synthesizePointer(mediator, rect_m.width/2, rect_m.height/20, {type: "pointermove"}); - synthesizePointer(listener, rect_l.width/2, rect_l.height/20, {type: "pointermove"}); - synthesizePointer(mediator, rect_m.width/2, rect_m.height/20, {type: "pointermove"}); - synthesizePointer(target, rect_t.width/2, rect_t.height/20, {type: "pointermove"}); - synthesizePointer(target, rect_t.width/2, rect_t.height/20, {type: "pointerup"}); - synthesizePointer(target, rect_t.width/2, rect_t.height/20, {type: "pointermove"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousedown"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); + synthesizeMouse(mediator, rect_m.width/2, rect_m.height/20, {type: "mousemove"}); + synthesizeMouse(listener, rect_l.width/2, rect_l.height/20, {type: "mousemove"}); + synthesizeMouse(mediator, rect_m.width/2, rect_m.height/20, {type: "mousemove"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mouseup"}); + synthesizeMouse(target, rect_t.width/2, rect_t.height/20, {type: "mousemove"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug1080360_inner.html b/layout/base/tests/bug1080360_inner.html index edb208dd870e..b0ef7349c2ef 100644 --- a/layout/base/tests/bug1080360_inner.html +++ b/layout/base/tests/bug1080360_inner.html @@ -59,9 +59,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1080360 listener.addEventListener("lostpointercapture", ListenerHandler); document.addEventListener("lostpointercapture", DocumentHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug1080361_inner.html b/layout/base/tests/bug1080361_inner.html index 56bf90185b57..0e9f96368529 100644 --- a/layout/base/tests/bug1080361_inner.html +++ b/layout/base/tests/bug1080361_inner.html @@ -83,9 +83,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1080361 target.addEventListener("pointerup", TargetUpHandler); listener.addEventListener("gotpointercapture", ListenerHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug1153130_inner.html b/layout/base/tests/bug1153130_inner.html index 61bd7f42ddd4..c8df8524ef91 100644 --- a/layout/base/tests/bug1153130_inner.html +++ b/layout/base/tests/bug1153130_inner.html @@ -46,12 +46,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1153130 target.addEventListener("gotpointercapture", TargetHandler); target.addEventListener("pointermove", TargetHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/5, rect.height/5, {type: "pointermove"}); - synthesizePointer(target, rect.width/5, rect.height/5, {type: "pointerdown"}); - synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointermove"}); - synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"}); - synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointerup"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"}); + synthesizeMouse(target, rect.width/5, rect.height/5, {type: "mousemove"}); + synthesizeMouse(target, rect.width/5, rect.height/5, {type: "mousedown"}); + synthesizeMouse(target, rect.width/4, rect.height/4, {type: "mousemove"}); + synthesizeMouse(target, rect.width/3, rect.height/3, {type: "mousemove"}); + synthesizeMouse(target, rect.width/3, rect.height/3, {type: "mouseup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove"}); test_success = true; finishTest(); } diff --git a/layout/base/tests/bug1162990_inner_1.html b/layout/base/tests/bug1162990_inner_1.html index 84d155e329d7..d4644405d73f 100644 --- a/layout/base/tests/bug1162990_inner_1.html +++ b/layout/base/tests/bug1162990_inner_1.html @@ -100,13 +100,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990 setEventHandlers(); var rectCd = child.getBoundingClientRect(); var rectLr = listener.getBoundingClientRect(); - synthesizePointer(listener, rectLr.width/3, rectLr.height/2, {type: "pointerdown"}); - synthesizePointer(child, rectCd.width/3, rectCd.height/2, {type: "pointermove"}); - synthesizePointer(listener, rectLr.width/3, rectLr.height/2, {type: "pointermove"}); - synthesizePointer(child, rectCd.width/3, rectCd.height/2, {type: "pointermove"}); - synthesizePointer(listener, rectLr.width/3, rectLr.height/2, {type: "pointermove"}); - synthesizePointer(listener, rectLr.width/3, rectLr.height/2, {type: "pointerup"}); - synthesizePointer(listener, rectLr.width/3, rectLr.height/3, {type: "pointermove"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/2, {type: "mousedown"}); + synthesizeMouse(child, rectCd.width/3, rectCd.height/2, {type: "mousemove"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/2, {type: "mousemove"}); + synthesizeMouse(child, rectCd.width/3, rectCd.height/2, {type: "mousemove"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/2, {type: "mousemove"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/2, {type: "mouseup"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/3, {type: "mousemove"}); finishTest(); } diff --git a/layout/base/tests/bug1162990_inner_2.html b/layout/base/tests/bug1162990_inner_2.html index a6adadc7b593..72f00a6eabb3 100644 --- a/layout/base/tests/bug1162990_inner_2.html +++ b/layout/base/tests/bug1162990_inner_2.html @@ -101,13 +101,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1162990 var rectTg = target.getBoundingClientRect(); var rectCd = child.getBoundingClientRect(); var rectLr = listener.getBoundingClientRect(); - synthesizePointer(target, rectTg.width/3, rectTg.height/7, {type: "pointerdown"}); - synthesizePointer(child, rectCd.width/3, rectCd.height/2, {type: "pointermove"}); - synthesizePointer(listener, rectLr.width/3, rectLr.height/2, {type: "pointermove"}); - synthesizePointer(child, rectCd.width/3, rectCd.height/2, {type: "pointermove"}); - synthesizePointer(target, rectTg.width/3, rectTg.height/7, {type: "pointermove"}); - synthesizePointer(target, rectTg.width/3, rectTg.height/7, {type: "pointerup"}); - synthesizePointer(target, rectTg.width/3, rectTg.height/9, {type: "pointermove"}); + synthesizeMouse(target, rectTg.width/3, rectTg.height/7, {type: "mousedown"}); + synthesizeMouse(child, rectCd.width/3, rectCd.height/2, {type: "mousemove"}); + synthesizeMouse(listener, rectLr.width/3, rectLr.height/2, {type: "mousemove"}); + synthesizeMouse(child, rectCd.width/3, rectCd.height/2, {type: "mousemove"}); + synthesizeMouse(target, rectTg.width/3, rectTg.height/7, {type: "mousemove"}); + synthesizeMouse(target, rectTg.width/3, rectTg.height/7, {type: "mouseup"}); + synthesizeMouse(target, rectTg.width/3, rectTg.height/9, {type: "mousemove"}); finishTest(); } diff --git a/layout/base/tests/bug977003_inner_1.html b/layout/base/tests/bug977003_inner_1.html index 354863d0fd79..969aa04837a1 100644 --- a/layout/base/tests/bug977003_inner_1.html +++ b/layout/base/tests/bug977003_inner_1.html @@ -68,8 +68,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 target.addEventListener("gotpointercapture", GotPCHandler); target.addEventListener("lostpointercapture", LostPCHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug977003_inner_2.html b/layout/base/tests/bug977003_inner_2.html index 7abc298e0fd6..f053f64854d3 100644 --- a/layout/base/tests/bug977003_inner_2.html +++ b/layout/base/tests/bug977003_inner_2.html @@ -50,8 +50,8 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=977003 listener.addEventListener("gotpointercapture", ListenerHandler); listener.addEventListener("lostpointercapture", ListenerHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug977003_inner_3.html b/layout/base/tests/bug977003_inner_3.html index 28f79ed6e5a5..400014728fab 100644 --- a/layout/base/tests/bug977003_inner_3.html +++ b/layout/base/tests/bug977003_inner_3.html @@ -66,9 +66,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=977003 listener.addEventListener("gotpointercapture", ListenerHandler); listener.addEventListener("lostpointercapture", ListenerHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"}); - synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointermove"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/3, rect.height/3, {type: "mousemove"}); + synthesizeMouse(target, rect.width/4, rect.height/4, {type: "mousemove"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug977003_inner_4.html b/layout/base/tests/bug977003_inner_4.html index 099ec55c02db..558d626a12c1 100644 --- a/layout/base/tests/bug977003_inner_4.html +++ b/layout/base/tests/bug977003_inner_4.html @@ -69,10 +69,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=977003 listener.addEventListener("gotpointercapture", ListenerGotHandler); listener.addEventListener("lostpointercapture", ListenerLostHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/3, rect.height/3, {type: "pointermove"}); - synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointermove"}); - synthesizePointer(target, rect.width/4, rect.height/4, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/3, rect.height/3, {type: "mousemove"}); + synthesizeMouse(target, rect.width/4, rect.height/4, {type: "mousemove"}); + synthesizeMouse(target, rect.width/4, rect.height/4, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug977003_inner_5.html b/layout/base/tests/bug977003_inner_5.html index 1427df56d378..038f256d8705 100644 --- a/layout/base/tests/bug977003_inner_5.html +++ b/layout/base/tests/bug977003_inner_5.html @@ -84,9 +84,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1098139 listener.addEventListener("pointerup", ListenerHandler); listener.addEventListener("pointerout", ListenerHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup", isPrimary: true, inputSource: SpecialPowers.Ci.nsIDOMMouseEvent.MOZ_SOURCE_TOUCH}); finishTest(); } function finishTest() { diff --git a/layout/base/tests/bug977003_inner_6.html b/layout/base/tests/bug977003_inner_6.html index 9eb9295b140e..3366dbec17c9 100644 --- a/layout/base/tests/bug977003_inner_6.html +++ b/layout/base/tests/bug977003_inner_6.html @@ -74,9 +74,9 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1073563 listener.addEventListener("pointerout", ListenerHandler); listener.addEventListener("lostpointercapture", ListenerHandler); var rect = target.getBoundingClientRect(); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerdown"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointermove"}); - synthesizePointer(target, rect.width/2, rect.height/2, {type: "pointerup"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousedown"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mousemove"}); + synthesizeMouse(target, rect.width/2, rect.height/2, {type: "mouseup"}); finishTest(); } function finishTest() { diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index 712376bc5de0..998aaedc6c9d 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -10,7 +10,6 @@ * sendWheelAndPaintNoFlush * synthesizeMouse * synthesizeMouseAtCenter - * synthesizePointer * synthesizeWheel * synthesizeWheelAtPoint * synthesizeKey @@ -363,12 +362,6 @@ function synthesizeTouch(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) synthesizeTouchAtPoint(rect.left + aOffsetX, rect.top + aOffsetY, aEvent, aWindow); } -function synthesizePointer(aTarget, aOffsetX, aOffsetY, aEvent, aWindow) -{ - var rect = aTarget.getBoundingClientRect(); - return synthesizePointerAtPoint(rect.left + aOffsetX, rect.top + aOffsetY, - aEvent, aWindow); -} /* * Synthesize a mouse event at a particular point in aWindow. @@ -454,35 +447,6 @@ function synthesizeTouchAtPoint(left, top, aEvent, aWindow = window) } } -function synthesizePointerAtPoint(left, top, aEvent, aWindow = window) -{ - var utils = _getDOMWindowUtils(aWindow); - var defaultPrevented = false; - - if (utils) { - var button = computeButton(aEvent); - 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; - var synthesized = ("isSynthesized" in aEvent) ? aEvent.isSynthesized : true; - var isPrimary = ("isPrimary" in aEvent) ? aEvent.isPrimary : false; - - if (("type" in aEvent) && aEvent.type) { - defaultPrevented = utils.sendPointerEventToWindow(aEvent.type, left, top, button, - clickCount, modifiers, false, - pressure, inputSource, - synthesized, 0, 0, 0, 0, isPrimary); - } - else { - utils.sendPointerEventToWindow("pointerdown", left, top, button, clickCount, modifiers, false, pressure, inputSource); - utils.sendPointerEventToWindow("pointerup", left, top, button, clickCount, modifiers, false, pressure, inputSource); - } - } - - return defaultPrevented; -} - // Call synthesizeMouse with coordinates at the center of aTarget. function synthesizeMouseAtCenter(aTarget, aEvent, aWindow) { diff --git a/widget/tests/test_assign_event_data.html b/widget/tests/test_assign_event_data.html index 6137cfd2ada4..6b65868648e9 100644 --- a/widget/tests/test_assign_event_data.html +++ b/widget/tests/test_assign_event_data.html @@ -623,12 +623,12 @@ const kTests = [ todoMismatch: [], }, { description: "PointerEvent (pointerdown)", - targetID: "pointer-target", eventType: "pointerdown", + targetID: "pointer-target", eventType: "mousedown", dispatchEvent: function () { var elem = document.getElementById(this.targetID); var rect = elem.getBoundingClientRect(); - synthesizePointer(elem, rect.width/2, rect.height/2, - { type: this.eventType, button: 1, clickCount: 1, inputSource: 2, pressure: 0.25, isPrimary: true }); + synthesizeMouse(elem, rect.width/2, rect.height/2, + { type: this.eventType, button: 1, clickCount: 1, inputSource: 2, pressure: 0.25, isPrimary: true }); }, canRun: function () { return true; @@ -636,12 +636,12 @@ const kTests = [ todoMismatch: [], }, { description: "PointerEvent (pointerup)", - targetID: "pointer-target", eventType: "pointerup", + targetID: "pointer-target", eventType: "mouseup", dispatchEvent: function () { var elem = document.getElementById(this.targetID); var rect = elem.getBoundingClientRect(); - synthesizePointer(elem, rect.width/2, rect.height/2, - { type: this.eventType, button: -1, ctrlKey: true, shiftKey: true, altKey: true, isSynthesized: false }); + synthesizeMouse(elem, rect.width/2, rect.height/2, + { type: this.eventType, button: -1, ctrlKey: true, shiftKey: true, altKey: true, isSynthesized: false }); }, canRun: function () { return true;