From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- testing/web-platform/tests/touch-events/META.yml | 5 + .../expose-legacy-touch-event-apis.html | 15 + .../tests/touch-events/historical.html | 59 ++++ .../tests/touch-events/idlharness.window.js | 19 + .../touch-events/multi-touch-interactions.html | 52 +++ .../tests/touch-events/multi-touch-interactions.js | 392 +++++++++++++++++++++ .../tests/touch-events/multi-touch-interfaces.html | 295 ++++++++++++++++ .../touch-events/single-touch-vertical-rl.html | 53 +++ .../tests/touch-events/single-touch.html | 392 +++++++++++++++++++++ .../tests/touch-events/support/touch.js | 106 ++++++ .../touch-globaleventhandler-interface.html | 40 +++ .../touch-events/touch-retargeting-manual.html | 36 ++ .../touch-events/touch-touchevent-constructor.html | 145 ++++++++ 13 files changed, 1609 insertions(+) create mode 100644 testing/web-platform/tests/touch-events/META.yml create mode 100644 testing/web-platform/tests/touch-events/expose-legacy-touch-event-apis.html create mode 100644 testing/web-platform/tests/touch-events/historical.html create mode 100644 testing/web-platform/tests/touch-events/idlharness.window.js create mode 100644 testing/web-platform/tests/touch-events/multi-touch-interactions.html create mode 100644 testing/web-platform/tests/touch-events/multi-touch-interactions.js create mode 100644 testing/web-platform/tests/touch-events/multi-touch-interfaces.html create mode 100644 testing/web-platform/tests/touch-events/single-touch-vertical-rl.html create mode 100644 testing/web-platform/tests/touch-events/single-touch.html create mode 100644 testing/web-platform/tests/touch-events/support/touch.js create mode 100644 testing/web-platform/tests/touch-events/touch-globaleventhandler-interface.html create mode 100644 testing/web-platform/tests/touch-events/touch-retargeting-manual.html create mode 100644 testing/web-platform/tests/touch-events/touch-touchevent-constructor.html (limited to 'testing/web-platform/tests/touch-events') diff --git a/testing/web-platform/tests/touch-events/META.yml b/testing/web-platform/tests/touch-events/META.yml new file mode 100644 index 0000000000..3dcab9a534 --- /dev/null +++ b/testing/web-platform/tests/touch-events/META.yml @@ -0,0 +1,5 @@ +spec: https://w3c.github.io/touch-events/ +suggested_reviewers: + - jtangelder + - zqzhang + - cynthia diff --git a/testing/web-platform/tests/touch-events/expose-legacy-touch-event-apis.html b/testing/web-platform/tests/touch-events/expose-legacy-touch-event-apis.html new file mode 100644 index 0000000000..2dab74dccd --- /dev/null +++ b/testing/web-platform/tests/touch-events/expose-legacy-touch-event-apis.html @@ -0,0 +1,15 @@ + + +Expose legacy touch event APIs + + + diff --git a/testing/web-platform/tests/touch-events/historical.html b/testing/web-platform/tests/touch-events/historical.html new file mode 100644 index 0000000000..16ddf51903 --- /dev/null +++ b/testing/web-platform/tests/touch-events/historical.html @@ -0,0 +1,59 @@ + + +Historical touch events features + + + + + diff --git a/testing/web-platform/tests/touch-events/idlharness.window.js b/testing/web-platform/tests/touch-events/idlharness.window.js new file mode 100644 index 0000000000..88573286a2 --- /dev/null +++ b/testing/web-platform/tests/touch-events/idlharness.window.js @@ -0,0 +1,19 @@ +// META: script=/resources/WebIDLParser.js +// META: script=/resources/idlharness.js + +// https://w3c.github.io/touch-events/ + +'use strict'; + +idl_test( + ['touch-events'], + ['uievents', 'html', 'dom'], + idl_array => { + idl_array.add_objects({ + Document: ['document'], + GlobalEventHandlers: ['window', 'document', 'document.body'], + Touch: ['new Touch({identifier: 1, target: document})'], + TouchEvent: ['new TouchEvent("name")'], + }); + } +); diff --git a/testing/web-platform/tests/touch-events/multi-touch-interactions.html b/testing/web-platform/tests/touch-events/multi-touch-interactions.html new file mode 100644 index 0000000000..a10416bdfd --- /dev/null +++ b/testing/web-platform/tests/touch-events/multi-touch-interactions.html @@ -0,0 +1,52 @@ + + + + + +Touch Events Multi-Touch Interaction Test + + + + + + + + + + +

Touch Events: Multi-Touch Interaction Test

