mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Fix FinalizationRegistry with primitive held value (#496)
Apparently test262 does not test FinalizationRegistry#register() with held values that are not objects. Fixes: https://github.com/quickjs-ng/quickjs/issues/494
This commit is contained in:
parent
9bc41a8a00
commit
8c58e01928
2 changed files with 19 additions and 1 deletions
|
@ -53083,7 +53083,7 @@ static void reset_weak_ref(JSRuntime *rt, JSWeakRefRecord **first_weak_ref)
|
|||
/**
|
||||
* During the GC sweep phase the held object might be collected first.
|
||||
*/
|
||||
if (JS_IsLiveObject(frd->ctx->rt, fre->held_val)) {
|
||||
if (!JS_IsObject(fre->held_val) || JS_IsLiveObject(frd->ctx->rt, fre->held_val)) {
|
||||
JSValue func = js_dup(frd->cb);
|
||||
JSValue ret = JS_Call(frd->ctx, func, JS_UNDEFINED, 1, &fre->held_val);
|
||||
JS_FreeValueRT(rt, func);
|
||||
|
|
|
@ -992,6 +992,23 @@ function test_proxy_is_array()
|
|||
}
|
||||
}
|
||||
|
||||
function test_finalization_registry()
|
||||
{
|
||||
{
|
||||
let expected = {};
|
||||
let actual;
|
||||
let finrec = new FinalizationRegistry(v => { actual = v });
|
||||
finrec.register({}, expected); // {} goes out of scope immediately
|
||||
assert(actual, expected);
|
||||
}
|
||||
{
|
||||
let actual;
|
||||
let finrec = new FinalizationRegistry(v => { actual = v });
|
||||
finrec.register({}, 42); // {} goes out of scope immediately
|
||||
assert(actual, 42);
|
||||
}
|
||||
}
|
||||
|
||||
function test_cur_pc()
|
||||
{
|
||||
var a = [];
|
||||
|
@ -1059,6 +1076,7 @@ test_weak_set();
|
|||
test_generator();
|
||||
test_proxy_iter();
|
||||
test_proxy_is_array();
|
||||
test_finalization_registry();
|
||||
test_exception_source_pos();
|
||||
test_function_source_pos();
|
||||
test_exception_prepare_stack();
|
||||
|
|
Loading…
Reference in a new issue