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 --harmony-reflect | 5 // Flags: --harmony-proxies --harmony-reflect |
6 | 6 |
7 var target = { target: 1 }; | 7 var target = { target: 1 }; |
8 target.__proto__ = {}; | 8 target.__proto__ = {}; |
9 var handler = { handler: 1 }; | 9 var handler = { handler: 1 }; |
10 var proxy = new Proxy(target, handler); | 10 var proxy = new Proxy(target, handler); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 assertEquals([3], Reflect.getPrototypeOf(target)); | 113 assertEquals([3], Reflect.getPrototypeOf(target)); |
114 | 114 |
115 // Setting the prototype of a non-extensible target is fine if the prototype | 115 // Setting the prototype of a non-extensible target is fine if the prototype |
116 // doesn't change. | 116 // doesn't change. |
117 delete handler.getPrototypeOf; | 117 delete handler.getPrototypeOf; |
118 Reflect.setPrototypeOf(proxy2, prototype); | 118 Reflect.setPrototypeOf(proxy2, prototype); |
119 // Changing the prototype will throw. | 119 // Changing the prototype will throw. |
120 prototype = [5]; | 120 prototype = [5]; |
121 assertThrows(() => {Reflect.setPrototypeOf(proxy2, prototype)}, TypeError); | 121 assertThrows(() => {Reflect.setPrototypeOf(proxy2, prototype)}, TypeError); |
122 })(); | 122 })(); |
| 123 |
| 124 (function testProxyTrapReturnsFalse() { |
| 125 var handler = {}; |
| 126 handler.setPrototypeOf = () => false; |
| 127 var target = new Proxy({}, {isExtensible: () => assertUnreachable()}); |
| 128 var object = new Proxy(target, handler); |
| 129 assertFalse(Reflect.setPrototypeOf(object, {})); |
| 130 })(); |
OLD | NEW |