Skip to content

Commit

Permalink
Re-sync pointerevents WPT
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=261939
rdar://115882438

Reviewed by Aditya Keerthi.

This patch imports web-platform-tests/pointerevents from upstream
(revision ba70881d5cc75412640c5b96f50d3c65a00ec4b8).

Notably, the pointerevents/pointerevent_after_target_removed.html layout
test has been revamped.
(reference: web-platform-tests/interop#380)

We would like to see this change (and others) reflected in our WPT import
for ease of local development.

* LayoutTests/imported/w3c/web-platform-tests/pointerevents/coalesced_events_attributes_under_load.html:
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_appended.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_appended_mouse-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_appended_pen-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_appended_touch-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_removed.html:
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_removed_mouse-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerevent_after_target_removed_pen-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_pointerlock_after_pointercapture_original-expected.txt: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/pointerlock/pointerevent_pointerlock_after_pointercapture_original.html: Added.
* LayoutTests/imported/w3c/web-platform-tests/pointerevents/w3c-import.log:
* LayoutTests/platform/mac/TestExpectations:

Canonical link: https://commits.webkit.org/268347@main
  • Loading branch information
aprotyas committed Sep 23, 2023
1 parent 0a038d9 commit 42d1126
Show file tree
Hide file tree
Showing 15 changed files with 442 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@
// Every pointerdown blocks the main thread for a certain time limit,
// and then increases the time limit for next round in case the
// current limit fails to cause event coalescing.
let now = performance.now();
while (performance.now() < now + current_busyloop_ms)
let start = performance.now();
while (performance.now() < start + current_busyloop_ms)
continue;
current_busyloop_ms *= 2;
});
Expand All @@ -85,7 +85,7 @@
actions = actions.pointerUp();

await actions.send();
await await pointerup_promise;
await pointerup_promise;
}

assert_true(coalesced_event_received, "Coalesed pointermoves received");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
<!DOCTYPE HTML>
<title>Enter/leave events fired to parent after child is added</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?touch">
<meta name="variant" content="?pen">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="pointerevent_support.js"></script>

<style>
div.target {
width: 100px;
height: 100px;
}
</style>
<div class="target" id="parent">
<div class="target" id="child">child</div>
</div>
<div id="done">done</div>

<script>
'use strict';
const pointer_type = location.search.substring(1);

const parent = document.getElementById("parent");
const child = document.getElementById("child");
const done = document.getElementById("done");

let event_log = [];
let logged_event_prefix = "";
let received_compat_mouse_events = false;

function logEvent(e) {
if (e.type.startsWith(logged_event_prefix) && e.eventPhase == e.AT_TARGET) {
event_log.push(e.type + "@" + e.target.id);
}
if (e.type.startsWith("mouse")) {
received_compat_mouse_events = true;
}
}

function attachChild(e) {
if (e.eventPhase == e.AT_TARGET) {
parent.appendChild(child);
event_log.push("(child-attached)");
}
}

let child_moved = false;

function moveChild(e) {
if (!child_moved) {
child_moved = true;
parent.appendChild(child);
event_log.push("(child-moved)");
}
}

function setup() {
const logged_event_suffixes =
["over", "out", "enter", "leave", "down", "up"];
let targets = document.getElementsByClassName("target");
for (let i = 0; i < targets.length; i++) {
logged_event_suffixes.forEach(suffix => {
targets[i].addEventListener("pointer" + suffix, logEvent);
targets[i].addEventListener("mouse" + suffix, logEvent);
});
}
}

function addPromiseTestForNewChild(attaching_event,
tested_event_prefix, expected_events) {
const test_name = `${tested_event_prefix} events from ${pointer_type} `+
`received before/after child attached at ${attaching_event}`;

promise_test(async test => {
event_log = [];
logged_event_prefix = tested_event_prefix;

// We started with child attached to ease event listener setup above.
parent.removeChild(child);

parent.addEventListener(attaching_event, attachChild);
test.add_cleanup(() => {
parent.removeEventListener(attaching_event, attachChild);
});

let done_click_promise = getEvent("click", done);

let actions = new test_driver.Actions()
.addPointer("TestPointer", pointer_type)
.pointerMove(-30, -30, {origin: parent})
.pointerDown()
.pointerUp()
.pointerMove(30, 30, {origin: parent})
.pointerDown()
.pointerUp()
.pointerMove(0, 0, {origin: done})
.pointerDown()
.pointerUp();

await actions.send();
await done_click_promise;

if (tested_event_prefix == "mouse" && !received_compat_mouse_events) {
expected_events = [];
}

assert_equals(event_log.toString(), expected_events.toString(),
"events received");
}, test_name);
}

