OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 var realms = [Realm.current(), Realm.create()]; |
| 6 |
| 7 function throw_in_current() { Realm.eval(Realm.current(), "throw Error()"); }; |
| 8 |
| 9 Realm.shared = { |
| 10 throw_in_current: throw_in_current, |
| 11 thrower_0: (function thrower_0() { Realm.shared.throw_in_current(); }), |
| 12 thrower_1: Realm.eval(realms[1], |
| 13 "(function thrower_1() { Realm.shared.throw_in_current(); })"), |
| 14 }; |
| 15 |
| 16 var script = |
| 17 "Error.prepareStackTrace = function(a, b) { return b; }; \ |
| 18 try { \ |
| 19 Realm.shared.thrower_0(); \ |
| 20 } catch (e) { \ |
| 21 Realm.shared.error_0 = e.stack; \ |
| 22 } \ |
| 23 try { \ |
| 24 Realm.shared.thrower_1(); \ |
| 25 } catch (e) { \ |
| 26 Realm.shared.error_1 = e.stack; \ |
| 27 }" |
| 28 |
| 29 Realm.eval(realms[1], script); |
| 30 assertSame(3, Realm.shared.error_0.length); |
| 31 assertSame(4, Realm.shared.error_1.length); |
| 32 |
| 33 assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[2].getFunction()); |
| 34 for (var i = 0; i < Realm.shared.error_0.length; i++) { |
| 35 assertFalse(Realm.shared.thrower_0 === Realm.shared.error_0[i].getFunction()); |
| 36 } |
| 37 for (var i = 0; i < Realm.shared.error_1.length; i++) { |
| 38 assertFalse(Realm.shared.thrower_0 === Realm.shared.error_1[i].getFunction()); |
| 39 } |
| 40 |
| 41 Realm.eval(realms[0], script); |
| 42 assertSame(6, Realm.shared.error_0.length); |
| 43 assertSame(5, Realm.shared.error_1.length); |
| 44 |
| 45 assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[3].getFunction()); |
| 46 for (var i = 0; i < Realm.shared.error_0.length; i++) { |
| 47 assertFalse(Realm.shared.thrower_1 === Realm.shared.error_0[i].getFunction()); |
| 48 } |
| 49 for (var i = 0; i < Realm.shared.error_1.length; i++) { |
| 50 assertFalse(Realm.shared.thrower_1 === Realm.shared.error_1[i].getFunction()); |
| 51 } |
OLD | NEW |