From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../tests/debug/Object-getPromiseReactions-06.js | 43 ++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js (limited to 'js/src/jit-test/tests/debug/Object-getPromiseReactions-06.js') 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); -- cgit v1.2.3