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 // Flags: --harmony-proxies | 5 // Flags: --harmony-proxies |
6 | 6 |
7 "use strict"; | 7 "use strict"; |
8 | 8 |
9 | 9 |
10 var global = this; | 10 var global = this; |
(...skipping 12 matching lines...) Expand all Loading... |
23 | 23 |
24 (function TestProxyProto() { | 24 (function TestProxyProto() { |
25 var calls = 0; | 25 var calls = 0; |
26 var handler = { | 26 var handler = { |
27 getPropertyDescriptor: function(name) { | 27 getPropertyDescriptor: function(name) { |
28 calls++; | 28 calls++; |
29 return undefined; | 29 return undefined; |
30 } | 30 } |
31 }; | 31 }; |
32 | 32 |
33 var proto = {}; | 33 var target = {}; |
34 var proxy = Proxy.create(handler, proto); | 34 var proxy = new Proxy(target, handler); |
35 var object = { | 35 var object = { |
36 __proto__: proxy, | 36 __proto__: proxy, |
37 setX(v) { | 37 setX(v) { |
38 super.x = v; | 38 super.x = v; |
39 }, | 39 }, |
40 setSymbol(sym, v) { | 40 setSymbol(sym, v) { |
41 super[sym] = v; | 41 super[sym] = v; |
42 } | 42 } |
43 }; | 43 }; |
44 | 44 |
(...skipping 22 matching lines...) Expand all Loading... |
67 assertUnreachable(); | 67 assertUnreachable(); |
68 }, | 68 }, |
69 set(receiver, name, value) { | 69 set(receiver, name, value) { |
70 calls++; | 70 calls++; |
71 assertEquals(proxy, receiver); | 71 assertEquals(proxy, receiver); |
72 assertEquals('y', name); | 72 assertEquals('y', name); |
73 assertEquals(3, value); | 73 assertEquals(3, value); |
74 } | 74 } |
75 }; | 75 }; |
76 | 76 |
77 var proxy = Proxy.create(handler); | 77 var proxy = new Proxy({}, handler); |
78 object.setY.call(proxy, 3); | 78 object.setY.call(proxy, 3); |
79 assertEquals(1, calls); | 79 assertEquals(1, calls); |
80 })(); | 80 })(); |
OLD | NEW |