Debian Codegraph @

js/src/tests/test262/built-ins/Object/internals/DefineOwnProperty/consistent-value-function-caller.js

raw
1 // Copyright (C) 2017 Claude Pache. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3 /*---
4 esid: sec-invariants-of-the-essential-internal-methods
5 description: >
6 Value of non-writable, non-configurable data property must not change
7 ("caller" property of a non-strict function)
8 info: |
9 [[GetOwnProperty]] (P)
10 [...]
11 - If a property P is described as a data property with Desc.[[Value]] equal
12 to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then
13 the SameValue must be returned for the Desc.[[Value]] attribute of the
14 property on all future calls to [[GetOwnProperty]] ( P ).
15 [...]
16 (This invariant was violated for the specific property under test by a number
17 of implementations as of January 2017.)
18 ---*/
19
20 function f() {
21 return Reflect.getOwnPropertyDescriptor(f, 'caller');
22 }
23
24 function g() {
25 return f();
26 }
27
28 Reflect.defineProperty(f, 'caller', {
29 writable: false,
30 configurable: false
31 });
32
33 var desc = Reflect.getOwnPropertyDescriptor(f, 'caller');
34 if (desc && desc.configurable === false && desc.writable === false) {
35 var desc2 = g();
36 assert.sameValue(desc.value, desc2.value);
37 }
38
39 reportCompare(0, 0);