fix tests

This commit is contained in:
Dmitry Vasilev
2024-02-15 17:03:26 +08:00
parent 0d902418ee
commit fb07f81ff6
7 changed files with 26 additions and 10 deletions

2
src/effects.js vendored
View File

@@ -181,7 +181,7 @@ export const apply_side_effects = (prev, next, ui) => {
next.eval_modules_state != null
) {
const s = next.eval_modules_state
s.promise.__original_then(result => {
s.promise.then(result => {
exec('eval_modules_finished',
next, /* becomes prev_state */
result,

View File

@@ -515,7 +515,8 @@ export const eval_modules = (
}
if(is_async) {
return result.__original_then(make_result)
// convert app_window.Promise to host Promise
return Promise.resolve(result).then(make_result)
} else {
return make_result(result)
}

View File

@@ -75,7 +75,7 @@ const make_patched_method = (window, original, name, use_context) => {
? new original(...args)
: original.apply(this, args)
if(value instanceof cxt.window.Promise) {
if(value?.[Symbol.toStringTag] == 'Promise') {
// TODO use __original_then, not finally which calls
// patched 'then'?
value = value.finally(() => {

View File

@@ -262,7 +262,7 @@ const __await_start = (cxt, promise) => {
const children_copy = cxt.children
const result = {children_copy, promise}
if(promise instanceof cxt.window.Promise) {
if(promise?.[Symbol.toStringTag] == 'Promise') {
result.promise = promise.then(
(value) => {
result.status = {ok: true, value}