summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/language/global-code/script-decl-var-err.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/tests/test262/language/global-code/script-decl-var-err.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/tests/test262/language/global-code/script-decl-var-err.js')
-rw-r--r--js/src/tests/test262/language/global-code/script-decl-var-err.js42
1 files changed, 42 insertions, 0 deletions
diff --git a/js/src/tests/test262/language/global-code/script-decl-var-err.js b/js/src/tests/test262/language/global-code/script-decl-var-err.js
new file mode 100644
index 0000000000..730309f718
--- /dev/null
+++ b/js/src/tests/test262/language/global-code/script-decl-var-err.js
@@ -0,0 +1,42 @@
+// 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-globaldeclarationinstantiation
+es6id: 15.1.8
+description: >
+ Declaration of variable when there is no corresponding global property and
+ the global object is non-extensible
+info: |
+ [...]
+ 11. Let declaredVarNames be a new empty List.
+ 12. For each d in varDeclarations, do
+ a. If d is a VariableDeclaration or a ForBinding, then
+ i. For each String vn in the BoundNames of d, do
+ 1. If vn is not an element of declaredFunctionNames, then
+ a. Let vnDefinable be ? envRec.CanDeclareGlobalVar(vn).
+ b. If vnDefinable is false, throw a TypeError exception.
+ c. If vn is not an element of declaredVarNames, then
+ i. Append vn to declaredVarNames.
+
+ 8.1.1.4.15 CanDeclareGlobalVar
+
+ 1. Let envRec be the global Environment Record for which the method was
+ invoked.
+ 2. Let ObjRec be envRec.[[ObjectRecord]].
+ 3. Let globalObject be the binding object for ObjRec.
+ 4. Let hasProperty be ? HasOwnProperty(globalObject, N).
+ 5. If hasProperty is true, return true.
+ 6. Return ? IsExtensible(globalObject).
+---*/
+
+var executed = false;
+
+Object.preventExtensions(this);
+
+assert.throws(TypeError, function() {
+ $262.evalScript('executed = true; var test262;');
+});
+
+assert.sameValue(executed, false);
+
+reportCompare(0, 0);