Debian Codegraph @

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