harness/asyncHelpers.js: Remove dependency on Promise.

This commit is contained in:
Cam Tenny 2022-12-05 14:36:41 -08:00 committed by Philip Chimento
parent 98952c3c51
commit 4bd0545b29

View File

@ -10,9 +10,14 @@ function asyncTest(testFunc) {
if (!Object.hasOwn(globalThis, "$DONE")) { if (!Object.hasOwn(globalThis, "$DONE")) {
throw new Test262Error("asyncTest called without async flag"); throw new Test262Error("asyncTest called without async flag");
} }
const resolveThenable = {
then(resolve, reject) {
resolve();
},
};
if (typeof testFunc !== "function") { if (typeof testFunc !== "function") {
$DONE(new Test262Error("asyncTest called with non-function argument")); $DONE(new Test262Error("asyncTest called with non-function argument"));
return Promise.resolve(); return resolveThenable;
} }
try { try {
return testFunc().then( return testFunc().then(
@ -25,7 +30,7 @@ function asyncTest(testFunc) {
); );
} catch (syncError) { } catch (syncError) {
$DONE(syncError); $DONE(syncError);
return Promise.resolve(); return resolveThenable;
} }
} }