Debian Codegraph @

js/src/tests/test262/built-ins/Object/keys/proxy-non-enumerable-prop-invariant-2.js

raw
1 // Copyright (C) 2019 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-object.keys
6 description: >
7 Proxy [[OwnPropertyKeys]] trap does not skip non-enumerable keys when validating invariant:
8 * If the target object is not extensible, then the result List must contain all the keys of
9 the own properties of the target object and no other values.
10 info: |
11 Object.keys ( O )
12
13 ...
14 2. Let nameList be ? EnumerableOwnPropertyNames(obj, "key").
15
16 EnumerableOwnPropertyNames ( O, kind )
17
18 ...
19 2. Let ownKeys be ? O.[[OwnPropertyKeys]]().
20
21 [[OwnPropertyKeys]] ( )
22
23 ...
24 11. Let targetKeys be ? target.[[OwnPropertyKeys]]().
25 16. For each element key of targetKeys, do
26 a. Let desc be ? target.[[GetOwnProperty]](key).
27 b. If desc is not undefined and desc.[[Configurable]] is false, then
28 ...
29 c. Else,
30 i. Append key as an element of targetConfigurableKeys.
31 ...
32 18. Let uncheckedResultKeys be a new List which is a copy of trapResult.
33 ...
34 21. For each key that is an element of targetConfigurableKeys, do
35 a. If key is not an element of uncheckedResultKeys, throw a TypeError exception.
36 features: [Proxy]
37 ---*/
38
39 var target = {};
40 Object.defineProperty(target, 'prop', {
41 value: 2,
42 writable: true,
43 enumerable: false,
44 configurable: true,
45 });
46
47 var proxy = new Proxy(target, {
48 ownKeys: function() {
49 return [];
50 },
51 });
52
53 Object.preventExtensions(target);
54
55 assert.throws(TypeError, function() {
56 Object.keys(proxy);
57 });
58
59 reportCompare(0, 0);