fix: promise was sending macro tasks instead of micro

This commit is contained in:
TopchetoEU 2023-11-25 18:58:24 +02:00
parent b6eaff65ca
commit b127aadcf6
Signed by: topchetoeu
GPG Key ID: 6531B8583E5F6ED4

View File

@ -252,7 +252,7 @@ import me.topchetoeu.jscript.interop.Native;
this.val = val;
this.state = STATE_FULFILLED;
ctx.engine.pushMsg(false, ctx, new NativeFunction((_ctx, _thisArg, _args) -> {
ctx.engine.pushMsg(true, ctx, new NativeFunction((_ctx, _thisArg, _args) -> {
for (var handle : handles) {
handle.fulfilled.call(handle.ctx, null, val);
}
@ -287,11 +287,12 @@ import me.topchetoeu.jscript.interop.Native;
this.val = val;
this.state = STATE_REJECTED;
ctx.engine.pushMsg(false, ctx, new NativeFunction((_ctx, _thisArg, _args) -> {
ctx.engine.pushMsg(true, ctx, new NativeFunction((_ctx, _thisArg, _args) -> {
for (var handle : handles) handle.rejected.call(handle.ctx, null, val);
if (!handled) {
if (handles.size() == 0) {
Values.printError(new EngineException(val).setCtx(ctx.environment(), ctx.engine), "(in promise)");
}
handles = null;
return null;
}), null);
}