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 --- js/src/jit-test/lib/evalInFrame.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 js/src/jit-test/lib/evalInFrame.js (limited to 'js/src/jit-test/lib/evalInFrame.js') diff --git a/js/src/jit-test/lib/evalInFrame.js b/js/src/jit-test/lib/evalInFrame.js new file mode 100644 index 0000000000..d429b3fb6a --- /dev/null +++ b/js/src/jit-test/lib/evalInFrame.js @@ -0,0 +1,32 @@ +var evalInFrame = (function (global) { + var dbgGlobal = newGlobal({newCompartment: true}); + var dbg = new dbgGlobal.Debugger(); + + return function evalInFrame(upCount, code) { + dbg.addDebuggee(global); + + // Skip ourself. + var frame = dbg.getNewestFrame().older; + for (var i = 0; i < upCount; i++) { + if (!frame.older) + break; + frame = frame.older; + } + + var completion = frame.eval(code); + if (completion.return) { + var v = completion.return; + if (typeof v === "object") + v = v.unsafeDereference(); + return v; + } + if (completion.throw) { + var v = completion.throw; + if (typeof v === "object") + v = v.unsafeDereference(); + throw v; + } + if (completion === null) + terminate(); + }; +})(this); -- cgit v1.2.3