Re: [pointerevents-tests] PointerEvents: update touch-action tests to be more reliable (#1299)

In tests where the expected result is "no panning", there can easily be false-positive results. One can simply load the page, click the complete button immediately and pass the test, without doing anything to the target element, and regardless of pointer type. 

To prevent such false-positives:
1. Add a pointerdown listener to record the pointer type used:
                on_event(target0, 'pointerdown', function(event) {
                        detected_pointertypes[event.pointerType] = true;
                });
2. At the click event of btnComplete, remove the recording of pointer type (which is already done in the pointerdown listener), and assert that the touch pointer type was used:
                on_event(btnComplete, 'click', function(event) {
&nbsp;&nbsp;&nbsp;&nbsp;                    <strike>detected_pointertypes[event.pointerType] = true;</strike>
&nbsp;&nbsp;&nbsp;&nbsp;                    test_touchaction.step(function() {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b>                        assert_true(detected_pointertypes['touch'], "touch input should be used");</b>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;                        assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
&nbsp;&nbsp;&nbsp;&nbsp;                    });
...

View on GitHub: https://github.com/w3c/web-platform-tests/pull/1299#issuecomment-60308351

Received on Thursday, 23 October 2014 21:00:05 UTC