OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 var target = { | 5 var target = { |
6 target: 1 | 6 target: 1 |
7 }; | 7 }; |
8 target.__proto__ = { | 8 target.__proto__ = { |
9 target_proto: 2 | 9 target_proto: 2 |
10 }; | 10 }; |
(...skipping 19 matching lines...) Expand all Loading... |
30 assertEquals([], Object.keys(proxy)); | 30 assertEquals([], Object.keys(proxy)); |
31 | 31 |
32 // Throwing shouldn't crash. | 32 // Throwing shouldn't crash. |
33 handler.getOwnPropertyDescriptor = function() { throw new Number(1); }; | 33 handler.getOwnPropertyDescriptor = function() { throw new Number(1); }; |
34 assertThrows("Object.keys(proxy)", Number); | 34 assertThrows("Object.keys(proxy)", Number); |
35 | 35 |
36 // Fall through to target if there is no trap. | 36 // Fall through to target if there is no trap. |
37 handler.ownKeys = undefined; | 37 handler.ownKeys = undefined; |
38 assertEquals(["target"], Object.keys(proxy)); | 38 assertEquals(["target"], Object.keys(proxy)); |
39 assertEquals(["target"], Object.keys(target)); | 39 assertEquals(["target"], Object.keys(target)); |
| 40 |
| 41 var proxy2 = new Proxy(proxy, {}); |
| 42 assertEquals(["target"], Object.keys(proxy2)); |
| 43 |
| 44 |
| 45 (function testForSymbols() { |
| 46 var symbol = Symbol(); |
| 47 var p = new Proxy({}, {ownKeys() { return ["1", symbol, "2"] }}); |
| 48 assertEquals(["1","2"], Object.getOwnPropertyNames(p)); |
| 49 assertEquals([symbol], Object.getOwnPropertySymbols(p)); |
| 50 })(); |
OLD | NEW |