2015-03-27 02:36:22 +01:00
|
|
|
// Copyright (C) 2015 Caitlin Potter. All rights reserved.
|
|
|
|
// This code is governed by the BSD license found in the LICENSE file.
|
|
|
|
|
2019-06-19 22:39:21 +02:00
|
|
|
/*---
|
2015-03-27 02:36:22 +01:00
|
|
|
description: >
|
|
|
|
ECMAScript Function objects defined using syntactic constructors
|
|
|
|
in strict mode code do not have own properties "caller" or
|
2016-06-14 21:26:12 +02:00
|
|
|
"arguments" other than those that are created by applying the
|
|
|
|
AddRestrictedFunctionProperties abstract operation to the function.
|
2015-03-27 02:36:22 +01:00
|
|
|
flags: [onlyStrict]
|
|
|
|
es6id: 16.1
|
|
|
|
---*/
|
|
|
|
|
|
|
|
function func() {}
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
return func.caller;
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'return func.caller throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
func.caller = {};
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'func.caller = {} throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
return func.arguments;
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'return func.arguments throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
func.arguments = {};
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'func.arguments = {} throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
var newfunc = new Function('"use strict"');
|
|
|
|
|
2021-08-11 20:53:42 +02:00
|
|
|
assert.sameValue(newfunc.hasOwnProperty('caller'), false, 'newfunc.hasOwnProperty(\'caller\') must return false');
|
|
|
|
assert.sameValue(newfunc.hasOwnProperty('arguments'), false, 'newfunc.hasOwnProperty(\'arguments\') must return false');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
return newfunc.caller;
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'return newfunc.caller throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
newfunc.caller = {};
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'newfunc.caller = {} throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
return newfunc.arguments;
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'return newfunc.arguments throws a TypeError exception');
|
2015-03-27 02:36:22 +01:00
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
newfunc.arguments = {};
|
2021-08-11 20:53:42 +02:00
|
|
|
}, 'newfunc.arguments = {} throws a TypeError exception');
|