Debian Codegraph @

js/src/tests/test262/built-ins/Reflect/ownKeys/order-after-define-property.js

raw
1 // Copyright (C) 2020 Alexey Shvayka. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /*---
5 esid: sec-reflect.ownkeys
6 description: >
7 Property names are returned in ascending chronological order of creation
8 that is unaffected by [[DefineOwnProperty]].
9 info: |
10 Reflect.ownKeys ( target )
11
12 [...]
13 2. Let keys be ? target.[[OwnPropertyKeys]]().
14 3. Return CreateArrayFromList(keys).
15
16 OrdinaryOwnPropertyKeys ( O )
17
18 [...]
19 4. For each own property key P of O that is a Symbol, in ascending
20 chronological order of property creation, do
21 a. Add P as the last element of keys.
22 5. Return keys.
23
24 [[OwnPropertyKeys]] ( )
25
26 [...]
27 7. For each own property key P of O such that Type(P) is String and P is not
28 an array index, in ascending chronological order of property creation, do
29 a. Add P as the last element of keys.
30 [...]
31 9. Return keys.
32 features: [Symbol, Reflect]
33 includes: [compareArray.js]
34 ---*/
35
36 var obj = {};
37 var symA = Symbol("a");
38 var symB = Symbol("b");
39 obj[symA] = 1;
40 obj[symB] = 2;
41 Object.defineProperty(obj, symA, {configurable: false});
42 assert.compareArray(Reflect.ownKeys(obj), [symA, symB]);
43
44 var str = new String("");
45 str.a = 1;
46 str.b = 2;
47 Object.defineProperty(str, "a", {
48 get: function() {},
49 });
50 assert.compareArray(Reflect.ownKeys(str), ["length", "a", "b"]);
51
52 reportCompare(0, 0);