summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/weakRef_in_promise.js
blob: 2448ebcd8a75225ed352f299b49918454b70ae4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
// https://github.com/tc39/proposal-weakrefs/issues/39
// Weakref should keep the target until the end of current Job, that includes
// microtask(Promise).
let wr;
{
  let obj = {};
  wr = new WeakRef(obj);
  obj = null;
}
// obj is out of block scope now, should be GCed.

gc();

assertEq(undefined == wr.deref(), false);
Promise.resolve().then(() => {
  assertEq(undefined == wr.deref(), false);
});