Files
sousa-gecko/testing/web-platform/tests/dom/events/label-default-action.html
T
Yeonghan Kim 42ee026e25 Bug 2009796 [wpt PR 57127] - Fix <label> default action when clicked button is removed, a=testonly
Automatic update from web-platform-tests
Fix <label> default action when clicked button is removed

According to spec[1], label activation behavior for events targeted at
interactive content descendants should do nothing. The check should
reflect the state at dispatch start, not after handlers modify the DOM.
The current implementation checks IsInInteractiveContent() after event
handlers run. If the button removes itself during onclick(), it's no
longer in the DOM, so the check returns false and label activation
proceeds unexpectedly.
So, this patch fixes the bug by using the EventPath captured at dispatch
start, instead of traversing the current DOM.

[1] https://html.spec.whatwg.org/#the-label-element

Bug: 452084024
Change-Id: I7a5839fc584b9d4e6e8831acc5c770c4402427f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7368319
Reviewed-by: Mason Freed <masonf@chromium.org>
Commit-Queue: YeongHan Kim <soosungp33@gmail.com>
Reviewed-by: Joey Arhar <jarhar@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1568214}

--

wpt-commits: a10f070b29ee071292ecd7a3c02f469d8866ae3a
wpt-pr: 57127
2026-01-16 07:54:47 +00:00

22 lines
728 B
HTML

<!DOCTYPE html>
<title>Label default action with interactive content</title>
<link rel=help href="https://issues.chromium.org/issues/452084024">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(t => {
const label = document.createElement("label");
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
const button = document.createElement("button");
label.append(checkbox, button);
button.click();
assert_false(checkbox.checked);
button.onclick = () => button.remove();
button.click();
assert_false(checkbox.checked);
}, "Label default action should not trigger when clicked button removes itself");
</script>