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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 // test that do not pollute / leak a function prototype v8/4217 |
| 76 var realmIndex = Realm.create(); |
| 77 var otherObject = Realm.eval(realmIndex, "Object"); |
| 78 |
| 79 var f = Realm.eval(realmIndex, "function f(){}; f"); |
| 80 f.prototype = null; |
| 81 |
| 82 var o = new f(); |
| 83 var proto = Object.getPrototypeOf(o); |
| 84 assertFalse(proto === Object.prototype); |
| 85 assertTrue(proto === otherObject.prototype); |
| 86 |
| 87 o = Realm.eval(realmIndex, "new f()"); |
| 88 proto = Object.getPrototypeOf(o); |
| 89 assertFalse(proto === Object.prototype); |
| 90 assertTrue(proto === otherObject.prototype); |
OLD | NEW |