blob: 679886d66a8a81d5b163ea9070fdafb268e98280 [file] [log] [blame]
Ben Murdoch61f157c2016-09-16 13:49:30 +01001// 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
5var r = Realm.create();
6var f = Realm.eval(r, "function f() { return this }; f()");
7assertEquals(f, Realm.global(r));
8
9// Cross-origin property access throws
10assertThrows(() => f.a, TypeError);
11assertThrows(() => { 'use strict'; f.a = 1 }, TypeError);
12
13var r2 = Realm.createAllowCrossRealmAccess();
14var f2 = Realm.eval(r2, "function f() { return this }; f()");
15assertEquals(f2, Realm.global(r2));
16
17// Same-origin property access doesn't throw
18assertEquals(undefined, f2.a);
19f2.a = 1;
20assertEquals(1, f2.a);