| 1 |
// This file was procedurally generated from the following sources: |
| 2 |
// - src/function-forms/forbidden-ext-indirect-access-prop-caller.case |
| 3 |
// - src/function-forms/forbidden-extensions/bullet-two/func-expr.template |
| 4 |
/*--- |
| 5 |
description: Forbidden extension, o.caller (function expression) |
| 6 |
esid: sec-definitions-runtime-semantics-evaluation |
| 7 |
flags: [generated, noStrict] |
| 8 |
info: | |
| 9 |
FunctionExpression : function ( FormalParameters ) { FunctionBody } |
| 10 |
|
| 11 |
If an implementation extends any function object with an own property named "caller" the value of |
| 12 |
that property, as observed using [[Get]] or [[GetOwnProperty]], must not be a strict function |
| 13 |
object. If it is an accessor property, the function that is the value of the property's [[Get]] |
| 14 |
attribute must never return a strict function when called. |
| 15 |
|
| 16 |
---*/ |
| 17 |
var CALLER_OWN_PROPERTY_DOES_NOT_EXIST = Symbol(); |
| 18 |
function inner() { |
| 19 |
// This property may exist, but is forbidden from having a value that is a strict function object |
| 20 |
return inner.hasOwnProperty("caller") |
| 21 |
? inner.caller |
| 22 |
: CALLER_OWN_PROPERTY_DOES_NOT_EXIST; |
| 23 |
} |
| 24 |
|
| 25 |
var callCount = 0; |
| 26 |
var f; |
| 27 |
f = function() { |
| 28 |
"use strict"; |
| 29 |
// This and the following conditional value is set in the test's .case file. |
| 30 |
// For every test that has a "true" value here, there is a |
| 31 |
// corresponding test that has a "false" value here. |
| 32 |
// They are generated from two different case files, which use |
| 33 |
// the same templates. |
| 34 |
let descriptor = Object.getOwnPropertyDescriptor(inner, "caller"); |
| 35 |
if (descriptor && descriptor.configurable && false) { |
| 36 |
Object.defineProperty(inner, "caller", {}); |
| 37 |
} |
| 38 |
var result = inner(); |
| 39 |
if (descriptor && descriptor.configurable && false) { |
| 40 |
assert.sameValue(result, 1, 'If this test defined an own "caller" property on the inner function, then it should be accessible and should return the value it was set to.'); |
| 41 |
} |
| 42 |
|
| 43 |
// "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from |
| 44 |
// forbidden-ext-indirect-access-prop-caller.case |
| 45 |
// |
| 46 |
// If the function object "inner" has an own property |
| 47 |
// named "caller", then its value will be returned. |
| 48 |
// |
| 49 |
// If the function object "inner" DOES NOT have an |
| 50 |
// own property named "caller", then the symbol |
| 51 |
// CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned. |
| 52 |
if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) { |
| 53 |
assert.notSameValue(result, f); |
| 54 |
} |
| 55 |
|
| 56 |
callCount++; |
| 57 |
}; |
| 58 |
f(); |
| 59 |
assert.sameValue(callCount, 1, 'body evaluated'); |
| 60 |
|
| 61 |
reportCompare(0, 0); |