+
+ Touch this box with one finger, then another one... +
+
+ ...then drag to this box, then touch with a third finger, and lift all your fingers. +
+
+
+ + diff --git a/testing/web-platform/tests/touch-events/multi-touch-interactions.js b/testing/web-platform/tests/touch-events/multi-touch-interactions.js new file mode 100644 index 0000000000..9b883ef7e0 --- /dev/null +++ b/testing/web-platform/tests/touch-events/multi-touch-interactions.js @@ -0,0 +1,392 @@ +setup({explicit_done: true}); + +var debug = document.getElementById("debug"); + +function debug_print (x) { +/* uncomment below statement to show debug messages */ +// document.getElementById("debug").innerHTML += x; +} + +var starting_elements = {}; + +function check_list_subset_of_targetlist(list, list_name, targetlist, targetlist_name) { + var exist_in_targetlist; + for(i=0; i= 1, "changedTouches.length is at least 1"); + assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length"); + check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches"); + }, "touchstart #" + touchstart_received + ": changedTouches is a subset of touches"); + + // TA: 1.3.3.2, 1.3.3.3 + test(function() { + assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1"); + assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length"); + check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches"); + }, "touchstart #" + touchstart_received + ": targetTouches is a subset of touches"); + + // TA: 1.3.3.9 + test(function() { + check_targets(ev.targetTouches, ev.target); + }, "touchstart #" + touchstart_received + ": targets of targetTouches are correct"); + + // TA: 1.3.4.2 + test(function() { + assert_true(ev.touches.length >= 1, "touches.length is at least 1"); + }, "touchstart #" + touchstart_received + ": touches.length is valid"); + + if(touchstart_received == 1) { + // TA: 1.3.3.5, 1.3.3.7 + test(function() { + assert_true(ev.targetTouches.length <= ev.changedTouches.length, "targetTouches.length is smaller than changedTouches.length"); + check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.changedTouches, "changedTouches"); + }, "touchstart #" + touchstart_received + ": targetTouches is a subset of changedTouches"); + + // TA: 1.3.4.3 + test(function() { + assert_equals(ev.touches.length, ev.changedTouches.length, "touches and changedTouches have the same length"); + }, "touchstart #" + touchstart_received + ": touches and changedTouches have the same length"); + } else { + // TA: 1.3.3.6 + test(function() { + var diff_in_targetTouches = ev.targetTouches.length - (last_targetTouches[ev.target.id] ? last_targetTouches[ev.target.id].length : 0); + assert_true(diff_in_targetTouches > 0, "targetTouches.length is larger than last received targetTouches.length"); + assert_true(diff_in_targetTouches <= ev.changedTouches.length, "change in targetTouches.length is smaller than changedTouches.length"); + }, "touchstart #" + touchstart_received + ": change in targetTouches.length is valid"); + + // TA: 1.3.3.8 + test(function() { + assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches"); + }, "touchstart #" + touchstart_received + ": at least one targetTouches item in changedTouches"); + + // TA: 1.3.4.4 + test(function() { + var diff_in_touches = ev.touches.length - last_touches.length; + assert_true(diff_in_touches > 0, "touches.length is larger than last received touches.length"); + assert_equals(diff_in_touches, ev.changedTouches.length, "change in touches.length equals changedTouches.length"); + }, "touchstart #" + touchstart_received + ": change in touches.length is valid"); + + // TA: 1.3.4.5 + test(function() { + check_list_subset_of_two_targetlists(ev.touches, "touches", ev.changedTouches, "changedTouches", last_touches, "last touches"); + }, "touchstart #" + touchstart_received + ": touches is subset of {changedTouches, last received touches}"); + } + + // save starting element of each new touch point + for (i=0; i0, "touchmove follows touchstart"); + // assert_false(touchend_received, "touchmove precedes touchend"); // this applies to scenario tests + }); + test_touchmove.done(); + + touchmove_received++; + + // do the detailed checking only for a few times + if(touchmove_received<6) { + // TA: 1.4.2.2, 1.4.2.4 + test(function() { + assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1"); + assert_true(ev.changedTouches.length <= ev.touches.length, "changedTouches.length is smaller than touches.length"); + check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches"); + }, "touchmove #" + touchmove_received + ": changedTouches is a subset of touches"); + + // TA: 1.4.3.2, 1.4.3.4 + test(function() { + assert_true(ev.targetTouches.length >= 1, "targetTouches.length is at least 1"); + assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length"); + check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches"); + }, "touchmove #" + touchmove_received + ": targetTouches is a subset of touches"); + + // TA: 1.4.3.6 + test(function() { + assert_true(is_at_least_one_item_in_targetlist(ev.targetTouches, ev.changedTouches), "at least one item of targetTouches is in changedTouches"); + }, "touchmove #" + touchmove_received + ": at least one targetTouches item in changedTouches"); + + // TA: 1.4.3.8 + test(function() { + check_targets(ev.targetTouches, ev.target); + }, "touchmove #" + touchmove_received + ": targets of targetTouches are correct"); + + // TA: 1.4.4.2 + test(function() { + assert_equals(ev.touches.length, last_touches.length, "length of touches is same as length of last received touches"); + check_list_subset_of_targetlist(ev.touches, "touches", last_touches, "last received touches"); + }, "touchmove #" + touchmove_received + ": touches must be same as last received touches"); + + // TA: 1.6.3 + check_starting_elements(ev.changedTouches); + } + + last_touches = ev.touches; + last_targetTouches[ev.target.id] = ev.targetTouches; + last_changedTouches = {}; // changedTouches are only saved for touchend events + }); + + on_event(window, "touchend", function onTouchEnd(ev) { + // process event only if it's targeted at target0 or target1 + if(ev.target != target0 && ev.target != target1 ) + return; + + test_touchend.step(function() { + assert_true(touchstart_received>0, "touchend follows touchstart"); + }); + test_touchend.done(); + + touchend_received++; + + debug_print("touchend #" + touchend_received + ":
"); + debug_print("changedTouches.length=" + ev.changedTouches.length + "
"); + debug_print("targetTouches.length=" + ev.targetTouches.length + "
"); + debug_print("touches.length=" + ev.touches.length + "
"); + for(i=0; i"); + + // TA: 1.5.2.2 + test(function() { + assert_true(ev.changedTouches.length >= 1, "changedTouches.length is at least 1"); + }, "touchend #" + touchend_received + ": length of changedTouches is valid"); + + // TA: 1.5.2.3 + test(function() { + check_list_subset_of_targetlist(ev.changedTouches, "changedTouches", last_touches, "last received touches"); + }, "touchend #" + touchend_received + ": changedTouches is a subset of last received touches"); + + // TA: 1.5.2.4, 1.5.2.5 + test(function() { + check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.touches, "touches"); + check_no_item_in_targetlist(ev.changedTouches, "changedTouches", ev.targetTouches, "targetTouches"); + }, "touchend #" + touchend_received + ": no item in changedTouches are in touches or targetTouches"); + + // TA: 1.5.2.6 + test(function() { + var found=false; + for (i=0; i= 0, "targetTouches.length is non-negative"); + assert_true(ev.targetTouches.length <= ev.touches.length, "targetTouches.length is smaller than touches.length"); + check_list_subset_of_targetlist(ev.targetTouches, "targetTouches", ev.touches, "touches"); + }, "touchend #" + touchend_received + ": targetTouches is a subset of touches"); + + // TA: 1.5.3.5 (new) + test(function() { + check_targets(ev.targetTouches, ev.target); + }, "touchend #" + touchend_received + ": targets of targetTouches are correct"); + + // In some cases, when multiple touch points are released simultaneously + // the UA would dispatch the "same" touchend event (same changedTouches, same touches, but possibly different targetTouches) + // to each of the elements that are starting elements of the released touch points. + // in these situations, the subsequent events are exempt from TA 1.5.3.4 and 1.5.4.2 + var same_event_as_last = false; + if (last_changedTouches && last_changedTouches.length==ev.changedTouches.length) { + same_event_as_last = true; // assume true until proven otherwise + for (i=0; i 0, "last received targetTouches.length is not zero"); + var diff_in_targetTouches = last_targetTouches[ev.target.id].length - ev.targetTouches.length; + debug_print("diff_in_targetTouches=" + diff_in_targetTouches + "
"); + assert_true(diff_in_targetTouches > 0, "targetTouches.length is smaller than last received targetTouches.length"); + assert_true(diff_in_targetTouches <= ev.changedTouches.length, "change in targetTouches.length is smaller than changedTouches.length"); + }, "touchend #" + touchend_received + ": change in targetTouches.length is valid"); + + // TA: 1.5.4.2 + // Getting semi-random failures on this and 1.5.3.4. + // It looks like if fingers are lifted simultaneously, the "same" touchend event can be dispatched to two target elements + // but adapted to the element (same touches, changedTouches but different targetTouches). + // When one event is processed after another, ev.touches would end up being identical to last_touches, leading to failure. + // Question is why done() does not stop the processing of the latter event. + test(function() { + assert_true(last_touches.length > 0, "last received touches.length is not zero"); + var diff_in_touches = last_touches.length - ev.touches.length; + debug_print("diff_in_touches=" + diff_in_touches + "
"); + assert_true(diff_in_touches > 0, "touches.length is smaller than last received touches.length"); + assert_equals(diff_in_touches, ev.changedTouches.length, "change in touches.length equals changedTouches.length"); + }, "touchend #" + touchend_received + ": change in touches.length is valid"); + } + + // TA: 1.6.4 + debug_print("touchend #" + touchend_received + ": TA 1.6.4
"); + test(function() { + check_starting_elements(ev.changedTouches); + }, "touchend #" + touchend_received + ": event dispatched to correct element
"); + + debug_print("touchend #" + touchend_received + ": saving touch lists
"); + + last_touches = ev.touches; + last_targetTouches[ev.target.id] = ev.targetTouches; + last_changedTouches = ev.changedTouches; + + debug_print("touchend #" + touchend_received + ": done
"); + if(ev.touches.length==0) + actions_promise.then( () => done() ); + }); + + on_event(target0, "mousedown", function onMouseDown(ev) { + test_mousedown.step(function() { + assert_true(touchstart_received, + "The touchstart event must be dispatched before any mouse " + + "events. (If this fails, it might mean that the user agent does " + + "not implement W3C touch events at all.)" + ); + }); + test_mousedown.done(); + + if (!touchstart_received) { + // Abort the tests. If touch events are not supported, then most of + // the other event handlers will never be called, and the test will + // time out with misleading results. + done(); + } + }); + + actions_promise = new test_driver.Actions() + .addPointer("touchPointer1", "touch") + .addPointer("touchPointer2", "touch") + .addPointer("touchPointer3", "touch") + .pointerMove(0, 0, {origin: target0, sourceName: "touchPointer1"}) + .pointerMove(3, 0, {origin: target0, sourceName: "touchPointer2"}) + .pointerDown({sourceName: "touchPointer1"}) + .pointerDown({sourceName: "touchPointer2"}) + .pointerMove(0, 10, {origin: target0, sourceName: "touchPointer1"}) + .pointerMove(3, 10, {origin: target0, sourceName: "touchPointer2"}) + .pointerMove(0, 0, {origin: target1, sourceName: "touchPointer1"}) + .pointerMove(3, 0, {origin: target1, sourceName: "touchPointer2"}) + .pointerMove(6, 0, {origin: target0, sourceName: "touchPointer3"}) + .pointerDown({sourceName: "touchPointer3"}) + .pointerUp({sourceName: "touchPointer1"}) + .pointerUp({sourceName: "touchPointer2"}) + .pointerUp({sourceName: "touchPointer3"}) + .send(); +} diff --git a/testing/web-platform/tests/touch-events/multi-touch-interfaces.html b/testing/web-platform/tests/touch-events/multi-touch-interfaces.html new file mode 100644 index 0000000000..8b5965c2c9 --- /dev/null +++ b/testing/web-platform/tests/touch-events/multi-touch-interfaces.html @@ -0,0 +1,295 @@ + + + + + +Touch Events Multi-Touch Interface Tests + + + + + + + + + + +

