Add a "widget" event synthesization API for wheel events
Categories
(Core :: Panning and Zooming, enhancement, P2)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox139 | --- | fixed |
People
(Reporter: whimboo, Assigned: whimboo)
References
(Blocks 1 open bug)
Details
(Whiteboard: [webdriver:m16])
Attachments
(2 files, 1 obsolete file)
This bug tracks introducing an nsIDOMWindowUtils API for synthesizing "widget" wheel events which will be sent to the parent process and go through APZ processing there, but unlike "native" wheel events will not be injected into the operating system's native event queue.
We need this API for bug 1848957 to send widget events via WebDriver.
Updated•7 months ago
|
| Assignee | ||
Comment 1•7 months ago
|
||
Original Revision: https://phabricator.services.mozilla.com/D186548
Updated•7 months ago
|
| Assignee | ||
Updated•7 months ago
|
| Assignee | ||
Comment 2•7 months ago
|
||
With the changes for DOMWindowUtils and EventUtils (as attached as patch) I tried to update the following test as proposed by Hiro to switch from native events to widget events but I can see different issues with missing events:
- Compared to sending a native event the expected events are not always emitted, especially not when we already are at
scrollTop == 0 - When a scroll is performed (modifying
scrollTopbefore) it doesn't matter if I enable async events or not,scrollandscrollendare always emitted. What would need to change to only emit them with widget events? I thought it's the overscroll, but maybe there is another factor?
Feel free to attach the patch from Phabricator, apply the following changes as well, and run the command:
mach mochitest gfx/layers/apz/test/mochitest/test_group_overscroll_handoff.html
to reproduce.
diff --git a/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe.html b/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe.html
index 79101b2ca5b71..fdeda1178bcd3 100644
--- a/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe.html
+++ b/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe.html
@@ -1,48 +1,81 @@
<head>
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Test that wheel events on an unscrollable OOP iframe are handoff-ed</title>
<script src="apz_test_native_event_utils.js"></script>
<script src="apz_test_utils.js"></script>
+ <script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<style>
iframe {
height: 201px;
border: none;
}
</style>
</head>
<body>
<div id="iframe-container" style="overflow-y: scroll; height: 200px;">
<iframe src="https://example.com/tests/gfx/layers/apz/test/mochitest/helper_wheelevents_handoff_on_iframe_child.html"></iframe>
</div>
<div style="height: 200vh;"></div>
<script type="application/javascript">
async function test() {
+ function waitForEvent(target, type) {
+ return new Promise(resolve => {
+ target.addEventListener(type, e => {
+ info(`Received "${e.type}" event for ${e.target}`);
+ resolve();
+ }, { once: true });
+ });
+ }
+
const scrollContainer = document.querySelector("#iframe-container");
- let scrollEventPromise = waitForScrollEvent(scrollContainer);
+
+ // Issue: Without setting the scroll position first, negative scrolling starting
+ // with scrollTop == 0 doesn't emit any events.
+ scrollContainer.scrollTop = 10;
+
+ let scrollEventPromise = waitForEvent(scrollContainer, "scroll");
+ let scrollendEventPromise = waitForEvent(scrollContainer, "scrollend");
+ let wheelEventPromise = waitForEvent(scrollContainer, "wheel");
// Send a wheel event on the iframe.
const iframe = document.querySelector("iframe");
- await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
+
+ const event = {
+ deltaY: -50,
+ asyncEnabled: true,
+ };
+ synthesizeWheel(iframe, 50, 50, event);
+ // await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
+
await scrollEventPromise;
+ await scrollendEventPromise;
+ await wheelEventPromise; // not emitted
// The wheel event should be handoff-ed to the parent scroll container.
is(scrollContainer.scrollTop, scrollContainer.scrollTopMax,
"The scroll position in the parent scroll container should be at the bottom");
// Make sure the wheel event wasn't handoff-ed to the root scroller.
is(window.scrollY, 0, "The root scroll position should be 0");
await promiseFrame();
scrollEventPromise = waitForScrollEvent(window);
+
// Send a wheel event on the iframe again.
- await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
+ synthesizeWheel(iframe, 50, 50, event);
+ // await synthesizeNativeWheel(iframe, 50, 50, 0, -50);
+
+ // None of the following events are emitted because we are already scrolled
+ // to the top.
await scrollEventPromise;
+ await scrollendEventPromise;
+ await wheelEventPromise;
// Now it should be handoff-ed to the root scroller.
ok(window.scrollY > 0,
"The wheel event should have been handoff-ed to the root scroller");
}
waitUntilApzStable()
.then(test)
| Assignee | ||
Comment 3•7 months ago
|
||
Updated•7 months ago
|
Comment 4•7 months ago
•
|
||
There's a confusing difference between synthesizeNativeWheel and synthesizeWheel. The delta direction is opposite direction.
I tried the modified test locally with setting "test.events.async.enabled=true" and with changing the deltaY to 50, the test works.
(In reply to Henrik Skupin [:whimboo][⌚️UTC+2] from comment #2)
With the changes for DOMWindowUtils and EventUtils (as attached as patch) I tried to update the following test as proposed by Hiro to switch from native events to widget events but I can see different issues with missing events:
- Compared to sending a native event the expected events are not always emitted, especially not when we already are at
scrollTop == 0
You don't need this change with the positive deltaY.
| Assignee | ||
Comment 5•7 months ago
|
||
Updated•7 months ago
|
| Assignee | ||
Updated•7 months ago
|
Comment 7•7 months ago
|
||
| bugherder | ||
https://hg.mozilla.org/mozilla-central/rev/4be24e8d9463
https://hg.mozilla.org/mozilla-central/rev/408e73e86a0d
Updated•6 months ago
|
Description
•