1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 26.1.7
description: >
Return a property descriptor object as an accessor descriptor.
info: |
26.1.7 Reflect.getOwnPropertyDescriptor ( target, propertyKey )
...
4. Let desc be target.[[GetOwnProperty]](key).
5. ReturnIfAbrupt(desc).
6. Return FromPropertyDescriptor(desc).
6.2.4.4 FromPropertyDescriptor ( Desc )
...
2. Let obj be ObjectCreate(%ObjectPrototype%).
...
4. If Desc has a [[Value]] field, then
a. Perform CreateDataProperty(obj, "value", Desc.[[Value]]).
5. If Desc has a [[Writable]] field, then
a. Perform CreateDataProperty(obj, "writable", Desc.[[Writable]]).
6. If Desc has a [[Get]] field, then
a. Perform CreateDataProperty(obj, "get", Desc.[[Get]]).
7. If Desc has a [[Set]] field, then
a. Perform CreateDataProperty(obj, "set", Desc.[[Set]])
8. If Desc has an [[Enumerable]] field, then
a. Perform CreateDataProperty(obj, "enumerable", Desc.[[Enumerable]]).
9. If Desc has a [[Configurable]] field, then
a. Perform CreateDataProperty(obj , "configurable", Desc.[[Configurable]]).
...
11. Return obj.
includes: [compareArray.js]
features: [Reflect]
---*/
var o1 = {};
var fn = function() {};
Object.defineProperty(o1, 'p', {
get: fn,
configurable: true
});
var result = Reflect.getOwnPropertyDescriptor(o1, 'p');
assert.compareArray(
Object.getOwnPropertyNames(result),
['get', 'set', 'enumerable', 'configurable']
);
assert.sameValue(result.enumerable, false);
assert.sameValue(result.configurable, true);
assert.sameValue(result.get, fn);
assert.sameValue(result.set, undefined);
reportCompare(0, 0);
|