Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1)

Side by Side Diff: test/mjsunit/realm-property-access.js

Issue 2034083002: Don't compile functions in a context the caller doesn't have access to (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 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 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 // Flags: --restricted-realms
6
5 var r = Realm.create(); 7 var r = Realm.create();
6 var f = Realm.eval(r, "function f() { return this }; f()"); 8 var f = Realm.eval(r, "function f() { return this }; f()");
7 assertEquals(f, Realm.global(r)); 9 assertEquals(f, Realm.global(r));
8 10
9 // Cross-origin property access throws 11 // Cross-origin property access throws
10 assertThrows(() => f.a, TypeError); 12 assertThrows(() => f.a, TypeError);
11 assertThrows(() => { 'use strict'; f.a = 1 }, TypeError); 13 assertThrows(() => { 'use strict'; f.a = 1 }, TypeError);
12 14
13 var r2 = Realm.createAllowCrossRealmAccess(); 15 var r2 = Realm.createAllowCrossRealmAccess();
14 var f2 = Realm.eval(r2, "function f() { return this }; f()"); 16 var f2 = Realm.eval(r2, "function f() { return this }; f()");
15 assertEquals(f2, Realm.global(r2)); 17 assertEquals(f2, Realm.global(r2));
16 18
17 // Same-origin property access doesn't throw 19 // Same-origin property access doesn't throw
18 assertEquals(undefined, f2.a); 20 assertEquals(undefined, f2.a);
19 f2.a = 1; 21 f2.a = 1;
20 assertEquals(1, f2.a); 22 assertEquals(1, f2.a);
OLDNEW
« test/mjsunit/cross-realm-filtering.js ('K') | « test/mjsunit/lookup-behind-property.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698