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
Add movementxy attribute test for pointerevents #4571
Add movementxy attribute test for pointerevents #4571
Conversation
w3c-test:mirror (want to try the test out on w3c-test.org) |
Test is now served here. I can't get it to complete on current Chrome dev channel - I was initially confused about the iframe and requirement that movement is kept to <10 pixels per event. This is because the events that land over the frame are lost, right? This is a same-origin iframe so it should be easy to also have listeners inside the frame which just call into some common code in the top document so that you can test both the events delivered to the top document and those delivered inside the frame. Big picture, what I was wondering was - is it better to rely on relatively precise positioning like this (move from red to black), and/or should our test just verify that the movement sum exactly equals the change in client (or maybe screen) co-ordinates the way the pointerlock tests do? /cc @scheib who may have input. From a quick glance I didn't see any movementX/Y tests there which look explicitly at the iframe case (but maybe it was only our originally flawed PointerEvents implementation that would even suggest that such a test was worthwhile). |
We don't have any further sub-directory under compat though. I thought I just put all the related interaction with other spec tests under here like Shadow dom that will come later. If I were to create a folder for each some of those folders will have only one test. Having said that which one do you think is better? Create a separate subfolder under pointerevents for each other spec we would like to add test? I do have a handler for the inner iframe as well and I also check the events from that (i.e. innerSumX vs sumX). The reason that I wanted the movements to be small is to avoid the jump when you cross the boundary of an iframe discussed in this issue on PointerLock. So I can actually sum things up inside the frame and outside the frame and be able to rely on the range of the result. |
Right,
or
I have a slight preference for the former, but as long as we're not mixing different patterns I don't really care. |
I see, thanks. See my comment here. I don't think it makes sense to try to test the movementX/Y for the first event inside an iframe without communicating with the outer frame in order to measure the real delta. |
w3c-test:mirror |
}); | ||
['pointerenter', 'pointerleave'].forEach(function(eventName) { | ||
on_event(document.getElementById('innerFrame').contentDocument, eventName, function (event) { | ||
isFirstMove = true; |
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.
I see, so this means we're not testing the movementX/movementY values for the event that enters/leaves the iframe. That's OK but not ideal (misses some interesting test coverage).
The simplest way to get this additional test coverage is to use screenX/Y
instead of clientX/Y
(and remove all the isFirstMove
logic). That would also better match the spec, since movementX/Y
is defined in terms of screen co-ordinates. Eg. if the browser content area happened to move relative to the physical screen during the test (such as when top controls show or hide in mobile browsers) then the test should still pass when using screen
co-ordinates but should fail when using client
(assuming we've implemented according to the spec).
If there's some reason why using client co-ordinates is preferable (eg. perhaps @schieb has a reason why the existing pointerlock tests do that), you could still get this additional test coverage as follows:
- specify the iframe border size explicitly (with either the 'border=' HTML attribute or a CSS border rule on the iframe element) rather than relying on the browser default (not sure that's standardized).
- on test start, compute the offset of the iframe within the parent frame by using getBoundingClientRect on innerFrame plus the border size you specified
- in your pointermove handler, if the event target is inside the iframe, add the above offset to the client co-ordinates
In that way you'd be doing all your math in the "root frame" coordinate space (instead of in the client / local-frame co-ordinate space). And then the math should work out in all cases.
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.
@scheib ^
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.
screenX/Y are good, the use of clientX/Y in other tests was an oversight. I've filed an issue to fix the pointerlock tests #4630.
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.
Perfect, thanks! Sorry for the mis-spell ;-)
Now it looks a lot better using screenX/Y. I was able to get rid of all that isFirstMove/enter/leave logic. Thanks. ptal. |
w3c-test:mirror |
Yeah it looks great - thanks! Just wanted to try it out again myself. On Chrome 55 desktop (the only laptop I have handy in the meeting I'm sitting in) the mouse case fails the ASSERT. Is there a known bug for mouse in Chrome 55? I thought the only known bug was with touch? I also tried Chrome 57 android but it seems the test won't work on a phone - it doesn't fit and you apparently can't scroll the page. It's probably not worth a big effort now (eg. could be a mobile-friendly-cleanup we do later), but do you think it's worth seeing if you can tweak the layout / touch-action a bit to make this test passable on a phone? |
w3c-test:mirror |
Layout is fixed now. Chrome 55 does have the bug. That is the intention of this test. Hopefully it will be fixed in the latest version. |
@RByers is this good to go now? |
w3c-test:mirror |
LGTM, thanks! |
So this was wrong. PointerLock spec explicitly states that "movementX/Y must be zero for all mouse events except mousemove." We need a spec change, as far as I see. |
@mustaqahmed @dtapuska
closes w3c/pointerevents#131