Bug 1900679 [wpt PR 46622] - Expose InteractionID to Keydown Entries in FID, a=testonly

Automatic update from web-platform-tests
Expose InteractionID to Keydown Entries in FID (#46622)

Given EventTimingKeypressAndCompositionInteractionId is fully launched
(though slowly rollout on webview, but soon), interactionID is now
generated upfront on keydown entries in Event Timing. As a result, we
can now easily expose that to FID to reduce developer confusions when
matching same entries between FID and Event Timing.

Bug: 40840075
Change-Id: I25c5d7dd05ef61915779acd926005fc10aa62a77
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5597879
Commit-Queue: Aoyuan Zuo <zuoaoyuan@chromium.org>
Reviewed-by: Michal Mocny <mmocny@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1310208}

Co-authored-by: Aoyuan Zuo <zuoaoyuan@chromium.org>
--

wpt-commits: a4787fec82370958a8901b8d793ac175acd3d42d
wpt-pr: 46622
This commit is contained in:
Blink WPT Bot 2024-06-07 22:02:27 +00:00 коммит произвёл moz-wptsync-bot
Родитель ee086169a7
Коммит 56b496e5da
2 изменённых файлов: 61 добавлений и 1 удалений

Просмотреть файл

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html>
<meta charset=utf-8 />
<title>First Input: interactionId-key.</title>
<input id='input'></input>
<textarea id='textarea'></textarea>
<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/testdriver-actions.js></script>
<script src=resources/event-timing-test-utils.js></script>
<script>
const key = 'a'; // Arbitrary key picked for testing.
let firstInputInteractionId = 0;
let eventTimingKeyDownInteractionId = 0;
let hasFirstInputEntry = false;
let hasEventTimingKeyDownEntry = false;
promise_test(async t => {
assert_implements(window.PerformanceEventTiming, 'Event Timing is not supported.');
const callback = (entryList) => {
entryList.getEntries().forEach(entry => {
switch (entry.entryType) {
case 'first-input': {
firstInputInteractionId = entry.interactionId;
hasFirstInputEntry = true;
break;
}
case 'event': {
if ('keydown' == entry.name) {
eventTimingKeyDownInteractionId = entry.interactionId;
hasEventTimingKeyDownEntry = true;
}
break;
}
}
});
};
const readyToResolve = () => {
return hasFirstInputEntry && hasEventTimingKeyDownEntry;
}
const observerPromise = createPerformanceObserverPromise(['event', 'first-input'], callback, readyToResolve);
await interactAndObserve('key', document.getElementById('input'), observerPromise, key);
assert_greater_than(firstInputInteractionId, 0, 'The first input entry should have a non-trivial interactionId');
assert_equals(firstInputInteractionId, eventTimingKeyDownInteractionId, 'The first input entry should have the same interactionId as the event timing keydown entry');
assert_equals(firstInputInteractionId.target, eventTimingKeyDownInteractionId.target, 'The first input entry should have the same target as the event timing keydown entry');
assert_not_equals(firstInputInteractionId.target, null, 'The first input entry should have a non-null target');
}, "The interactionId of the first input entry should match the same keydown entry of event timing when press a key.");
</script>
</html>

Просмотреть файл

@ -418,9 +418,13 @@ async function createPerformanceObserverPromise(observeTypes, callback, readyToR
// The testdriver.js, testdriver-vendor.js need to be included to use this
// function.
async function interactAndObserve(interactionType, target, observerPromise) {
async function interactAndObserve(interactionType, target, observerPromise, key = '') {
let interactionPromise;
switch (interactionType) {
case 'key': {
addListeners(target, ['keydown', 'keyup']);
interactionPromise = pressKey(target, key);
}
case 'tap': {
addListeners(target, ['pointerdown', 'pointerup']);
interactionPromise = tap(target);