Touch Events: multi-touch interface tests

+
+ Touch this box with one finger, then another one... +
+
+ ...then drag to this box and lift your fingers. +
+
+ + diff --git a/testing/web-platform/tests/touch-events/single-touch-vertical-rl.html b/testing/web-platform/tests/touch-events/single-touch-vertical-rl.html new file mode 100644 index 0000000000..857007b1f8 --- /dev/null +++ b/testing/web-platform/tests/touch-events/single-touch-vertical-rl.html @@ -0,0 +1,53 @@ + + + + Touch events with vertical-rl writing mode + + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/testing/web-platform/tests/touch-events/single-touch.html b/testing/web-platform/tests/touch-events/single-touch.html new file mode 100644 index 0000000000..4db96c208d --- /dev/null +++ b/testing/web-platform/tests/touch-events/single-touch.html @@ -0,0 +1,392 @@ + + + + + + Touch Events Single Touch Tests + + + + + + + + + + + +

Touch Events: single-touch tests

+
+ Touch this box with one finger (or other pointing device)... +
+
+ ...then drag to this box and lift your finger. +
+
+ + \ No newline at end of file diff --git a/testing/web-platform/tests/touch-events/support/touch.js b/testing/web-platform/tests/touch-events/support/touch.js new file mode 100644 index 0000000000..f4bc0467db --- /dev/null +++ b/testing/web-platform/tests/touch-events/support/touch.js @@ -0,0 +1,106 @@ +// Check a Touch object's attributes for existence and correct type +// TA: 1.1.2, 1.1.3 +function check_Touch_object(t) { + assert_equals(Object.prototype.toString.call(t), "[object Touch]", "touch is of type Touch"); + [ + ["long", "identifier"], + ["EventTarget", "target"], + ["long", "screenX"], + ["long", "screenY"], + ["long", "clientX"], + ["long", "clientY"], + ["long", "pageX"], + ["long", "pageY"], + ["long", "radiusX"], + ["long", "radiusY"], + ["long", "rotationAngle"], + ["long", "force"], + ].forEach(function(attr) { + var type = attr[0]; + var name = attr[1]; + + // existence check + assert_true(name in t, name + " attribute in Touch object"); + + // type check + switch (type) { + case "long": + assert_equals(typeof t[name], "number", name + " attribute of type long"); + break; + case "EventTarget": + // An event target is some type of Element + assert_true(t[name] instanceof Element, "EventTarget must be an Element."); + break; + default: + break; + } + }); +} + +// Check a TouchList object's attributes and methods for existence and proper type +// Also make sure all of the members of the list are Touch objects +// TA: 1.2.1, 1.2.2, 1.2.5, 1.2.6 +function check_TouchList_object(tl) { + assert_equals(Object.prototype.toString.call(tl), "[object TouchList]", "touch list is of type TouchList"); + [ + ["unsigned long", "length"], + ["function", "item"], + ].forEach(function(attr) { + var type = attr[0]; + var name = attr[1]; + + // existence check + assert_true(name in tl, name + " attribute in TouchList"); + + // type check + switch (type) { + case "unsigned long": + assert_equals(typeof tl[name], "number", name + " attribute of type long"); + break; + case "function": + assert_equals(typeof tl[name], "function", name + " attribute of type function"); + break; + default: + break; + } + }); + // Each member of tl should be a proper Touch object + for (var i = 0; i < tl.length; i++) { + check_Touch_object(tl.item(i)); + } + // TouchList.item(x) should return null if x is >= TouchList.length + var t = tl.item(tl.length); + assert_equals(t, null, "TouchList.item returns null if the index is >= the length of the list"); +} + +// Check a TouchEvent event's attributes for existence and proper type +// Also check that each of the event's TouchList objects are valid +// TA: 1.{3,4,5}.1.1, 1.{3,4,5}.1.2 +function check_TouchEvent(ev) { + assert_true(ev instanceof TouchEvent, ev.type + " event is a TouchEvent event"); + [ + ["TouchList", "touches"], + ["TouchList", "targetTouches"], + ["TouchList", "changedTouches"], + ["boolean", "altKey"], + ["boolean", "metaKey"], + ["boolean", "ctrlKey"], + ["boolean", "shiftKey"], + ].forEach(function(attr) { + var type = attr[0]; + var name = attr[1]; + // existence check + assert_true(name in ev, name + " attribute in " + ev.type + " event"); + // type check + switch (type) { + case "boolean": + assert_equals(typeof ev[name], "boolean", name + " attribute of type boolean"); + break; + case "TouchList": + assert_equals(Object.prototype.toString.call(ev[name]), "[object TouchList]", name + " attribute of type TouchList"); + break; + default: + break; + } + }); +} diff --git a/testing/web-platform/tests/touch-events/touch-globaleventhandler-interface.html b/testing/web-platform/tests/touch-events/touch-globaleventhandler-interface.html new file mode 100644 index 0000000000..1513cdaa21 --- /dev/null +++ b/testing/web-platform/tests/touch-events/touch-globaleventhandler-interface.html @@ -0,0 +1,40 @@ + +GlobalEventHandlers Touch Interface Tests + + + diff --git a/testing/web-platform/tests/touch-events/touch-retargeting-manual.html b/testing/web-platform/tests/touch-events/touch-retargeting-manual.html new file mode 100644 index 0000000000..a90bb48d64 --- /dev/null +++ b/testing/web-platform/tests/touch-events/touch-retargeting-manual.html @@ -0,0 +1,36 @@ + + + + TouchEvent Retargeting Tests + + + + +

Touch retargeting manual test

+
This test requires touch input.
+
+ + + diff --git a/testing/web-platform/tests/touch-events/touch-touchevent-constructor.html b/testing/web-platform/tests/touch-events/touch-touchevent-constructor.html new file mode 100644 index 0000000000..e2d0950d5e --- /dev/null +++ b/testing/web-platform/tests/touch-events/touch-touchevent-constructor.html @@ -0,0 +1,145 @@ + + + +Touch and TouchEvent Constructor Tests + + + + + +
+ + + -- cgit v1.2.3