summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 19:33:14 +0000
commit36d22d82aa202bb199967e9512281e9a53db42c9 (patch)
tree105e8c98ddea1c1e4784a60a5a6410fa416be2de /js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js
parentInitial commit. (diff)
downloadfirefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz
firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.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/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js')
-rw-r--r--js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js54
1 files changed, 54 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js b/js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js
new file mode 100644
index 0000000000..54b3553489
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js
@@ -0,0 +1,54 @@
+'use strict';
+// Copyright (C) 2015 Caitlin Potter. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ ECMAScript Function objects defined using syntactic constructors
+ in strict mode code do not have own properties "caller" or
+ "arguments" other than those that are created by applying the
+ AddRestrictedFunctionProperties abstract operation to the function.
+flags: [onlyStrict]
+es6id: 16.1
+---*/
+
+function func() {}
+
+assert.throws(TypeError, function() {
+ return func.caller;
+}, 'return func.caller throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ func.caller = {};
+}, 'func.caller = {} throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ return func.arguments;
+}, 'return func.arguments throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ func.arguments = {};
+}, 'func.arguments = {} throws a TypeError exception');
+
+var newfunc = new Function('"use strict"');
+
+assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false');
+assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false');
+
+assert.throws(TypeError, function() {
+ return newfunc.caller;
+}, 'return newfunc.caller throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ newfunc.caller = {};
+}, 'newfunc.caller = {} throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ return newfunc.arguments;
+}, 'return newfunc.arguments throws a TypeError exception');
+
+assert.throws(TypeError, function() {
+ newfunc.arguments = {};
+}, 'newfunc.arguments = {} throws a TypeError exception');
+
+reportCompare(0, 0);