Debian Codegraph @

js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js

raw
1 'use strict';
2 // Copyright (C) 2015 Caitlin Potter. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
4
5 /*---
6 description: >
7 ECMAScript Function objects defined using syntactic constructors
8 in strict mode code do not have own properties "caller" or
9 "arguments" other than those that are created by applying the
10 AddRestrictedFunctionProperties abstract operation to the function.
11 flags: [onlyStrict]
12 es6id: 16.1
13 ---*/
14
15 function func() {}
16
17 assert.throws(TypeError, function() {
18 return func.caller;
19 }, 'return func.caller throws a TypeError exception');
20
21 assert.throws(TypeError, function() {
22 func.caller = {};
23 }, 'func.caller = {} throws a TypeError exception');
24
25 assert.throws(TypeError, function() {
26 return func.arguments;
27 }, 'return func.arguments throws a TypeError exception');
28
29 assert.throws(TypeError, function() {
30 func.arguments = {};
31 }, 'func.arguments = {} throws a TypeError exception');
32
33 var newfunc = new Function('"use strict"');
34
35 assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false');
36 assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false');
37
38 assert.throws(TypeError, function() {
39 return newfunc.caller;
40 }, 'return newfunc.caller throws a TypeError exception');
41
42 assert.throws(TypeError, function() {
43 newfunc.caller = {};
44 }, 'newfunc.caller = {} throws a TypeError exception');
45
46 assert.throws(TypeError, function() {
47 return newfunc.arguments;
48 }, 'return newfunc.arguments throws a TypeError exception');
49
50 assert.throws(TypeError, function() {
51 newfunc.arguments = {};
52 }, 'newfunc.arguments = {} throws a TypeError exception');
53
54 reportCompare(0, 0);