Skip to content

Commit

Permalink
Make touch event test wait until promises are resolved.
Browse files Browse the repository at this point in the history
Judging from the test history[1], it appears the fix in
crrev.com/c/5630365 did not work. This is another attempt to deflake
this test.

In this attempt, we ensure that the test function itself waits for the
resolution of the actions promise before proceeding. This should
address the flaky leaks. This is still only a speculative fix because
the failure has not reproduced locally even with hundreds of
--enable-leak-detection runs.

[1]https://ci.chromium.org/ui/test/chromium%3Aci/ninja%3A%2F%2F%3Ablink_wpt_tests%2Fexternal%2Fwpt%2Ftouch-events%2Fsingle-touch-vertical-rl.html?q=VHASH%3A402a4a508f2b5677

Bug: 40861680
Change-Id: I3e29f0cbb4d21964be3a5665aaa7d07882a841b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5677036
Reviewed-by: Kevin Ellis <[email protected]>
Commit-Queue: David Awogbemila <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1323437}
  • Loading branch information
David Awogbemila authored and chromium-wpt-export-bot committed Jul 4, 2024
1 parent b921f8e commit 272fda1
Showing 1 changed file with 31 additions and 15 deletions.
46 changes: 31 additions & 15 deletions touch-events/single-touch-vertical-rl.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,44 @@
<script>
setup({explicit_done: true});

async function run() {
document.documentElement.addEventListener("touchstart", function onTouchStart(event) {
test(function() {
assert_equals(event.changedTouches[0].clientX, 10, "clientX");
assert_equals(event.changedTouches[0].clientY, 20, "clientY");
}, "touchstart client coordinates are correct in vertical-rl");
function onEvent(target, eventName, validator) {
return new Promise((resolve) => {
const listener = (event) => {
validator(event);
resolve();
};
target.addEventListener(eventName, listener, { once: true });
});
}

document.documentElement.addEventListener("click", function onClick(event) {
test(function() {
assert_equals(event.clientX, 10, "clientX");
assert_equals(event.clientY, 20, "clientY");
}, "click client coordinates are correct in vertical-rl");
done();
});
async function run() {
promise_test(async () => {
const touchstart_promise = onEvent(document.documentElement,
"touchstart", (event) => {
assert_equals(event.changedTouches[0].clientX, 10,
"touchstart clientX coordinates are correct in vertical-rl");
assert_equals(event.changedTouches[0].clientY, 20,
"touchstart clientX coordinates are correct in vertical-rl");
});

const click_promise = onEvent(document.documentElement,
"click", (event) => {
assert_equals(event.clientX, 10,
"click clientX coordinates are correct in vertical-rl");
assert_equals(event.clientY, 20,
"click clientY coordinates are correct in vertical-rl");
});

let actions = new test_driver.Actions()
const actions = new test_driver.Actions()
.addPointer("touchPointer1", "touch")
.pointerMove(10, 20)
.pointerDown()
.pointerUp();
await actions.send();

const actions_promise = actions.send();
await Promise.all([actions_promise, click_promise, touchstart_promise]);
done();
}, "touch & click events in vertical-rl mode have correct coordinates");
}
</script>
<style>
Expand Down

0 comments on commit 272fda1

Please sign in to comment.