OLD | NEW |
(Empty) | |
| 1 // Copyright 2016 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 b = { toString: function() { return "b"; } }; |
| 6 var c = { toString: function() { return "c"; } }; |
| 7 |
| 8 (function() { |
| 9 var expected_receiver; |
| 10 var obj1 = { |
| 11 a: 100, |
| 12 b_: 200, |
| 13 get b() { assertEquals(expected_receiver, this); return this.b_; }, |
| 14 set b(v) { assertEquals(expected_receiver, this); this.b_ = v; }, |
| 15 c_: 300, |
| 16 get c() { assertEquals(expected_receiver, this); return this.c_; }, |
| 17 set c(v) { assertEquals(expected_receiver, this); this.c_ = v; }, |
| 18 }; |
| 19 var obj2 = { |
| 20 boom() { |
| 21 super.a++; |
| 22 super[b]++; |
| 23 super[c]++; |
| 24 }, |
| 25 } |
| 26 Object.setPrototypeOf(obj2, obj1); |
| 27 |
| 28 expected_receiver = obj2; |
| 29 obj2.boom(); |
| 30 assertEquals(101, obj2.a); |
| 31 assertEquals(201, obj2[b]); |
| 32 assertEquals(301, obj2[c]); |
| 33 |
| 34 expected_receiver = obj1; |
| 35 assertEquals(100, obj1.a); |
| 36 assertEquals(200, obj1[b]); |
| 37 assertEquals(300, obj1[c]); |
| 38 }()); |
OLD | NEW |