Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Unified Diff: test/mjsunit/harmony/object-observe.js

Issue 11369135: Object.observe: notify when element addition causes array growth (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: After review Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/object-observe.js
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js
index 231fe91e18594797c5519eec6fbc9f2b839998ef..2576e45e4c6e8dea2d1977e61b0eadc7af7f6838 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -399,3 +399,25 @@ observer.assertCallbackRecords([
{ object: obj, name: "3", type: "new" },
{ object: obj, name: "4", type: "new" },
]);
+
+// Adding elements past the end of an array should notify on length
+reset();
+var arr = [1, 2, 3];
+Object.observe(arr, observer.callback);
+arr[3] = 10;
+arr[100] = 20;
+Object.defineProperty(arr, '200', {value: 7});
+Object.defineProperty(arr, '400', {get: function(){}});
+arr[50] = 30; // no length change expected
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: arr, name: '3', type: 'new' },
+ { object: arr, name: 'length', type: 'updated', oldValue: 3 },
+ { object: arr, name: '100', type: 'new' },
+ { object: arr, name: 'length', type: 'updated', oldValue: 4 },
+ { object: arr, name: '200', type: 'new' },
+ { object: arr, name: 'length', type: 'updated', oldValue: 101 },
+ { object: arr, name: '400', type: 'new' },
+ { object: arr, name: 'length', type: 'updated', oldValue: 201 },
+ { object: arr, name: '50', type: 'new' },
+]);
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698