function addPromiseTestForMovedChild(mover_event,
tested_event_prefix, expected_events) {
const test_name = `${tested_event_prefix} events from ${pointer_type} `+
`received before/after child moved at ${mover_event}`;

promise_test(async test => {
event_log = [];
logged_event_prefix = tested_event_prefix;
child_moved = false;

child.addEventListener(mover_event, moveChild);
test.add_cleanup(() => {
child.removeEventListener(mover_event, moveChild);
});

let done_click_promise = getEvent("click", done);

let actions = new test_driver.Actions()
.addPointer("TestPointer", pointer_type)
.pointerMove(-30, -30, {origin: parent})
.pointerDown()
.pointerUp()
.pointerMove(30, 30, {origin: parent})
.pointerDown()
.pointerUp()
.pointerMove(0, 0, {origin: done})
.pointerDown()
.pointerUp();

await actions.send();
await done_click_promise;

if (tested_event_prefix == "mouse" && !received_compat_mouse_events) {
expected_events = [];
}

assert_equals(event_log.toString(), expected_events.toString(),
"events received");
}, test_name);
}

setup();

// Tests for dispatched pointer events.
addPromiseTestForNewChild("pointerdown", "pointer", [
"pointerover@parent", "pointerenter@parent",
"pointerdown@parent", "(child-attached)",
"pointerover@child", "pointerenter@child",
"pointerup@child",
"pointerdown@child", "pointerup@child",
"pointerout@child", "pointerleave@child", "pointerleave@parent"
]);
addPromiseTestForNewChild("pointerup", "pointer", [
"pointerover@parent", "pointerenter@parent",
"pointerdown@parent", "pointerup@parent", "(child-attached)",
"pointerover@child", "pointerenter@child",
"pointerdown@child", "pointerup@child",
"pointerout@child", "pointerleave@child", "pointerleave@parent"
]);
addPromiseTestForMovedChild("pointerdown", "pointer", [
"pointerover@child", "pointerenter@parent", "pointerenter@child",
"pointerdown@child", "(child-moved)",
"pointerover@child", "pointerenter@child",
"pointerup@child",
"pointerdown@child", "pointerup@child",
"pointerout@child", "pointerleave@child", "pointerleave@parent"
]);
addPromiseTestForMovedChild("pointerup", "pointer", [
"pointerover@child", "pointerenter@parent", "pointerenter@child",
"pointerdown@child", "pointerup@child", "(child-moved)",
"pointerover@child", "pointerenter@child",
"pointerdown@child", "pointerup@child",
"pointerout@child", "pointerleave@child", "pointerleave@parent"
]);

// Same tests for dispatched compatibility mouse events.
addPromiseTestForNewChild("pointerdown", "mouse", [
"mouseover@parent", "mouseenter@parent",
"mousedown@parent", "(child-attached)",
"mouseover@child", "mouseenter@child",
"mouseup@child",
"mousedown@child", "mouseup@child",
"mouseout@child", "mouseleave@child", "mouseleave@parent"
]);
addPromiseTestForNewChild("pointerup", "mouse", [
"mouseover@parent", "mouseenter@parent",
"mousedown@parent", "mouseup@parent", "(child-attached)",
"mouseover@child", "mouseenter@child",
"mousedown@child", "mouseup@child",
"mouseout@child", "mouseleave@child", "mouseleave@parent"
]);

addPromiseTestForMovedChild("pointerdown", "mouse", [
"mouseover@child", "mouseenter@parent", "mouseenter@child",
"mousedown@child", "(child-moved)",
"mouseover@child", "mouseenter@child",
"mouseup@child",
"mousedown@child", "mouseup@child",
"mouseout@child", "mouseleave@child", "mouseleave@parent"
]);
addPromiseTestForMovedChild("pointerup", "mouse", [
"mouseover@child", "mouseenter@parent", "mouseenter@child",
"mousedown@child", "mouseup@child", "(child-moved)",
"mouseover@child", "mouseenter@child",
"mousedown@child", "mouseup@child",
"mouseout@child", "mouseleave@child", "mouseleave@parent"
]);
</script>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
child
done

