| 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(3, Realm.shared.error_0.length); | 36 assertSame(2, Realm.shared.error_0.length); |
| 37 assertSame(4, Realm.shared.error_1.length); | 37 assertSame(3, Realm.shared.error_1.length); |
| 38 | 38 |
| 39 assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[2].getFunction()); | 39 assertTrue(Realm.shared.thrower_1 === Realm.shared.error_1[1].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(5, Realm.shared.error_0.length); | 44 assertSame(4, Realm.shared.error_0.length); |
| 45 assertSame(4, Realm.shared.error_1.length); | 45 assertSame(3, Realm.shared.error_1.length); |
| 46 | 46 |
| 47 assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[2].getFunction()); | 47 assertTrue(Realm.shared.thrower_0 === Realm.shared.error_0[1].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 23 matching lines...) Expand all Loading... |
| 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); |
| OLD | NEW |