This change affects developers who need to synthesize **native** mouse events in mochitest of any flavor.

Currently, these APIs take raw native event message as their param. I.e., they require helper functions returning different value for each platform. This causes some tests messy because of copying them from utility files.

Additionally these API don't take mouse button ID nor modifiers. The former is caused by `nsIDOMWindowUtils::SendNativeMouseEvent` was designed assuming that any platforms having native mouse press/release message for each button, but it's not true on Linux, macOS and Android. The latter is caused by that the APIs do not have an argument to specify it.

Bug 1691622 [1] will make them easier to use, and align the API style to `synthesizeNativeKeyEvent`.

First, `synthesizeNativeMouseClick*`, `synthesizeNativeMouseClickAtCenter` and `synthesizeMouseMove` will be merged to `synthesizeNativeMouseEvent*`. Then it'll take an `Object` param which contains a `type` member to specify which mouse event should be synthesized. It takes "mousemove", "click", "mousedown" and "mouseup".

Next, the `Object` param will contain `modifiers` member which is an `Object` containing `shitKey`, `ctrlKey`, `altKey`, `metaKey`, `capsLockKey`, `numLockKey`, `accelKey`, etc.

Next, the `Object` param contains `target` element. It's must not be `null` if you use APZ-aware version. `offsetX` and `offsetY` are relative to it, setting `atCenter` to `true` means to synthesize the native mouse event(s) at center of `target`.

Next, the `Object` param can contain `screenX` and `screenY`. When the caller knows screen pixels, these members are useful.

Next, you can specify in which unit `clientX`, `clientY`, `screenX` and `screenY` are only for `EventUtils` version. "inScreenPixels" means that they are in device pixels, "screenPixelPerCSSPixels" (this is default value) means that they are in CSS pixels with current zoom level. "screenPixelPerCSSPixelsNoOverride" means that they are in CSS pixels but ignoring zoom state (IIUC for the latter 2).

Finally, there will be `promiseNativeMouseEvent`, `synthesizeNativeMouseEventAndWaitForEvent`, `promiseNativeMouseEventAndWaitForEvent`.

Note that unfortunately, modifiers are not available on Windows and Android for now, and X1 and X2 button events can be synthesized only on Windows, but they may not be caused mouse events since they are typically converted to `WM_APPCOMMAND` message for "back" and "forward" navigation.

I hope this change will help you to write chrome and content collaborating test like related to xorigin event delivering and autoscrolling.

If you have some additional suggestions, let me know.

[1] https://bugzilla.mozilla.org/show_bug.cgi?id=1691622

--
Masayuki Nakano <masay...@d-toybox.com>
Working on DOM, Events, editor and IME handling for Gecko

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to