diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js | |
parent | Initial commit. (diff) | |
download | firefox-esr-upstream.tar.xz firefox-esr-upstream.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esrupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js')
-rw-r--r-- | js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js b/js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js new file mode 100644 index 0000000000..fd2df0277b --- /dev/null +++ b/js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js @@ -0,0 +1,57 @@ +// Debugger.Script.prototype.isAsyncFunction, Debugger.Object.prototype.isAsyncFunction, +// Debugger.Script.prototype.isGeneratorFunction, Debugger.Object.prototype.isGeneratorFunction + +var g = newGlobal({newCompartment: true}); +var dbg = new Debugger(); +var gDO = dbg.addDebuggee(g); +g.non_debuggee = function non_debuggee () {} + +function checkExpr(expr, { isAsync, isGenerator }) +{ + print("Evaluating: " + JSON.stringify(expr)); + let completion = gDO.executeInGlobal(expr); + if (completion.throw) + throw completion.throw.unsafeDereference(); + + let fn = completion.return; + assertEq(fn.isAsyncFunction, isAsync); + assertEq(fn.isGeneratorFunction, isGenerator); + + // The Debugger.Object and its Debugger.Script should always agree. + if (fn.script) { + assertEq(fn.isAsyncFunction, fn.script.isAsyncFunction); + assertEq(fn.isGeneratorFunction, fn.script.isGeneratorFunction); + } +} + +checkExpr('({})', { isAsync: undefined, isGenerator: undefined }); +checkExpr('non_debuggee', { isAsync: undefined, isGenerator: undefined }); +checkExpr('(function(){})', { isAsync: false, isGenerator: false }); +checkExpr('(function*(){})', { isAsync: false, isGenerator: true }); +checkExpr('(async function snerf(){})', { isAsync: true, isGenerator: false }); +checkExpr('(async function* omlu(){})', { isAsync: true, isGenerator: true }); + +checkExpr('new Function("1+2")', { isAsync: false, isGenerator: false }); +checkExpr('Object.getPrototypeOf(function*(){}).constructor("1+2")', + { isAsync: false, isGenerator: true }); +checkExpr('Object.getPrototypeOf(async function(){}).constructor("1+2")', + { isAsync: true, isGenerator: false }); +checkExpr('Object.getPrototypeOf(async function*(){}).constructor("1+2")', + { isAsync: true, isGenerator: true }); + +// Check eval scripts. +function checkFrame(expr, type) +{ + var log = ''; + dbg.onDebuggerStatement = function(frame) { + log += 'd'; + assertEq(frame.type, type); + assertEq(frame.script.isAsyncFunction, false); + assertEq(frame.script.isGeneratorFunction, false); + } + gDO.executeInGlobal(expr); + assertEq(log, 'd'); +} + +checkFrame('debugger;', 'global'); +checkFrame('eval("debugger;")', 'eval'); |