| 1 |
// Copyright (C) 2015 the V8 project authors. All rights reserved. |
| 2 |
// This code is governed by the BSD license found in the LICENSE file. |
| 3 |
/*--- |
| 4 |
es6id: 9.5.5 |
| 5 |
description: > |
| 6 |
Throws a TypeError exception if trap result is not configurable but target |
| 7 |
property descriptor is undefined. |
| 8 |
info: | |
| 9 |
[[GetOwnProperty]] (P) |
| 10 |
|
| 11 |
... |
| 12 |
2. Let handler be the value of the [[ProxyHandler]] internal slot of O. |
| 13 |
... |
| 14 |
5. Let target be the value of the [[ProxyTarget]] internal slot of O. |
| 15 |
6. Let trap be GetMethod(handler, "getOwnPropertyDescriptor"). |
| 16 |
... |
| 17 |
9. Let trapResultObj be Call(trap, handler, «target, P»). |
| 18 |
... |
| 19 |
12. Let targetDesc be target.[[GetOwnProperty]](P). |
| 20 |
... |
| 21 |
17. Let resultDesc be ToPropertyDescriptor(trapResultObj). |
| 22 |
... |
| 23 |
22. If resultDesc.[[Configurable]] is false, then |
| 24 |
a. If targetDesc is undefined or targetDesc.[[Configurable]] is true, then |
| 25 |
i. Throw a TypeError exception. |
| 26 |
|
| 27 |
---*/ |
| 28 |
|
| 29 |
var target = {}; |
| 30 |
|
| 31 |
var p = new Proxy(target, { |
| 32 |
getOwnPropertyDescriptor: function(t, prop) { |
| 33 |
var foo = {}; |
| 34 |
|
| 35 |
Object.defineProperty(foo, "bar", { |
| 36 |
configurable: false, |
| 37 |
enumerable: true, |
| 38 |
value: 1 |
| 39 |
}); |
| 40 |
|
| 41 |
return Object.getOwnPropertyDescriptor(foo, prop); |
| 42 |
} |
| 43 |
}); |
| 44 |
|
| 45 |
assert.throws(TypeError, function() { |
| 46 |
Object.getOwnPropertyDescriptor(p, "bar"); |
| 47 |
}); |