FAIL pointer events from mouse received before/after child attached at pointerdown assert_equals: events received expected "pointerover@parent,pointerenter@parent,pointerdown@parent,(child-attached),pointerover@child,pointerenter@child,pointerup@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@parent,pointerenter@parent,pointerdown@parent,(child-attached),pointerup@child,pointerout@parent,pointerleave@parent"
FAIL pointer events from mouse received before/after child attached at pointerup assert_equals: events received expected "pointerover@parent,pointerenter@parent,pointerdown@parent,pointerup@parent,(child-attached),pointerover@child,pointerenter@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@parent,pointerenter@parent,pointerdown@parent,pointerup@parent,(child-attached),pointerout@parent,pointerleave@parent"
FAIL pointer events from mouse received before/after child moved at pointerdown assert_equals: events received expected "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,(child-moved),pointerover@child,pointerenter@child,pointerup@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,(child-moved),pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent"
FAIL pointer events from mouse received before/after child moved at pointerup assert_equals: events received expected "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,pointerup@child,(child-moved),pointerover@child,pointerenter@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,pointerup@child,(child-moved),pointerout@child,pointerleave@child,pointerleave@parent"
FAIL mouse events from mouse received before/after child attached at pointerdown assert_equals: events received expected "mouseover@parent,mouseenter@parent,mousedown@parent,(child-attached),mouseover@child,mouseenter@child,mouseup@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@parent,mouseenter@parent,(child-attached),mousedown@parent,mouseup@child,mouseout@parent,mouseleave@parent"
FAIL mouse events from mouse received before/after child attached at pointerup assert_equals: events received expected "mouseover@parent,mouseenter@parent,mousedown@parent,mouseup@parent,(child-attached),mouseover@child,mouseenter@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@parent,mouseenter@parent,mousedown@parent,(child-attached),mouseup@parent,mouseout@parent,mouseleave@parent"
FAIL mouse events from mouse received before/after child moved at pointerdown assert_equals: events received expected "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,(child-moved),mouseover@child,mouseenter@child,mouseup@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@child,mouseenter@parent,mouseenter@child,(child-moved),mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent"
FAIL mouse events from mouse received before/after child moved at pointerup assert_equals: events received expected "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,mouseup@child,(child-moved),mouseover@child,mouseenter@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,(child-moved),mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent"

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
child
done

FAIL pointer events from pen received before/after child attached at pointerdown assert_equals: events received expected "pointerover@parent,pointerenter@parent,pointerdown@parent,(child-attached),pointerover@child,pointerenter@child,pointerup@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@parent,pointerenter@parent,pointerdown@parent,(child-attached),pointerup@child,pointerout@parent,pointerleave@parent"
FAIL pointer events from pen received before/after child attached at pointerup assert_equals: events received expected "pointerover@parent,pointerenter@parent,pointerdown@parent,pointerup@parent,(child-attached),pointerover@child,pointerenter@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@parent,pointerenter@parent,pointerdown@parent,pointerup@parent,(child-attached),pointerout@parent,pointerleave@parent"
FAIL pointer events from pen received before/after child moved at pointerdown assert_equals: events received expected "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,(child-moved),pointerover@child,pointerenter@child,pointerup@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,(child-moved),pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent"
FAIL pointer events from pen received before/after child moved at pointerup assert_equals: events received expected "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,pointerup@child,(child-moved),pointerover@child,pointerenter@child,pointerdown@child,pointerup@child,pointerout@child,pointerleave@child,pointerleave@parent" but got "pointerover@child,pointerenter@parent,pointerenter@child,pointerdown@child,pointerup@child,(child-moved),pointerout@child,pointerleave@child,pointerleave@parent"
FAIL mouse events from pen received before/after child attached at pointerdown assert_equals: events received expected "mouseover@parent,mouseenter@parent,mousedown@parent,(child-attached),mouseover@child,mouseenter@child,mouseup@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@parent,mouseenter@parent,(child-attached),mousedown@parent,mouseup@child,mouseout@parent,mouseleave@parent"
FAIL mouse events from pen received before/after child attached at pointerup assert_equals: events received expected "mouseover@parent,mouseenter@parent,mousedown@parent,mouseup@parent,(child-attached),mouseover@child,mouseenter@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@parent,mouseenter@parent,mousedown@parent,(child-attached),mouseup@parent,mouseout@parent,mouseleave@parent"
FAIL mouse events from pen received before/after child moved at pointerdown assert_equals: events received expected "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,(child-moved),mouseover@child,mouseenter@child,mouseup@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@child,mouseenter@parent,mouseenter@child,(child-moved),mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent"
FAIL mouse events from pen received before/after child moved at pointerup assert_equals: events received expected "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,mouseup@child,(child-moved),mouseover@child,mouseenter@child,mousedown@child,mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent" but got "mouseover@child,mouseenter@parent,mouseenter@child,mousedown@child,(child-moved),mouseup@child,mouseout@child,mouseleave@child,mouseleave@parent"

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
done

