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
|
// Copyright (C) 2015 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
es6id: 9.5.6
description: >
Trap is called with handler as context and parameters are target, P, and the
descriptor object.
info: >
[[DefineOwnProperty]] (P, Desc)
...
9. Let descObj be FromPropertyDescriptor(Desc).
10. Let booleanTrapResult be ToBoolean(Call(trap, handler, «target, P,
descObj»)).
...
---*/
var _handler, _target, _prop, _desc;
var target = {};
var descriptor = {
configurable: true,
enumerable: true,
writable: true,
value: 1
};
var handler = {
defineProperty: function(t, prop, desc) {
_handler = this;
_target = t;
_prop = prop;
_desc = desc;
return true;
}
};
var p = new Proxy(target, handler);
Object.defineProperty(p, "attr", descriptor);
assert.sameValue(_handler, handler);
assert.sameValue(_target, target);
assert.sameValue(_prop, "attr");
assert.sameValue(
Object.keys(_desc).length, 4,
"descriptor arg has the same amount of keys as given descriptor"
);
assert(_desc.configurable);
assert(_desc.writable);
assert(_desc.enumerable);
assert.sameValue(_desc.value, 1);
|