Debian Codegraph @

js/src/tests/test262/built-ins/Object/getOwnPropertySymbols/proxy-invariant-not-extensible-extra-string-key.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.getownpropertysymbols
6 description: >
7 Proxy [[OwnPropertyKeys]] trap does not skip string 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.getOwnPropertySymbols ( O )
12
13 1. Return ? GetOwnPropertyKeys(O, Symbol).
14
15 GetOwnPropertyKeys ( O, type )
16
17 ...
18 2. Let keys be ? obj.[[OwnPropertyKeys]]().
19
20 [[OwnPropertyKeys]] ( )
21
22 ...
23 11. Let targetKeys be ? target.[[OwnPropertyKeys]]().
24 16. For each element key of targetKeys, do
25 a. Let desc be ? target.[[GetOwnProperty]](key).
26 b. If desc is not undefined and desc.[[Configurable]] is false, then
27 ...
28 c. Else,
29 i. Append key as an element of targetConfigurableKeys.
30 ...
31 18. Let uncheckedResultKeys be a new List which is a copy of trapResult.
32 ...
33 22. If uncheckedResultKeys is not empty, throw a TypeError exception.
34 features: [Proxy]
35 ---*/
36
37 var target = {};
38 var proxy = new Proxy(target, {
39 ownKeys: function() {
40 return ['prop'];
41 },
42 });
43
44 Object.preventExtensions(target);
45
46 assert.throws(TypeError, function() {
47 Object.getOwnPropertySymbols(proxy);
48 });
49
50 reportCompare(0, 0);