-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DOM: Test {mouse,}wheel and touch{move,start} events are non-cancelable when there are no non-passive event listeners #34464
Conversation
The tests pass in Chrome, but fail in Firefox and Safari because: For wheel/mousewheel Firefox: Safari:
For touchmove/touchstart: Firefox: Safari: Both Firefox and Safari on wpt CI are with touch support disabled, so maybe not testable until we test with builds/devices where touch support is enabled. |
|
I used separate demos for mousewheel and wheel because at least in Chrome, when there were |
6b0d8f0
to
69b2f91
Compare
I tried testing multiple events, but could not reproduce passive after non-passive with testdriver.js. If the concept of default passive event listeners is unrelated to whether a previous event was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I left an inline comment about passive vs. non-cancelable, but I'm wondering if there's a bigger problem there... or maybe I'm just not understanding.
Basically, is there any evidence that passive-ness is involved here at all? It seems like everything could be explained by browsers just firing non-cancelable
events. Whereas the point of passive
is to allow certain listeners to have no-op preventDefault()
, even if the event can be preventDefault()
ed by other listeners and thus has cancelable = true
.
EDIT: maybe the evidence is that if you set passive: false
explicitly, that overrides the default behavior? But in that case cancelable
should be true, whereas these tests expect false for non-divs...
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-touching.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
dom/events/passive-default/resources/default-passive-scrolling.js
Outdated
Show resolved
Hide resolved
This tests that the events are non-cancellable as allowed in https://w3c.github.io/touch-events/#cancelability and ... not yet in https://w3c.github.io/uievents/#cancelability-of-wheel-events . The issue is w3c/uievents#282 -- I can submit a PR to fix the spec.
I'm not sure why this is only a "may", and not a "must" or at least "should". I'll file an issue. Edit: w3c/touch-events#130 |
Hmm, so that is very weird. So basically, if you do I would have expected |
I guess the browser would be lying if it fired events with |
@domenic I've opened a new PR with the strategy discussed in #34464 (comment) which doesn't rely on the related but separate intervention to fire cancelable events when there are no non-passive listeners: |
@domenic OK I've changed this PR to isolate testing of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally looks good. However, I do think we should expand the test coverage in two ways:
-
We should also test
touchend
, and show that this does not apply totouchend
. Right now it seems an implementation could pass by just applying this to every event. -
We should test synthetic events (with
dispatchEvent()
). Ideally test both the proper event type (e.g.TouchEvent
) and a non-correct event type (e.g.Event
). I don't actually know what the behavior will be for these...
There are other cases that might be worth testing, such as:
-
passive: undefined
. Right now we are assuming that the behavior of DOM: Test that some event listeners are passive by default #34623 meanspassive: undefined
is the same aspassive: true
for some events, but it feels like this area is messy enough that assuming everything is compositional and can be tested independently is not entirely justified. -
one
passive: true
listener and onepassive: false
listener. (Should behave the same as onepassive: false
listener, IIUC.)
However I don't think these latter are worth testing if they cause a bunch of new files to get generated and need maintenance. If you can merge some files, e.g. test all of passive: true
, passive: false
, and passive: undefined
in a single file, or test all of the events in a single file, or both, then expanding the test matrix might be reasonable. But maybe that is a bad idea for some reason, I am not sure.
dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-body.html
Outdated
Show resolved
Hide resolved
dom/events/non-cancelable-when-passive/non-passive-mousewheel-event-listener-on-body.html
Outdated
Show resolved
Hide resolved
This intervention might apply to |
I don't think there's anything special going on for synthetic events, but we can test it to verify that that is indeed the case. |
I think I've addressed your comments @domenic.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with test name/title nit. However upon reviewing the synthetic-events-cancelable test I realized it was kind of silly. Since you are on the one dispatching the event then it makes sense it will just follow the normal default. And since the normal default is cancelable = false then of course there's no chance for the intervention to apply.
So, feel free to delete that extra test if you want, now that I realize it was not really a tricky case after all.
dom/events/non-cancelable-when-passive/synthetic-events-cancelable.html
Outdated
Show resolved
Hide resolved
4183e08
to
d891764
Compare
Suggested commit message
|
CI failed to install Safari TP:
I tried rebasing but it didn't help. cc @web-platform-tests/admins |
3fc0804 should fix that (but, also, like, file new issues for things that are broken like this; that's more discoverable for others and there's no direct need for admin intervention here). |
…listeners instead
d891764
to
a252b67
Compare
Thanks @gsnedders! |
Test that events are not cancelable when there are no non-passive event listeners, and cancelable when there are non-passive event listeners.
Follows https://w3c.github.io/touch-events/#cancelability
...and the same for
wheel
events andmousewheel
events, but that is not yet defined in https://w3c.github.io/uievents/#cancelability-of-wheel-events . The relevant issue is w3c/uievents#282