Debian Codegraph @

js/src/jit-test/tests/gc/weakRef_in_promise.js

raw
1 // https://github.com/tc39/proposal-weakrefs/issues/39
2 // Weakref should keep the target until the end of current Job, that includes
3 // microtask(Promise).
4 let wr;
5 {
6 let obj = {};
7 wr = new WeakRef(obj);
8 obj = null;
9 }
10 // obj is out of block scope now, should be GCed.
11
12 gc();
13
14 assertEq(undefined == wr.deref(), false);
15 Promise.resolve().then(() => {
16 assertEq(undefined == wr.deref(), false);
17 });
18