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 | 5 |
6 // Flags: --harmony-proxies --allow-natives-syntax | 6 // Flags: --allow-natives-syntax |
7 | 7 |
8 // Test instanceof with proxies. | 8 // Test instanceof with proxies. |
9 | 9 |
10 (function TestInstanceOfWithProxies() { | 10 (function TestInstanceOfWithProxies() { |
11 function foo(x) { | 11 function foo(x) { |
12 return x instanceof Array; | 12 return x instanceof Array; |
13 } | 13 } |
14 assertTrue(foo([])); | 14 assertTrue(foo([])); |
15 assertFalse(foo({})); | 15 assertFalse(foo({})); |
16 %OptimizeFunctionOnNextCall(foo); | 16 %OptimizeFunctionOnNextCall(foo); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 (function testInstanceOfWithRecursiveProxy() { | 53 (function testInstanceOfWithRecursiveProxy() { |
54 // Make sure we gracefully deal with recursive proxies. | 54 // Make sure we gracefully deal with recursive proxies. |
55 var proxy = new Proxy({},{}); | 55 var proxy = new Proxy({},{}); |
56 proxy.__proto__ = proxy; | 56 proxy.__proto__ = proxy; |
57 // instanceof will cause an inifinite prototype walk. | 57 // instanceof will cause an inifinite prototype walk. |
58 assertThrows(() => { proxy instanceof Object }, RangeError); | 58 assertThrows(() => { proxy instanceof Object }, RangeError); |
59 | 59 |
60 var proxy2 = new Proxy({}, {getPrototypeOf() { return proxy2 }}); | 60 var proxy2 = new Proxy({}, {getPrototypeOf() { return proxy2 }}); |
61 assertThrows(() => { proxy instanceof Object }, RangeError); | 61 assertThrows(() => { proxy instanceof Object }, RangeError); |
62 })(); | 62 })(); |
OLD | NEW |