OLD | NEW |
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 15 matching lines...) Expand all Loading... |
26 } \ | 26 } \ |
27 "; | 27 "; |
28 | 28 |
29 function assertNotIn(thrower, error) { | 29 function assertNotIn(thrower, error) { |
30 for (var i = 0; i < error.length; i++) { | 30 for (var i = 0; i < error.length; i++) { |
31 assertFalse(false === error[i].getFunction()); | 31 assertFalse(false === error[i].getFunction()); |
32 } | 32 } |
33 } | 33 } |
34 | 34 |
35 Realm.eval(realms[1], script); | 35 Realm.eval(realms[1], script); |
36 assertSame(2, Realm.shared.error_0.length); | 36 assertSame(3, Realm.shared.error_0.length); |
37 assertSame(3, Realm.shared.error_1.length); | 37 assertSame(4, Realm.shared.error_1.length); |
38 | 38 |
39 assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[1].getFunction()); | 39 assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[2].getFunction()); |
40 assertNotIn(Realm.shared.thrower_0, Realm.shared.error_0); | 40 assertNotIn(Realm.shared.thrower_0, Realm.shared.error_0); |
41 assertNotIn(Realm.shared.thrower_0, Realm.shared.error_1); | 41 assertNotIn(Realm.shared.thrower_0, Realm.shared.error_1); |
42 | 42 |
43 Realm.eval(realms[0], script); | 43 Realm.eval(realms[0], script); |
44 assertSame(4, Realm.shared.error_0.length); | 44 assertSame(5, Realm.shared.error_0.length); |
45 assertSame(3, Realm.shared.error_1.length); | 45 assertSame(4, Realm.shared.error_1.length); |
46 | 46 |
47 assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[1].getFunction()); | 47 assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[2].getFunction()); |
48 assertNotIn(Realm.shared.thrower_1, Realm.shared.error_0); | 48 assertNotIn(Realm.shared.thrower_1, Realm.shared.error_0); |
49 assertNotIn(Realm.shared.thrower_1, Realm.shared.error_1); | 49 assertNotIn(Realm.shared.thrower_1, Realm.shared.error_1); |
50 | 50 |
51 | 51 |
52 // Check .caller filtering across security contexts. | 52 // Check .caller filtering across security contexts. |
53 var caller_script = "(function (f) { f(); })"; | 53 var caller_script = "(function (f) { f(); })"; |
54 Realm.shared = { | 54 Realm.shared = { |
55 caller_0 : Realm.eval(realms[0], caller_script), | 55 caller_0 : Realm.eval(realms[0], caller_script), |
56 caller_1 : Realm.eval(realms[1], caller_script), | 56 caller_1 : Realm.eval(realms[1], caller_script), |
57 } | 57 } |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 assertSame(1, Realm.shared.direct_1()); | 155 assertSame(1, Realm.shared.direct_1()); |
156 assertSame(1, Realm.shared.indirect_1()); | 156 assertSame(1, Realm.shared.indirect_1()); |
157 assertSame(1, Realm.shared.apply_1()); | 157 assertSame(1, Realm.shared.apply_1()); |
158 assertSame(1, Realm.shared.bind_1()); | 158 assertSame(1, Realm.shared.bind_1()); |
159 assertSame(1, Realm.shared.call_1()); | 159 assertSame(1, Realm.shared.call_1()); |
160 assertSame(1, Realm.shared.proxy_1()); | 160 assertSame(1, Realm.shared.proxy_1()); |
161 assertSame(1, Realm.shared.reflect_1()); | 161 assertSame(1, Realm.shared.reflect_1()); |
162 assertSame(1, Realm.shared.a_1()); | 162 assertSame(1, Realm.shared.a_1()); |
163 assertSame(1, Realm.shared.b_1()); | 163 assertSame(1, Realm.shared.b_1()); |
164 assertSame(1, Realm.shared.c_1()); | 164 assertSame(1, Realm.shared.c_1()); |
OLD | NEW |