Skip to content

Commit

Permalink
Fix timeout failure for select-multiple-keyboard-selection.optional.html
Browse files Browse the repository at this point in the history
WPT select-multiple-keyboard-selection.optional.html test needs to wait
for all keyboard events to be completed and tasks to be done before we
can assert the select's value and scroll location. Different web engines
work differently for this type of error, but 2 requestAnimationFrames
and 1 timeout should be enough.

This bug is similar to the bug 1420110.

Change-Id: I48952bc987c3be2e29ca7059422e0090335caaa3
Fixed: 1490710
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4935949
Commit-Queue: Di Zhang <dizhangg@chromium.org>
Reviewed-by: David Baron <dbaron@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1210508}
  • Loading branch information
dizhang168 authored and pull[bot] committed Nov 1, 2023
1 parent e1bf63a commit 1066640
Showing 1 changed file with 11 additions and 4 deletions.
Expand Up @@ -23,6 +23,13 @@
const arrow_right = "\uE014";
const arrow_down = "\uE015";

async function sendKeyEventAndWait(key) {
await test_driver.send_keys(document.activeElement, key);
// Engines differ in when the scrolling is applied so wait for a frame to be
// rendered.
await new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve)));
}

for (const writingMode of ["horizontal-tb", "vertical-lr", "vertical-rl", "sideways-lr", "sideways-rl"]) {
if (!CSS.supports(`writing-mode: ${writingMode}`))
continue;
Expand Down Expand Up @@ -54,16 +61,16 @@

assert_equals(document.activeElement, select);

await test_driver.send_keys(document.activeElement, previousKey);
await sendKeyEventAndWait(previousKey);
assert_equals(select.value, "Option 1");
assert_equals(select[scrollBlockAxis], 0);

await test_driver.send_keys(document.activeElement, nextKey);
await sendKeyEventAndWait(nextKey);
assert_equals(select.value, "Option 2");
assert_equals(select[scrollBlockAxis], 0);

for (let i = 0; i < select.size - 1; i++) {
await test_driver.send_keys(document.activeElement, nextKey);
await sendKeyEventAndWait(nextKey);
}

assert_equals(select.value, "Option 5");
Expand All @@ -74,7 +81,7 @@
assert_true(select[scrollBlockAxis] < 0);
}

await test_driver.send_keys(document.activeElement, previousKey);
await sendKeyEventAndWait(previousKey);
assert_equals(select.value, "Option 4");

if (!isReversedBlockFlowDirection) {
Expand Down

0 comments on commit 1066640

Please sign in to comment.