Index: test/mjsunit/harmony/object-observe.js |
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js |
index 4f068424b376831e503cab92bfe510b7a96c21fe..26da547f7c7d9854e67de072c5f794edffa2b67f 100644 |
--- a/test/mjsunit/harmony/object-observe.js |
+++ b/test/mjsunit/harmony/object-observe.js |
@@ -333,6 +333,32 @@ observer.assertCallbackRecords([ |
{ object: obj, name: "1", type: "new" }, |
]); |
+// Observing array length (including truncation) |
+reset(); |
+var arr = ['a', 'b', 'c', 'd']; |
+var arr2 = ['alpha', 'beta']; |
+Object.defineProperty(arr, '0', {configurable: false}); |
+Object.defineProperty(arr, '2', {get: function(){}}); |
+Object.defineProperty(arr2, '0', {get: function(){}, configurable: false}); |
+Object.observe(arr, observer.callback); |
+Object.observe(arr2, observer.callback); |
+arr.length = 2; |
+arr.length = 0; |
+arr.length = 10; |
+arr2.length = 0; |
+arr2.length = 1; // no change expected |
+Object.deliverChangeRecords(observer.callback); |
+observer.assertCallbackRecords([ |
+ { object: arr, name: '3', type: 'deleted', oldValue: 'd' }, |
+ // TODO(adamk): oldValue should not be present below |
+ { object: arr, name: '2', type: 'deleted', oldValue: undefined }, |
+ { object: arr, name: 'length', type: 'updated', oldValue: 4 }, |
+ { object: arr, name: '1', type: 'deleted', oldValue: 'b' }, |
+ { object: arr, name: 'length', type: 'updated', oldValue: 2 }, |
+ { object: arr, name: 'length', type: 'updated', oldValue: 1 }, |
+ { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' }, |
+ { object: arr2, name: 'length', type: 'updated', oldValue: 2 }, |
+]); |
// Assignments in loops (checking different IC states). |
reset(); |