From 266b8380a7bab5a1e3e10b6845cfeb7191fcfad9 Mon Sep 17 00:00:00 2001 From: Joey Arhar Date: Mon, 30 Dec 2024 10:23:46 -0800 Subject: [PATCH] Make label click WPT stop timing out 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 Commit-Queue: Joey Arhar Cr-Commit-Position: refs/heads/main@{#1400951} --- ...click-to-associated-element.tentative.html | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/html/semantics/forms/the-label-element/proxy-modifier-click-to-associated-element.tentative.html b/html/semantics/forms/the-label-element/proxy-modifier-click-to-associated-element.tentative.html index fa50c080250699..a4fe0f7bc3208e 100644 --- a/html/semantics/forms/the-label-element/proxy-modifier-click-to-associated-element.tentative.html +++ b/html/semantics/forms/the-label-element/proxy-modifier-click-to-associated-element.tentative.html @@ -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");