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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 obj[i] = i; 392 obj[i] = i;
393 } 393 }
394 Object.deliverChangeRecords(observer.callback); 394 Object.deliverChangeRecords(observer.callback);
395 observer.assertCallbackRecords([ 395 observer.assertCallbackRecords([
396 { object: obj, name: "0", type: "new" }, 396 { object: obj, name: "0", type: "new" },
397 { object: obj, name: "1", type: "new" }, 397 { object: obj, name: "1", type: "new" },
398 { object: obj, name: "2", type: "new" }, 398 { object: obj, name: "2", type: "new" },
399 { object: obj, name: "3", type: "new" }, 399 { object: obj, name: "3", type: "new" },
400 { object: obj, name: "4", type: "new" }, 400 { object: obj, name: "4", type: "new" },
401 ]); 401 ]);
402
403 // Adding elements past the end of an array should notify on length
404 reset();
405 var arr = [1, 2, 3];
406 Object.observe(arr, observer.callback);
407 arr[3] = 10;
408 arr[100] = 20;
409 Object.defineProperty(arr, '200', {value: 7});
410 Object.defineProperty(arr, '400', {get: function(){}});
411 arr[50] = 30; // no length change expected
412 Object.deliverChangeRecords(observer.callback);
413 observer.assertCallbackRecords([
414 { object: arr, name: '3', type: 'new' },
415 { object: arr, name: 'length', type: 'updated', oldValue: 3 },
416 { object: arr, name: '100', type: 'new' },
417 { object: arr, name: 'length', type: 'updated', oldValue: 4 },
418 { object: arr, name: '200', type: 'new' },
419 { object: arr, name: 'length', type: 'updated', oldValue: 101 },
420 { object: arr, name: '400', type: 'new' },
421 { object: arr, name: 'length', type: 'updated', oldValue: 201 },
422 { object: arr, name: '50', type: 'new' },
423 ]);
OLDNEW
« 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