Skip to content
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

Merged
merged 4 commits into from Feb 3, 2017
Merged

Add movementxy attribute test for pointerevents #4571

merged 4 commits into from Feb 3, 2017

Conversation

NavidZ
Copy link
Member

@NavidZ NavidZ commented Jan 19, 2017

@RByers
Copy link
Contributor

RByers commented Jan 20, 2017

w3c-test:mirror (want to try the test out on w3c-test.org)
One initial nit: rather than a generic "interaction-with-other-specs" directory can you just use the name of the spec - "pointerlock"? That's the pattern we've already started with the "compat" sub-directory.

@RByers
Copy link
Contributor

RByers commented Jan 20, 2017

Test is now served here. I can't get it to complete on current Chrome dev channel -
the mouse one completes, but clicking 'skip' or using touch I still get "1 remain".

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).

@NavidZ
Copy link
Member Author

NavidZ commented Jan 20, 2017

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.

@RByers
Copy link
Contributor

RByers commented Jan 25, 2017

We don't have any further sub-directory under compat though

Right, compat is the name of the spec (compat.spec.whatwg.org). I only expect the single test there for the forseable future. We should have the spec name in the path somewhere, but as long as we're consistent with the pattern I don't really care. Eg: we could have:

compat/pointerevent_touch-action_two-finger_interaction-manual.html
pointerlock/pointerevent_movementxy-manual.html

or

interaction-with-other-specs/compat-pointerevent_touch-action_two-finger_interaction-manual.html
interaction-with-other-specs/pointerlock-pointerevent_movementxy-manual.html

I have a slight preference for the former, but as long as we're not mixing different patterns I don't really care.

@RByers
Copy link
Contributor

RByers commented Jan 25, 2017

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.

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.

@RByers
Copy link
Contributor

RByers commented Jan 25, 2017

w3c-test:mirror

});
['pointerenter', 'pointerleave'].forEach(function(eventName) {
on_event(document.getElementById('innerFrame').contentDocument, eventName, function (event) {
isFirstMove = true;
Copy link
Contributor

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.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

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.

Copy link
Contributor

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 ;-)

@NavidZ
Copy link
Member Author

NavidZ commented Jan 26, 2017

Now it looks a lot better using screenX/Y. I was able to get rid of all that isFirstMove/enter/leave logic. Thanks. ptal.

@RByers
Copy link
Contributor

RByers commented Jan 26, 2017

w3c-test:mirror

@RByers
Copy link
Contributor

RByers commented Jan 26, 2017

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?

@NavidZ
Copy link
Member Author

NavidZ commented Jan 26, 2017

w3c-test:mirror

@NavidZ
Copy link
Member Author

NavidZ commented Jan 26, 2017

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.

@Ms2ger
Copy link
Contributor

Ms2ger commented Jan 31, 2017

@RByers is this good to go now?

@RByers
Copy link
Contributor

RByers commented Feb 3, 2017

w3c-test:mirror

@RByers
Copy link
Contributor

RByers commented Feb 3, 2017

LGTM, thanks!

@RByers RByers merged commit b6125d6 into web-platform-tests:master Feb 3, 2017
@RByers RByers mentioned this pull request Feb 8, 2017
@smaug----
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect movementX/Y in PointerEvents
7 participants