Debian Codegraph @

js/src/tests/test262/language/expressions/arrow-function/forbidden-ext/b2/arrow-function-forbidden-ext-indirect-access-own-prop-caller-get.js

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