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 --- .../jit-test/tests/debug/Script-parameterNames.js | 36 ++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 js/src/jit-test/tests/debug/Script-parameterNames.js (limited to 'js/src/jit-test/tests/debug/Script-parameterNames.js') diff --git a/js/src/jit-test/tests/debug/Script-parameterNames.js b/js/src/jit-test/tests/debug/Script-parameterNames.js new file mode 100644 index 0000000000..1557a97e22 --- /dev/null +++ b/js/src/jit-test/tests/debug/Script-parameterNames.js @@ -0,0 +1,36 @@ +load(libdir + "asserts.js"); + +var g = newGlobal({newCompartment: true}); +var dbg = new Debugger; +var gDO = dbg.addDebuggee(g); + +function check(expr, expected) { + let completion = gDO.executeInGlobal(expr); + if (completion.throw) + throw completion.throw.unsafeDereference(); + + let fn = completion.return; + if (expected === undefined) + assertEq(fn.script.parameterNames, undefined); + else + assertDeepEq(fn.script.parameterNames, expected); +} + +check('(function () {})', []); +check('(function (x) {})', ["x"]); +check('(function (x = 1) {})', ["x"]); +check('(function (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z) {})', + ["a","b","c","d","e","f","g","h","i","j","k","l","m", + "n","o","p","q","r","s","t","u","v","w","x","y","z"]); +check('(function (a, [b, c], {d, e:f}) { })', + ["a", undefined, undefined]); +check('(async function (a, b, c) {})', ["a", "b", "c"]); +check('(async function* (d, e, f) {})', ["d", "e", "f"]); + +// Non-function scripts have |undefined| parameterNames. +var log = []; +dbg.onEnterFrame = function(frame) { + log.push(frame.script.parameterNames); +}; +g.evaluate("function foo(a, b) { return eval('1'); }; foo();"); +assertDeepEq(log, [undefined, ["a", "b"], undefined]); // global, function, eval -- cgit v1.2.3