Debian Codegraph @

js/src/tests/test262/language/statements/async-function/forbidden-ext/b2/async-func-decl-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-decl.template
5 /*---
6 description: Forbidden extension, o.caller (async function declaration)
7 esid: sec-async-definitions
8 features: [arrow-function, async-functions]
9 flags: [generated, noStrict, async]
10 info: |
11 AsyncFunctionDeclaration :
12 async function BindingIdentifier ( 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 async function f() {
32 "use strict";
33 // This and the following conditional value is set in the test's .case file.
34 // For every test that has a "true" value here, there is a
35 // corresponding test that has a "false" value here.
36 // They are generated from two different case files, which use
37 // the same templates.
38 let descriptor = Object.getOwnPropertyDescriptor(inner, "caller");
39 if (descriptor && descriptor.configurable && true) {
40 Object.defineProperty(inner, "caller", {get(){return 1}});
41 }
42 var result = inner();
43 if (descriptor && descriptor.configurable && true) {
44 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.');
45 }
46 // "CALLER_OWN_PROPERTY_DOES_NOT_EXIST" is from
47 // forbidden-ext-indirect-access-prop-caller.case
48 //
49 // If the function object "inner" has an own property
50 // named "caller", then its value will be returned.
51 //
52 // If the function object "inner" DOES NOT have an
53 // own property named "caller", then the symbol
54 // CALLER_OWN_PROPERTY_DOES_NOT_EXIST will be returned.
55 if (result !== CALLER_OWN_PROPERTY_DOES_NOT_EXIST) {
56 assert.notSameValue(result, f);
57 }
58 callCount++;
59 }
60
61 f()
62 .then(() => {
63 assert.sameValue(callCount, 1, 'function body evaluated');
64 }, $DONE).then($DONE, $DONE);