Cancelable is not set to false for passive event listener
Categories
(Core :: DOM: UI Events & Focus Handling, defect, P3)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox140 | --- | fixed |
People
(Reporter: BenWa, Assigned: vhilla)
References
Details
Attachments
(2 files)
| Reporter | ||
Comment 1•8 years ago
|
||
Comment 2•8 years ago
|
||
Comment 3•8 years ago
|
||
Updated•8 years ago
|
| Reporter | ||
Comment 4•8 years ago
|
||
Comment 5•8 years ago
|
||
Comment 6•8 years ago
|
||
| Reporter | ||
Comment 7•8 years ago
|
||
Comment 8•8 years ago
|
||
Comment 9•8 years ago
|
||
Updated•6 years ago
|
Updated•3 years ago
|
| Assignee | ||
Comment 10•1 year ago
|
||
There are wpts in /dom/events/non-cancelable-when-passive/*, see Bug 1778162
In addition to what is stated more generally in the dom spec, also see cancelability in the touch events spec.
| Assignee | ||
Comment 11•1 year ago
|
||
I updated the patch and from :rhunt and limited it to touch and wheel events. Otherwise, some mochitests fail and I worry about web compatibility:
const et = new EventTarget();
et.addEventListener('test', (e) => console.log(e.cancelable), {passive: true});
et.dispatchEvent(new Event('test', {cancelable: true}));
this will log true in Blink and current Gecko.
As today is my last day at Mozilla, I won't be able to finish this. I'll attach the patch here and hope it is useful for someone in the future. Some things that could be considered:
- Maybe replace the
PreventDefaultFromPassiveListenerWarninghere with an error that is always printed, as in Chrome - Possibly include more than touch and wheel events in the patch
- Convert above code into a wpt to ensure other events are not marked uncancelable
- Think about performance and code maintainability aspects
| Assignee | ||
Comment 12•1 year ago
|
||
According to the spec https://w3c.github.io/touch-events/#cancelability,
the touchstart, touchend and touchmove events should be uncancelable if
ther eare no non-passive listeners.
Updated•10 months ago
|
Updated•10 months ago
|
Updated•10 months ago
|
| Assignee | ||
Comment 13•10 months ago
|
||
test_continuous_wheel_events.html is failing. It seems, sendWheelAndPaint dispatches the wheel event first to the parent process before it is dispatched in the content. As there are no non-passive listeners in the parent, the event will incorrectly be set to uncancelable.
Comment 14•10 months ago
|
||
Perhaps all the events targeted to not-in-same-docshell-tree targets should avoid this new behavior.
Since I assume the same issue might apply to other events too.
| Assignee | ||
Comment 15•10 months ago
|
||
I'm unsure, does it suffice to check BrowserParent::GetFrom(aEvent->mTarget) as done here? That would resolve the test failures.
EventStateManager::HandleCrossProcessEvent makes it seem to me it's not enough to only consider aEvent->mTarget. And I don't have a good understanding of when events are propagated to other docshells.
Is the opposite situation to test_continuous_wheel_events.html possible, i.e. an event originates in the docshell containing the target, is set uncancelable there, propagates to a remote docshell, and encounters a non-passive listener?
Comment 16•10 months ago
|
||
I guess it should be enough to check BrowserParent::GetFrom(aEvent->mOriginalTarget), since in case the docshells are in the same process, all the relevant EventTargets are in the event path and the code in the patch should notice if there are non-passive listeners.
BrowserParent::GetFrom() is a tiny bit slow, so perhaps call that only in the parent process? (It returns always false in content processes)
Updated•10 months ago
|
Updated•10 months ago
|
Comment 17•9 months ago
|
||
Comment 19•9 months ago
|
||
| bugherder | ||
Updated•8 months ago
|
Description
•