summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/gc/weakRef_in_promise.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/gc/weakRef_in_promise.js')
-rw-r--r--js/src/jit-test/tests/gc/weakRef_in_promise.js18
1 files changed, 18 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/gc/weakRef_in_promise.js b/js/src/jit-test/tests/gc/weakRef_in_promise.js
new file mode 100644
index 0000000000..2448ebcd8a
--- /dev/null
+++ b/js/src/jit-test/tests/gc/weakRef_in_promise.js
@@ -0,0 +1,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);
+});
+