| 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 --harmony-reflect --allow-natives-syntax | |
| 6 | |
| 7 // Do not read out the prototype from a cross-realm object. | |
| 8 var realm = Realm.create(); | |
| 9 | |
| 10 __proto__ = {}; | |
| 11 assertEquals(null, | |
| 12 Realm.eval(realm, "3; Reflect.getPrototypeOf(Realm.global(0))")); | |
| 13 assertFalse(Realm.eval(realm, "3; Realm.global(0) instanceof Object")); | |
| 14 | |
| 15 __proto__ = new Proxy({}, { getPrototypeOf() { assertUnreachable() } }); | |
| 16 assertEquals(null, | |
| 17 Realm.eval(realm, "1; Reflect.getPrototypeOf(Realm.global(0))")); | |
| 18 assertFalse(Realm.eval(realm, "1; Realm.global(0) instanceof Object")); | |
| 19 | |
| 20 // Test that the instannceof check works in optimized code. | |
| 21 var test = Realm.eval(realm, | |
| 22 "()=>{1.1; return Realm.global(0) instanceof Object; }"); | |
| 23 assertFalse(test()); | |
| 24 test(); | |
| 25 test(); | |
| 26 %OptimizeFunctionOnNextCall(test); | |
| 27 assertFalse(test()); | |
| 28 | |
| 29 __proto__ = {}; | |
| 30 __proto__ = new Proxy({}, { get(t, p, r) { assertUnreachable() } }); | |
| 31 assertEquals(null, | |
| 32 Realm.eval(realm, "2; Reflect.getPrototypeOf(Realm.global(0))")); | |
| 33 assertFalse(Realm.eval(realm, "2; Realm.global(0) instanceof Object")); | |
| 34 | |
| 35 | |
| 36 __proto__ = {}; | |
| 37 __proto__.__proto__ = new Proxy({}, { | |
| 38 getPrototypeOf() { assertUnreachable() } | |
| 39 }); | |
| 40 assertEquals(null, | |
| 41 Realm.eval(realm, "4; Reflect.getPrototypeOf(Realm.global(0))")); | |
| 42 assertFalse(Realm.eval(realm, "4; Realm.global(0) instanceof Object")); | |
| 43 | |
| 44 // 2-level proxy indirection | |
| 45 __proto__ = {}; | |
| 46 __proto__ = new Proxy({}, | |
| 47 new Proxy({}, { | |
| 48 get() { assertUnreachable() } | |
| 49 }) | |
| 50 ); | |
| 51 assertEquals(null, | |
| 52 Realm.eval(realm, "5; Reflect.getPrototypeOf(Realm.global(0))")); | |
| 53 assertFalse(Realm.eval(realm, "5; Realm.global(0) instanceof Object")); | |
| OLD | NEW |