Index: test/mjsunit/cross-realm-filtering.js |
diff --git a/test/mjsunit/cross-realm-filtering.js b/test/mjsunit/cross-realm-filtering.js |
index 47c0d192299ec00159da9a554ce47059efcea7e9..2a23e0e19923227997d36b4687e35b6e66bddb90 100644 |
--- a/test/mjsunit/cross-realm-filtering.js |
+++ b/test/mjsunit/cross-realm-filtering.js |
@@ -2,6 +2,8 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
+// Flags: --restricted-realms |
+ |
var realms = [Realm.current(), Realm.create()]; |
// Check stack trace filtering across security contexts. |
@@ -88,3 +90,77 @@ o = Realm.eval(realmIndex, "new f()"); |
proto = Object.getPrototypeOf(o); |
assertFalse(proto === Object.prototype); |
assertTrue(proto === otherObject.prototype); |
+ |
+// Check function constructor. |
+var ctor_script = "Function"; |
+var ctor_a_script = |
+ "(function() { return Function.apply(this, ['return 1;']); })"; |
+var ctor_b_script = "Function.bind(this, 'return 1;')"; |
+var ctor_c_script = |
+ "(function() { return Function.call(this, 'return 1;'); })"; |
+Realm.shared = { |
+ ctor_0 : Realm.eval(realms[0], ctor_script), |
+ ctor_1 : Realm.eval(realms[1], ctor_script), |
+ ctor_a_0 : Realm.eval(realms[0], ctor_a_script), |
+ ctor_a_1 : Realm.eval(realms[1], ctor_a_script), |
+ ctor_b_0 : Realm.eval(realms[0], ctor_b_script), |
+ ctor_b_1 : Realm.eval(realms[1], ctor_b_script), |
+ ctor_c_0 : Realm.eval(realms[0], ctor_c_script), |
+ ctor_c_1 : Realm.eval(realms[1], ctor_c_script), |
+} |
+var script_0 = " \ |
+ var ctor_0 = Realm.shared.ctor_0; \ |
+ Realm.shared.direct_0 = ctor_0('return 1'); \ |
+ Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \ |
+ Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \ |
+ Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \ |
+ Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \ |
+ Realm.shared.proxy_0 = new Proxy(ctor_0, {})('return 1'); \ |
+ Realm.shared.reflect_0 = Reflect.apply(ctor_0, this, ['return 1']); \ |
+ Realm.shared.a_0 = Realm.shared.ctor_a_0(); \ |
+ Realm.shared.b_0 = Realm.shared.ctor_b_0(); \ |
+ Realm.shared.c_0 = Realm.shared.ctor_c_0(); \ |
+"; |
+script = script_0 + script_0.replace(/_0/g, "_1"); |
+Realm.eval(realms[0], script); |
+assertSame(1, Realm.shared.direct_0()); |
+assertSame(1, Realm.shared.indirect_0()); |
+assertSame(1, Realm.shared.apply_0()); |
+assertSame(1, Realm.shared.bind_0()); |
+assertSame(1, Realm.shared.call_0()); |
+assertSame(1, Realm.shared.proxy_0()); |
+assertSame(1, Realm.shared.reflect_0()); |
+assertSame(1, Realm.shared.a_0()); |
+assertSame(1, Realm.shared.b_0()); |
+assertSame(1, Realm.shared.c_0()); |
+assertSame(undefined, Realm.shared.direct_1); |
+assertSame(undefined, Realm.shared.indirect_1); |
+assertSame(undefined, Realm.shared.apply_1); |
+assertSame(undefined, Realm.shared.bind_1); |
+assertSame(undefined, Realm.shared.call_1); |
+assertSame(undefined, Realm.shared.proxy_1); |
+assertSame(undefined, Realm.shared.reflect_1); |
+assertSame(undefined, Realm.shared.a_1); |
+assertSame(undefined, Realm.shared.b_1); |
+assertSame(undefined, Realm.shared.c_1); |
+Realm.eval(realms[1], script); |
+assertSame(undefined, Realm.shared.direct_0); |
+assertSame(undefined, Realm.shared.indirect_0); |
+assertSame(undefined, Realm.shared.apply_0); |
+assertSame(undefined, Realm.shared.bind_0); |
+assertSame(undefined, Realm.shared.call_0); |
+assertSame(undefined, Realm.shared.proxy_0); |
+assertSame(undefined, Realm.shared.reflect_0); |
+assertSame(undefined, Realm.shared.a_0); |
+assertSame(undefined, Realm.shared.b_0); |
+assertSame(undefined, Realm.shared.c_0); |
+assertSame(1, Realm.shared.direct_1()); |
+assertSame(1, Realm.shared.indirect_1()); |
+assertSame(1, Realm.shared.apply_1()); |
+assertSame(1, Realm.shared.bind_1()); |
+assertSame(1, Realm.shared.call_1()); |
+assertSame(1, Realm.shared.proxy_1()); |
+assertSame(1, Realm.shared.reflect_1()); |
+assertSame(1, Realm.shared.a_1()); |
+assertSame(1, Realm.shared.b_1()); |
+assertSame(1, Realm.shared.c_1()); |