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

Unified Diff: test/mjsunit/realm-property-access.js

Issue 1973363004: Expose a way to make a "same-origin" realm (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Style fixes Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/realm-property-access.js
diff --git a/test/mjsunit/realm-property-access.js b/test/mjsunit/realm-property-access.js
new file mode 100644
index 0000000000000000000000000000000000000000..679886d66a8a81d5b163ea9070fdafb268e98280
--- /dev/null
+++ b/test/mjsunit/realm-property-access.js
@@ -0,0 +1,20 @@
+// Copyright 2016 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var r = Realm.create();
+var f = Realm.eval(r, "function f() { return this }; f()");
+assertEquals(f, Realm.global(r));
+
+// Cross-origin property access throws
+assertThrows(() => f.a, TypeError);
+assertThrows(() => { 'use strict'; f.a = 1 }, TypeError);
+
+var r2 = Realm.createAllowCrossRealmAccess();
+var f2 = Realm.eval(r2, "function f() { return this }; f()");
+assertEquals(f2, Realm.global(r2));
+
+// Same-origin property access doesn't throw
+assertEquals(undefined, f2.a);
+f2.a = 1;
+assertEquals(1, f2.a);
« no previous file with comments | « src/d8.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698