From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../language/eval-code/direct/super-call-method.js | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 js/src/tests/test262/language/eval-code/direct/super-call-method.js (limited to 'js/src/tests/test262/language/eval-code/direct/super-call-method.js') diff --git a/js/src/tests/test262/language/eval-code/direct/super-call-method.js b/js/src/tests/test262/language/eval-code/direct/super-call-method.js new file mode 100644 index 0000000000..f9efd69138 --- /dev/null +++ b/js/src/tests/test262/language/eval-code/direct/super-call-method.js @@ -0,0 +1,51 @@ +// Copyright (C) 2016 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-performeval +description: > + SuperCall may may only occur in eval code for direct eval within a + constructor method +info: | + [...] + 4. Let inMethod be false. + 5. Let inConstructor be false. + 6. If thisEnvRec has a [[HomeObject]] field, then + a. Let inMethod be true. + b. If thisEnvRec.[[FunctionObject]] has a [[Construct]] field, let + inConstructor be true. + 7. Let script be the ECMAScript code that is the result of parsing x, + interpreted as UTF-16 encoded Unicode text as described in 6.1.4, for the + goal symbol Script. If inMethod is false, additional early error rules + from 18.2.1.1.1 are applied. If inConstructor is false, additional early + error rules from 18.2.1.1.2 are applied. If the parse fails, throw a + SyntaxError exception. If any early errors are detected, throw a + SyntaxError or a ReferenceError exception, depending on the type of the + error (but see also clause 16). Parsing and early error detection may be + interweaved in an implementation dependent manner. + + 18.2.1.1.1 Additional Early Error Rules for Eval Outside Methods + + ScriptBody : StatementList + + - It is a Syntax Error if StatementList contains super. +features: [super] +---*/ + +var evaluatedArg = false; +var obj = { + method() { + // Early errors restricting the usage of SuperCall necessitate the use of + // `eval`. + eval('super(evaluatedArg = true);'); + } +} + +assert.throws(SyntaxError, function() { + obj.method(); +}); + +assert.sameValue( + evaluatedArg, false, 'did not perform ArgumentsListEvaluation' +); + +reportCompare(0, 0); -- cgit v1.2.3