Debian Codegraph @

testing/web-platform/mozilla/tests/dom/fs/support/testHelpers.js

raw
1 async function waitUntil(isWaitDone, untilMs, stepMs = 25) {
2 const startMs = Date.now();
3
4 return new Promise((resolve, reject) => {
5 const areWeDoneYet = setInterval(async function() {
6 if (await isWaitDone()) {
7 clearInterval(areWeDoneYet);
8 resolve();
9 } else if (Date.now() > startMs + untilMs) {
10 clearInterval(areWeDoneYet);
11 reject(new Error("Timed out after " + untilMs + "ms"));
12 }
13 }, stepMs);
14 });
15 }