Harness Error (TIMEOUT), message = null

TIMEOUT pointer events from touch received before/after child attached at pointerdown Test timed out
NOTRUN pointer events from touch received before/after child attached at pointerup
NOTRUN pointer events from touch received before/after child moved at pointerdown
NOTRUN pointer events from touch received before/after child moved at pointerup
NOTRUN mouse events from touch received before/after child attached at pointerdown
NOTRUN mouse events from touch received before/after child attached at pointerup
NOTRUN mouse events from touch received before/after child moved at pointerdown
NOTRUN mouse events from touch received before/after child moved at pointerup

Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,16 @@
const done = document.getElementById("done");

let event_log = [];
let logged_event_prefix = "";
let received_compat_mouse_events = false;

function logEvent(e) {
if (e.eventPhase == e.AT_TARGET) {
if (e.type.startsWith(logged_event_prefix) && e.eventPhase == e.AT_TARGET) {
event_log.push(e.type + "@" + e.target.id);
}
if (e.type.startsWith("mouse")) {
received_compat_mouse_events = true;
}
}

function removeChild() {
Expand All @@ -43,24 +48,24 @@
}

function setup() {
const logged_events = [
"pointerover", "pointerout", "pointerenter", "pointerleave",
"pointerdown", "pointerup"
];
const logged_event_suffixes =
["over", "out", "enter", "leave", "down", "up"];
let targets = document.getElementsByClassName("target");
for (let i = 0; i < targets.length; i++) {
logged_events.forEach(ename => {
targets[i].addEventListener(ename, logEvent);
logged_event_suffixes.forEach(suffix => {
targets[i].addEventListener("pointer" + suffix, logEvent);
targets[i].addEventListener("mouse" + suffix, logEvent);
});
}
}

function addPromiseTest(remover_event, expected_events) {
const test_name = `PointerEvents from ${pointer_type} `+
`received before/after child removal at ${remover_event}`;
function addPromiseTest(remover_event, tested_event_prefix, expected_events) {
const test_name = `${tested_event_prefix} events from ${pointer_type} `+
`received before/after child removal at ${remover_event}`;

promise_test(async test => {
event_log = [];
logged_event_prefix = tested_event_prefix;

child.addEventListener(remover_event, removeChild);
test.add_cleanup(() => {
Expand All @@ -87,22 +92,42 @@
await actions.send();
await done_click_promise;

if (tested_event_prefix == "mouse" && !received_compat_mouse_events) {
expected_events = [];
}

assert_equals(event_log.toString(), expected_events.toString(),
"events received");
}, test_name);
}

setup();
addPromiseTest("pointerdown", [

// Tests for dispatched pointer events.
addPromiseTest("pointerdown", "pointer", [
"pointerover@child", "pointerenter@parent", "pointerenter@child",
"pointerdown@child", "(child-removed)", "pointerup@parent",
"pointerdown@parent", "pointerup@parent",
"pointerout@parent", "pointerleave@parent"
]);
addPromiseTest("pointerup", [
addPromiseTest("pointerup", "pointer", [
"pointerover@child", "pointerenter@parent", "pointerenter@child",
"pointerdown@child", "pointerup@child", "(child-removed)",
"pointerdown@parent", "pointerup@parent",
"pointerout@parent", "pointerleave@parent"
]);

// Same tests for dispatched compatibility mouse events.
addPromiseTest("pointerdown", "mouse", [
"mouseover@child", "mouseenter@parent", "mouseenter@child",
"(child-removed)", "mouseup@parent",
"mousedown@parent", "mouseup@parent",
"mouseout@parent", "mouseleave@parent"
]);
addPromiseTest("pointerup", "mouse", [
"mouseover@child", "mouseenter@parent", "mouseenter@child",
"mousedown@child", "(child-removed)",
"mousedown@parent", "mouseup@parent",
"mouseout@parent", "mouseleave@parent"
]);
</script>
Loading

0 comments on commit 42d1126

Please sign in to comment.