| 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 // |
| 5 // Flags: --harmony-object-observe |
| 4 | 6 |
| 5 var records; | 7 var records; |
| 6 function observer(r) { | 8 function observer(r) { |
| 7 records = r; | 9 records = r; |
| 8 } | 10 } |
| 9 | 11 |
| 10 Object.defineProperty(Array.prototype, '0', { | 12 Object.defineProperty(Array.prototype, '0', { |
| 11 get: function() { return 0; }, | 13 get: function() { return 0; }, |
| 12 set: function() { throw "boom!"; } | 14 set: function() { throw "boom!"; } |
| 13 }); | 15 }); |
| 14 arr = [1, 2]; | 16 arr = [1, 2]; |
| 15 Array.observe(arr, observer); | 17 Array.observe(arr, observer); |
| 16 arr.length = 0; | 18 arr.length = 0; |
| 17 assertEquals(0, arr.length); | 19 assertEquals(0, arr.length); |
| 18 | 20 |
| 19 Object.deliverChangeRecords(observer); | 21 Object.deliverChangeRecords(observer); |
| 20 assertEquals(1, records.length); | 22 assertEquals(1, records.length); |
| 21 assertEquals('splice', records[0].type); | 23 assertEquals('splice', records[0].type); |
| 22 assertArrayEquals([1, 2], records[0].removed); | 24 assertArrayEquals([1, 2], records[0].removed); |
| OLD | NEW |