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

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

Issue 294073002: filter cross context eval (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 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 | Annotate | Revision Log
« 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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 Realm.shared.caller_1(f_1); \ 63 Realm.shared.caller_1(f_1); \
64 "; 64 ";
65 65
66 Realm.eval(realms[1], script); 66 Realm.eval(realms[1], script);
67 assertSame(null, Realm.shared.result_0); 67 assertSame(null, Realm.shared.result_0);
68 assertSame(Realm.shared.caller_1, Realm.shared.result_1); 68 assertSame(Realm.shared.caller_1, Realm.shared.result_1);
69 69
70 Realm.eval(realms[0], script); 70 Realm.eval(realms[0], script);
71 assertSame(Realm.shared.caller_0, Realm.shared.result_0); 71 assertSame(Realm.shared.caller_0, Realm.shared.result_0);
72 assertSame(null, Realm.shared.result_1); 72 assertSame(null, Realm.shared.result_1);
73
74
75 // Check function constructor.
76 var ctor_script = "Function.constructor";
77 var ctor_a_script =
78 "(function() { return Function.constructor.apply(this, ['return 1;']); })";
79 var ctor_b_script = "Function.constructor.bind(this, 'return 1;')";
80 var ctor_c_script =
81 "(function() { return Function.constructor.call(this, 'return 1;'); })";
82 Realm.shared = {
83 ctor_0 : Realm.eval(realms[0], ctor_script),
84 ctor_1 : Realm.eval(realms[1], ctor_script),
85 ctor_a_0 : Realm.eval(realms[0], ctor_a_script),
86 ctor_a_1 : Realm.eval(realms[1], ctor_a_script),
87 ctor_b_0 : Realm.eval(realms[0], ctor_b_script),
88 ctor_b_1 : Realm.eval(realms[1], ctor_b_script),
89 ctor_c_0 : Realm.eval(realms[0], ctor_c_script),
90 ctor_c_1 : Realm.eval(realms[1], ctor_c_script),
91 }
92
93 var script_0 = " \
94 var ctor_0 = Realm.shared.ctor_0; \
95 Realm.shared.direct_0 = ctor_0('return 1'); \
96 Realm.shared.indirect_0 = (function() { return ctor_0('return 1;'); })(); \
97 Realm.shared.apply_0 = ctor_0.apply(this, ['return 1']); \
98 Realm.shared.bind_0 = ctor_0.bind(this, 'return 1')(); \
99 Realm.shared.call_0 = ctor_0.call(this, 'return 1'); \
100 Realm.shared.a_0 = Realm.shared.ctor_a_0(); \
101 Realm.shared.b_0 = Realm.shared.ctor_b_0(); \
102 Realm.shared.c_0 = Realm.shared.ctor_c_0(); \
103 ";
104
105 script = script_0 + script_0.replace(/_0/g, "_1");
106
107 Realm.eval(realms[0], script);
108 assertSame(1, Realm.shared.direct_0());
109 assertSame(1, Realm.shared.indirect_0());
110 assertSame(1, Realm.shared.apply_0());
111 assertSame(1, Realm.shared.bind_0());
112 assertSame(1, Realm.shared.call_0());
113 assertSame(1, Realm.shared.a_0());
114 assertSame(1, Realm.shared.b_0());
115 assertSame(1, Realm.shared.c_0());
116 assertSame(undefined, Realm.shared.direct_1);
117 assertSame(undefined, Realm.shared.indirect_1);
118 assertSame(undefined, Realm.shared.apply_1);
119 assertSame(undefined, Realm.shared.bind_1);
120 assertSame(undefined, Realm.shared.call_1);
121 assertSame(1, Realm.shared.a_1());
122 assertSame(undefined, Realm.shared.b_1);
123 assertSame(1, Realm.shared.c_1());
124
125 Realm.eval(realms[1], script);
126 assertSame(undefined, Realm.shared.direct_0);
127 assertSame(undefined, Realm.shared.indirect_0);
128 assertSame(undefined, Realm.shared.apply_0);
129 assertSame(undefined, Realm.shared.bind_0);
130 assertSame(undefined, Realm.shared.call_0);
131 assertSame(1, Realm.shared.a_0());
132 assertSame(undefined, Realm.shared.b_0);
133 assertSame(1, Realm.shared.c_1());
134 assertSame(1, Realm.shared.direct_1());
135 assertSame(1, Realm.shared.indirect_1());
136 assertSame(1, Realm.shared.apply_1());
137 assertSame(1, Realm.shared.bind_1());
138 assertSame(1, Realm.shared.call_1());
139 assertSame(1, Realm.shared.a_1());
140 assertSame(1, Realm.shared.b_1());
141 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