blob: ffba5c2d81e853443393eeff27e80121c5a800e1 [file] [log] [blame]
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001// 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
Ben Murdochda12d292016-06-02 14:46:10 +01005// Flags: --allow-natives-syntax
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00006
7// Do not read out the prototype from a cross-realm object.
8var realm = Realm.create();
9
10__proto__ = {};
11assertEquals(null,
12 Realm.eval(realm, "3; Reflect.getPrototypeOf(Realm.global(0))"));
13assertFalse(Realm.eval(realm, "3; Realm.global(0) instanceof Object"));
14
15__proto__ = new Proxy({}, { getPrototypeOf() { assertUnreachable() } });
16assertEquals(null,
17 Realm.eval(realm, "1; Reflect.getPrototypeOf(Realm.global(0))"));
18assertFalse(Realm.eval(realm, "1; Realm.global(0) instanceof Object"));
19
20// Test that the instannceof check works in optimized code.
21var test = Realm.eval(realm,
22 "()=>{1.1; return Realm.global(0) instanceof Object; }");
23assertFalse(test());
24test();
25test();
26%OptimizeFunctionOnNextCall(test);
27assertFalse(test());
28
29__proto__ = {};
30__proto__ = new Proxy({}, { get(t, p, r) { assertUnreachable() } });
31assertEquals(null,
32 Realm.eval(realm, "2; Reflect.getPrototypeOf(Realm.global(0))"));
33assertFalse(Realm.eval(realm, "2; Realm.global(0) instanceof Object"));
34
35
36__proto__ = {};
37__proto__.__proto__ = new Proxy({}, {
38 getPrototypeOf() { assertUnreachable() }
39});
40assertEquals(null,
41 Realm.eval(realm, "4; Reflect.getPrototypeOf(Realm.global(0))"));
42assertFalse(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);
51assertEquals(null,
52 Realm.eval(realm, "5; Reflect.getPrototypeOf(Realm.global(0))"));
53assertFalse(Realm.eval(realm, "5; Realm.global(0) instanceof Object"));