Files
sousa-gecko/testing/web-platform/tests/event-timing/interactionid-label-click.html
T
Scott Haseley b56fb86c3f Bug 2042609 [wpt PR 60185] - EventTiming: Fix two instances of nested click handling, a=testonly
Automatic update from web-platform-tests
EventTiming: Fix two instances of nested click handling

This CL fixes two instances where input events, specifically clicks, can
be nested within another click event:
 1. Nested clicks happen when a label is clicked and the click is
    forwarded to a form control. This was actually causing a crash in
    soft navs because we detect a soft nav context mismatch (outer
    context vs. inner context). This CL fixes this by assigning an
    interactionId of 0, which matches Safari and FF's behavior. I've
    added a WPT for this as well.

 2. Due to scheduling races, it's possible to process a queued input
    event in a nested event loop triggered in a click, e.g. if the click
    event handler calls window.print(). The nested event will run, but
    the downstream the events don't fire because the context is paused.
    Really we shouldn't be running the events at all, but for now we
    just ignore them for event timing, matching what happens downstream.

    I'll try to follow-up with a regression test for this, but it may
    be impractical due to the race.

Bug: 500983020
Change-Id: I40c6918c2222aec28b1cbeaeafa57ba383192e4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7870025
Commit-Queue: Scott Haseley <shaseley@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1636428}

--

wpt-commits: 6821788164e500920aef9ee961572db8f583b557
wpt-pr: 60185
2026-05-29 16:00:11 +00:00

52 lines
1.8 KiB
HTML

<!DOCTYPE html>
<meta charset=utf-8 />
<title>Event Timing: Test interactionId for clicks forwarded to form controls</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src=/resources/testdriver.js></script>
<script src=/resources/testdriver-vendor.js></script>
<script src=resources/event-timing-test-utils.js></script>
<label id="label" for="control">Click me</label>
<select id="control"></select>
<script>
promise_test(async t => {
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
const entriesPromise = new Promise(resolve => {
let clickEntries = [];
let observer = new PerformanceObserver(entryList => {
clickEntries = clickEntries.concat(
entryList.getEntries().filter(entry => entry.name == 'click'));
if (clickEntries.length == 2) {
observer.disconnect();
resolve(clickEntries);
}
});
observer.observe({type: 'event', buffered: true});
});
addListeners(label, ['click']);
addListeners(control, ['click']);
await click(label);
let entries = await entriesPromise;
controlEntry = entries[0].target.id === 'control' ? entries[0] : entries[1];
labelEntry = entries[0].target.id === 'label' ? entries[0] : entries[1];
assert_equals(
labelEntry.target.id, 'label', 'Expected an entry for the label');
assert_greater_than(
labelEntry.interactionId, 0,
'Expected interactionId for "label" to be non-zero');
assert_equals(
controlEntry.target.id, 'control', 'Expected an entry for the control');
assert_equals(
controlEntry.interactionId, 0,
'Expected interactionId for "control" to be zero');
}, 'Event Timing: interactionId for clicks forwarded form controls is zero.');
</script>