mirror of
https://github.com/nodejs/node.git
synced 2026-11-09 15:11:11 -05:00
PR-URL: https://github.com/nodejs/node/pull/33770 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com> Reviewed-By: Shingo Inoue <leko.noor@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
20 lines
559 B
JavaScript
20 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();
|
|
});
|
|
});
|
|
});
|
|
}
|