summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 00:47:55 +0000
commit26a029d407be480d791972afb5975cf62c9360a6 (patch)
treef435a8308119effd964b339f76abb83a57c29483 /js/src/jit-test/tests/debug/isAsyncFunction-isGeneratorFunction.js
parentInitial commit. (diff)
downloadfirefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz
firefox-26a029d407be480d791972afb5975cf62c9360a6.zip
Adding upstream version 124.0.1.upstream/124.0.1
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.js57
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');