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: --allow-natives-syntax --harmony-proxies --harmony-reflect |
| 6 |
| 7 function CreateConstructableProxy(handler) { |
| 8 return Proxy.createFunction(handler, function() {}, function() {}); |
| 9 } |
| 10 |
| 11 (function() { |
| 12 var prototype = { x: 1 }; |
| 13 var log = []; |
| 14 |
| 15 var proxy = CreateConstructableProxy({ |
| 16 get(k) { |
| 17 log.push("get trap"); |
| 18 return prototype; |
| 19 }}); |
| 20 |
| 21 var o = Reflect.construct(Number, [100], proxy); |
| 22 assertEquals(["get trap"], log); |
| 23 assertTrue(Object.getPrototypeOf(o) === prototype); |
| 24 assertEquals(100, Number.prototype.valueOf.call(o)); |
| 25 })(); |
| 26 |
| 27 (function() { |
| 28 var prototype = { x: 1 }; |
| 29 var log = []; |
| 30 |
| 31 var proxy = CreateConstructableProxy({ |
| 32 get(k) { |
| 33 log.push("get trap"); |
| 34 return 10; |
| 35 }}); |
| 36 |
| 37 var o = Reflect.construct(Number, [100], proxy); |
| 38 assertEquals(["get trap"], log); |
| 39 assertTrue(Object.getPrototypeOf(o) === Object.prototype); |
| 40 assertEquals(100, Number.prototype.valueOf.call(o)); |
| 41 })(); |
OLD | NEW |