OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 // Flags: --harmony-proxies | |
6 | |
7 var target = { target: 1 }; | |
8 target.__proto__ = {}; | |
9 var handler = { handler: 1 }; | |
10 var proxy = new Proxy(target, handler); | |
11 | |
12 assertSame(Object.getPrototypeOf(proxy), target.__proto__ ); | |
13 | |
14 target.__proto__ = []; | |
15 assertSame(Object.getPrototypeOf(proxy), target.__proto__); | |
16 | |
17 handler.getPrototypeOf = function() { | |
18 return 1; | |
19 } | |
20 assertThrows(function() { Object.getPrototypeOf(proxy) }, TypeError); | |
21 | |
22 var target_prototype = {a:1, b:2}; | |
23 handler.getPrototypeOf = function() { | |
24 return target_prototype ; | |
25 } | |
26 assertSame(Object.getPrototypeOf(proxy), target_prototype); | |
27 | |
28 // Test with proxy target: | |
29 var proxy2 = new Proxy(proxy, {}); | |
30 assertSame(Object.getPrototypeOf(proxy2), target_prototype); | |
31 | |
32 // Test with Proxy handler: | |
33 // TODO(neis,cbruni): Uncomment once the get trap works again. | |
34 // var proxy3_prototype = {}; | |
35 // var handler_proxy = new Proxy({ | |
36 // getPrototypeOf: function() { return proxy3_prototype } | |
37 // }, {}); | |
38 // var proxy3 = new Proxy(target, handler_proxy); | |
39 // assertSame(Object.getPrototypeOf(proxy3), target_prototype); | |
OLD | NEW |