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

Side by Side Diff: test/mjsunit/cross-realm-filtering.js

Issue 1393713006: 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: Created 5 years, 2 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') | no next file » | 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 var realms = [Realm.current(), Realm.create()]; 5 var realms = [Realm.current(), Realm.create()];
6 6
7 // Check stack trace filtering across security contexts. 7 // Check stack trace filtering across security contexts.
8 var thrower_script = 8 var thrower_script =
9 "(function () { Realm.eval(Realm.current(), 'throw Error()') })"; 9 "(function () { Realm.eval(Realm.current(), 'throw Error()') })";
10 Realm.shared = { 10 Realm.shared = {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 81
82 var o = new f(); 82 var o = new f();
83 var proto = Object.getPrototypeOf(o); 83 var proto = Object.getPrototypeOf(o);
84 assertFalse(proto === Object.prototype); 84 assertFalse(proto === Object.prototype);
85 assertTrue(proto === otherObject.prototype); 85 assertTrue(proto === otherObject.prototype);
86 86
87 o = Realm.eval(realmIndex, "new f()"); 87 o = Realm.eval(realmIndex, "new f()");
88 proto = Object.getPrototypeOf(o); 88 proto = Object.getPrototypeOf(o);
89 assertFalse(proto === Object.prototype); 89 assertFalse(proto === Object.prototype);
90 assertTrue(proto === otherObject.prototype); 90 assertTrue(proto === otherObject.prototype);
91
92
93 // Check function constructor.
94 var ctor_script = "Function.constructor";
95 var ctor_a_script =
96 "(function() { return Function.constructor.apply(this, ['return 1;']); })";
97 var ctor_b_script = "Function.constructor.bind(this, 'return 1;')";
98 var ctor_c_script =
99 "(function() { return Function.constructor.call(this, 'return 1;'); })";
100 Realm.shared = {
101 ctor_0 : Realm.eval(realms[0], ctor_script),
102 ctor_1 : Realm.eval(realms[1], ctor_script),
103 ctor_a_0 : Realm.eval(realms[0], ctor_a_script),
104 ctor_a_1 : Realm.eval(realms[1], ctor_a_script),
105 ctor_b_0 : Realm.eval(realms[0], ctor_b_script),
106 ctor_b_1 : Realm.eval(realms[1], ctor_b_script),
107 ctor_c_0 : Realm.eval(realms[0], ctor_c_script),
108 ctor_c_1 : Realm.eval(realms[1], ctor_c_script),
109 }
110 var script_0 = " \
111 var ctor_0 = Realm.shared.ctor_0; \
112 Realm.shared.direct_0 = ctor_0('return 1'); \
113 Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \
114 Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \
115 Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \
116 Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \
117 Realm.shared.a_0 = Realm.shared.ctor_a_0(); \
118 Realm.shared.b_0 = Realm.shared.ctor_b_0(); \
119 Realm.shared.c_0 = Realm.shared.ctor_c_0(); \
120 ";
121 script = script_0 + script_0.replace(/_0/g, "_1");
122 Realm.eval(realms[0], script);
123 assertSame(1, Realm.shared.direct_0());
124 assertSame(1, Realm.shared.indirect_0());
125 assertSame(1, Realm.shared.apply_0());
126 assertSame(1, Realm.shared.bind_0());
127 assertSame(1, Realm.shared.call_0());
128 assertSame(1, Realm.shared.a_0());
129 assertSame(1, Realm.shared.b_0());
130 assertSame(1, Realm.shared.c_0());
131 assertSame(undefined, Realm.shared.direct_1);
132 assertSame(undefined, Realm.shared.indirect_1);
133 assertSame(undefined, Realm.shared.apply_1);
134 assertSame(undefined, Realm.shared.bind_1);
135 assertSame(undefined, Realm.shared.call_1);
136 assertSame(1, Realm.shared.a_1());
137 assertSame(undefined, Realm.shared.b_1);
138 assertSame(1, Realm.shared.c_1());
139 Realm.eval(realms[1], script);
140 assertSame(undefined, Realm.shared.direct_0);
141 assertSame(undefined, Realm.shared.indirect_0);
142 assertSame(undefined, Realm.shared.apply_0);
143 assertSame(undefined, Realm.shared.bind_0);
144 assertSame(undefined, Realm.shared.call_0);
145 assertSame(1, Realm.shared.a_0());
146 assertSame(undefined, Realm.shared.b_0);
147 assertSame(1, Realm.shared.c_1());
148 assertSame(1, Realm.shared.direct_1());
149 assertSame(1, Realm.shared.indirect_1());
150 assertSame(1, Realm.shared.apply_1());
151 assertSame(1, Realm.shared.bind_1());
152 assertSame(1, Realm.shared.call_1());
153 assertSame(1, Realm.shared.a_1());
154 assertSame(1, Realm.shared.b_1());
155 assertSame(1, Realm.shared.c_1());
OLDNEW
« no previous file with comments | « test/cctest/test-api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698