Debian Codegraph @

tests/auto/qml/ecmascripttests/test262/test/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 es6id: 6.1.7.3
6 description: >
7 Value of non-writable, non-configurable data property must not change
8 ("caller" property of a non-strict function)
9 info: |
10 [[GetOwnProperty]] (P)
11 [...]
12 - If a property P is described as a data property with Desc.[[Value]] equal
13 to v and Desc.[[Writable]] and Desc.[[Configurable]] are both false, then
14 the SameValue must be returned for the Desc.[[Value]] attribute of the
15 property on all future calls to [[GetOwnProperty]] ( P ).
16 [...]
17 (This invariant was violated for the specific property under test by a number
18 of implementations as of January 2017.)
19 ---*/
20
21 function f() {
22 return Reflect.getOwnPropertyDescriptor(f, 'caller');
23 }
24
25 function g() {
26 return f();
27 }
28
29 Reflect.defineProperty(f, 'caller', {
30 writable: false,
31 configurable: false
32 });
33
34 var desc = Reflect.getOwnPropertyDescriptor(f, 'caller');
35 if (desc && desc.configurable === false && desc.writable === false) {
36 var desc2 = g();
37 assert.sameValue(desc.value, desc2.value);
38 }