fune/testing/web-platform/tests/common/rendering-utils.js
Philip Rogers cde71073aa Bug 1833629 [wpt PR 40055] - Make waitForAtLeastOneFrame just for rendering, a=testonly
Automatic update from web-platform-tests
Make waitForAtLeastOneFrame just for rendering

https://crrev.com/1112425 fixed a cross-browser event flakiness issue
by making waitForAtLeastOneFrame wait both requestAnimationFrames and a
setTimeout. This patch moves the cross-browser event logic fix into
select-event.html so waitForAtLeastOneFrame just handles the
cross-browser differences related to rendering.

Bug: 1420110
Change-Id: I22ca860d9d59313517baa107860d9c75fa7ca9df
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4544037
Reviewed-by: Di Zhang <dizhangg@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1145700}

--

wpt-commits: 39fb748ddf814fe42a109bfc4a76875cc2fee8f2
wpt-pr: 40055
2023-05-25 08:22:06 +00:00

19 lines
559 B
JavaScript

"use strict";
/**
* Waits until we have at least one frame rendered, regardless of the engine.
*
* @returns {Promise}
*/
function waitForAtLeastOneFrame() {
return new Promise(resolve => {
// Different web engines work slightly different on this area but waiting
// for two requestAnimationFrames() to happen, one after another, should be
// sufficient to ensure at least one frame has been generated anywhere.
window.requestAnimationFrame(() => {
window.requestAnimationFrame(() => {
resolve();
});
});
});
}