mirror of
https://github.com/servo/servo.git
synced 2025-06-26 18:14:34 +01:00
21 lines
710 B
JavaScript
21 lines
710 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 1) waiting
|
|
// for two requestAnimationFrames() to happen one after another and 2)
|
|
// adding a step_timeout(0) to guarantee events have finished should be
|
|
// sufficient to ensure at least one frame has been generated anywhere.
|
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=1785615
|
|
window.requestAnimationFrame(() => {
|
|
window.requestAnimationFrame(() => {
|
|
setTimeout(resolve, 0);
|
|
});
|
|
});
|
|
});
|
|
}
|