Skip to content

Commit

Permalink
Make label click WPT stop timing out
Browse files Browse the repository at this point in the history
This patch refactors a WPT to expect a click event after waiting for
test_driver to complete its inputs instead of just waiting forever for a
click event.

As a result, it is clearer that this test is only failing on
content_shell due to functionality within test_driver.

Bug: 40756672
Change-Id: Id3debff7f74c8db9e0c30c9fadcae60a54a10755
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6126506
Reviewed-by: Di Zhang <[email protected]>
Commit-Queue: Joey Arhar <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1400951}
  • Loading branch information
josepharhar authored and chromium-wpt-export-bot committed Dec 30, 2024
1 parent 32de1ab commit 266b838
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,54 @@
"use strict";

function clickWithModifier(label, key) {
new test_driver.Actions()
return (new test_driver.Actions()
.keyDown(key)
.pointerMove(0, 0, { origin: label })
.pointerDown()
.pointerUp()
.addTick()
.keyUp(key)
.keyUp(key))
.send()
}

async_test(t => {
promise_test(async () => {
const label = document.getElementById("click-label");
const input = document.getElementById("click");

input.addEventListener("click", t.step_func_done());
new test_driver.click(label)

let receivedClick = false;
input.addEventListener("click", () => receivedClick = true);
await test_driver.click(label);
assert_true(receivedClick);
}, "label with for attribute should proxy click events to the associated element on click");

async_test(t => {
promise_test(async () => {
const label = document.getElementById("shift-label");
const input = document.getElementById("shift");

input.addEventListener("click", t.step_func_done());
clickWithModifier(label, "\uE008"); // ShiftLeft

let receivedClick = false;
input.addEventListener("click", () => receivedClick = true);
await clickWithModifier(label, "\uE008"); // ShiftLeft
assert_true(receivedClick);
}, "label with for attribute should proxy click events to the associated element on shift click");

async_test(t => {
promise_test(async () => {
const label = document.getElementById("alt-label");
const input = document.getElementById("alt");

input.addEventListener("click", t.step_func_done());
clickWithModifier(label, "\uE00A"); // AltLeft

let receivedClick = false;
input.addEventListener("click", () => receivedClick = true);
await clickWithModifier(label, "\uE00A"); // AltLeft
assert_true(receivedClick);
}, "label with for attribute should proxy click events to the associated element on alt click");

async_test(t => {
promise_test(async () => {
const label = document.getElementById("meta-label");
const input = document.getElementById("meta");

input.addEventListener("click", t.step_func_done());
clickWithModifier(label, "\uE03D"); // OSLeft

let receivedClick = false;
input.addEventListener("click", () => receivedClick = true);
await clickWithModifier(label, "\uE03D"); // OSLeft
assert_true(receivedClick);
}, "label with for attribute should proxy click events to the associated element on meta click");

</script>

0 comments on commit 266b838

Please sign in to comment.