summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Function/StrictFunction_restricted-properties-strict.js
blob: 54b35534894d4a9afb4a0c19087ae9fd32d9b8b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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);