summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js')
-rw-r--r--js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js b/js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js
new file mode 100644
index 0000000000..78fbd19492
--- /dev/null
+++ b/js/src/tests/test262/language/expressions/call/tco-cross-realm-class-derived-construct.js
@@ -0,0 +1,42 @@
+// |reftest| skip -- tail-call-optimization is not supported
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-function-calls-runtime-semantics-evaluation
+description: >
+ Check TypeError is thrown from correct realm with tco-call to class constructor from
+ class [[Construct]] invocation.
+info: |
+ 12.3.4.3 Runtime Semantics: EvaluateDirectCall( func, thisValue, arguments, tailPosition )
+ ...
+ 4. If tailPosition is true, perform PrepareForTailCall().
+ 5. Let result be Call(func, thisValue, argList).
+ 6. Assert: If tailPosition is true, the above call will not return here, but instead evaluation will continue as if the following return has already occurred.
+ 7. Assert: If result is not an abrupt completion, then Type(result) is an ECMAScript language type.
+ 8. Return result.
+
+ 9.2.1 [[Call]] ( thisArgument, argumentsList)
+ ...
+ 2. If F.[[FunctionKind]] is "classConstructor", throw a TypeError exception.
+ 3. Let callerContext be the running execution context.
+ 4. Let calleeContext be PrepareForOrdinaryCall(F, undefined).
+ 5. Assert: calleeContext is now the running execution context.
+ ...
+
+features: [tail-call-optimization, class, cross-realm]
+---*/
+
+// - The class constructor call is in a valid tail-call position, which means PrepareForTailCall is performed.
+// - The function call returns from `otherRealm` and proceeds the tail-call in this realm.
+// - Calling the class constructor throws a TypeError from the current realm, that means this realm and not `otherRealm`.
+var code = "(class extends Object { constructor() { return (class {})(); } });";
+
+var otherRealm = $262.createRealm();
+var tco = otherRealm.evalScript(code);
+
+assert.throws(TypeError, function() {
+ new tco();
+});
+
+reportCompare(0, 0);