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

Side by Side Diff: test/mjsunit/cross-realm-filtering.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, 5 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
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/reflect-construct.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 realms = [Realm.current(), Realm.create()]; 7 var realms = [Realm.current(), Realm.create()];
6 8
7 // Check stack trace filtering across security contexts. 9 // Check stack trace filtering across security contexts.
8 var thrower_script = 10 var thrower_script =
9 "(function () { Realm.eval(Realm.current(), 'throw Error()') })"; 11 "(function () { Realm.eval(Realm.current(), 'throw Error()') })";
10 Realm.shared = { 12 Realm.shared = {
11 thrower_0: Realm.eval(realms[0], thrower_script), 13 thrower_0: Realm.eval(realms[0], thrower_script),
12 thrower_1: Realm.eval(realms[1], thrower_script), 14 thrower_1: Realm.eval(realms[1], thrower_script),
13 }; 15 };
14 16
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 83
82 var o = new f(); 84 var o = new f();
83 var proto = Object.getPrototypeOf(o); 85 var proto = Object.getPrototypeOf(o);
84 assertFalse(proto === Object.prototype); 86 assertFalse(proto === Object.prototype);
85 assertTrue(proto === otherObject.prototype); 87 assertTrue(proto === otherObject.prototype);
86 88
87 o = Realm.eval(realmIndex, "new f()"); 89 o = Realm.eval(realmIndex, "new f()");
88 proto = Object.getPrototypeOf(o); 90 proto = Object.getPrototypeOf(o);
89 assertFalse(proto === Object.prototype); 91 assertFalse(proto === Object.prototype);
90 assertTrue(proto === otherObject.prototype); 92 assertTrue(proto === otherObject.prototype);
93
94 // Check function constructor.
95 var ctor_script = "Function";
96 var ctor_a_script =
97 "(function() { return Function.apply(this, ['return 1;']); })";
98 var ctor_b_script = "Function.bind(this, 'return 1;')";
99 var ctor_c_script =
100 "(function() { return Function.call(this, 'return 1;'); })";
101 Realm.shared = {
102 ctor_0 : Realm.eval(realms[0], ctor_script),
103 ctor_1 : Realm.eval(realms[1], ctor_script),
104 ctor_a_0 : Realm.eval(realms[0], ctor_a_script),
105 ctor_a_1 : Realm.eval(realms[1], ctor_a_script),
106 ctor_b_0 : Realm.eval(realms[0], ctor_b_script),
107 ctor_b_1 : Realm.eval(realms[1], ctor_b_script),
108 ctor_c_0 : Realm.eval(realms[0], ctor_c_script),
109 ctor_c_1 : Realm.eval(realms[1], ctor_c_script),
110 }
111 var script_0 = " \
112 var ctor_0 = Realm.shared.ctor_0; \
113 Realm.shared.direct_0 = ctor_0('return 1'); \
114 Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \
115 Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \
116 Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \
117 Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \
118 Realm.shared.proxy_0 = new Proxy(ctor_0, {})('return 1'); \
119 Realm.shared.reflect_0 = Reflect.apply(ctor_0, this, ['return 1']); \
120 Realm.shared.a_0 = Realm.shared.ctor_a_0(); \
121 Realm.shared.b_0 = Realm.shared.ctor_b_0(); \
122 Realm.shared.c_0 = Realm.shared.ctor_c_0(); \
123 ";
124 script = script_0 + script_0.replace(/_0/g, "_1");
125 Realm.eval(realms[0], script);
126 assertSame(1, Realm.shared.direct_0());
127 assertSame(1, Realm.shared.indirect_0());
128 assertSame(1, Realm.shared.apply_0());
129 assertSame(1, Realm.shared.bind_0());
130 assertSame(1, Realm.shared.call_0());
131 assertSame(1, Realm.shared.proxy_0());
132 assertSame(1, Realm.shared.reflect_0());
133 assertSame(1, Realm.shared.a_0());
134 assertSame(1, Realm.shared.b_0());
135 assertSame(1, Realm.shared.c_0());
136 assertSame(undefined, Realm.shared.direct_1);
137 assertSame(undefined, Realm.shared.indirect_1);
138 assertSame(undefined, Realm.shared.apply_1);
139 assertSame(undefined, Realm.shared.bind_1);
140 assertSame(undefined, Realm.shared.call_1);
141 assertSame(undefined, Realm.shared.proxy_1);
142 assertSame(undefined, Realm.shared.reflect_1);
143 assertSame(undefined, Realm.shared.a_1);
144 assertSame(undefined, Realm.shared.b_1);
145 assertSame(undefined, Realm.shared.c_1);
146 Realm.eval(realms[1], script);
147 assertSame(undefined, Realm.shared.direct_0);
148 assertSame(undefined, Realm.shared.indirect_0);
149 assertSame(undefined, Realm.shared.apply_0);
150 assertSame(undefined, Realm.shared.bind_0);
151 assertSame(undefined, Realm.shared.call_0);
152 assertSame(undefined, Realm.shared.proxy_0);
153 assertSame(undefined, Realm.shared.reflect_0);
154 assertSame(undefined, Realm.shared.a_0);
155 assertSame(undefined, Realm.shared.b_0);
156 assertSame(undefined, Realm.shared.c_0);
157 assertSame(1, Realm.shared.direct_1());
158 assertSame(1, Realm.shared.indirect_1());
159 assertSame(1, Realm.shared.apply_1());
160 assertSame(1, Realm.shared.bind_1());
161 assertSame(1, Realm.shared.call_1());
162 assertSame(1, Realm.shared.proxy_1());
163 assertSame(1, Realm.shared.reflect_1());
164 assertSame(1, Realm.shared.a_1());
165 assertSame(1, Realm.shared.b_1());
166 assertSame(1, Realm.shared.c_1());
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | test/mjsunit/es6/reflect-construct.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698