Debian Codegraph @

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

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