summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js')
-rw-r--r--js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js43
1 files changed, 43 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js b/js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js
new file mode 100644
index 0000000000..99d0bba872
--- /dev/null
+++ b/js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js
@@ -0,0 +1,43 @@
+// Debugger.Object.prototype.getPromiseReactions should handle reaction records
+// that are cross-compartment with their promises.
+
+var dbg = new Debugger;
+
+var g1 = newGlobal({ newCompartment: true });
+var DOg1 = dbg.addDebuggee(g1);
+
+var g2 = newGlobal({ newCompartment: true });
+var DOg2 = dbg.addDebuggee(g2);
+
+g1.eval(`
+ var pResolve, pReject;
+ var p = new Promise((resolve, reject) => { pResolve = resolve; pReject = reject });
+`);
+
+g2.p = g1.p;
+g2.eval(`
+ var p2 = new Promise((resolve, reject) => { resolve(p); });
+`);
+
+const DOp = DOg1.makeDebuggeeValue(g1.p);
+const DOp2 = DOg2.makeDebuggeeValue(g2.p2);
+
+// Since the standard resolving functions enqueue a job to do the `then` call,
+// we need to drain the queue before p2 will appear on p1's reaction list.
+drainJobQueue();
+
+const reactions = DOp.getPromiseReactions();
+assertEq(true, Array.isArray(reactions));
+assertEq(reactions.length, 1);
+assertEq(typeof reactions[0], "object");
+assertEq(true, reactions[0].resolve instanceof Debugger.Object);
+assertEq(true, reactions[0].resolve.callable);
+assertEq(true, reactions[0].reject instanceof Debugger.Object);
+assertEq(true, reactions[0].reject.callable);
+
+// Unfortunately, this is not p2; it's the promise returned by the internal call
+// to `then` that attached the reaction record to p. See bug 1603575 for ideas
+// about how to actually retrieve p2.
+assertEq(true, reactions[0].result instanceof Debugger.Object);
+assertEq(reactions[0].result.class, "Promise");
+assertEq(true, reactions[0].result !== DOp2);