OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 var r = Realm.create(); |
| 6 var f = Realm.eval(r, "function f() { return this }; f()"); |
| 7 assertEquals(f, Realm.global(r)); |
| 8 |
| 9 // Cross-origin property access throws |
| 10 assertThrows(() => f.a, TypeError); |
| 11 assertThrows(() => { 'use strict'; f.a = 1 }, TypeError); |
| 12 |
| 13 var r2 = Realm.createAllowCrossRealmAccess(); |
| 14 var f2 = Realm.eval(r2, "function f() { return this }; f()"); |
| 15 assertEquals(f2, Realm.global(r2)); |
| 16 |
| 17 // Same-origin property access doesn't throw |
| 18 assertEquals(undefined, f2.a); |
| 19 f2.a = 1; |
| 20 assertEquals(1, f2.a); |
OLD | NEW |