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

Side by Side Diff: test/mjsunit/harmony/object-observe.js

Issue 11338048: Handle Object.observe notifications for setting Array.length (Closed) Base URL: git@github.com:rafaelw/v8@master
Patch Set: Clarify test todo 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
« 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // TODO(observe): oldValue should not be present below. 326 // TODO(observe): oldValue should not be present below.
327 { object: obj, name: "1", type: "deleted", oldValue: undefined }, 327 { object: obj, name: "1", type: "deleted", oldValue: undefined },
328 { object: obj, name: "1", type: "new" }, 328 { object: obj, name: "1", type: "new" },
329 // TODO(observe): oldValue should be absent below, and type = "reconfigured". 329 // TODO(observe): oldValue should be absent below, and type = "reconfigured".
330 { object: obj, name: "1", type: "updated", oldValue: undefined }, 330 { object: obj, name: "1", type: "updated", oldValue: undefined },
331 { object: obj, name: "1", type: "updated", oldValue: 9 }, 331 { object: obj, name: "1", type: "updated", oldValue: 9 },
332 { object: obj, name: "1", type: "deleted", oldValue: 10 }, 332 { object: obj, name: "1", type: "deleted", oldValue: 10 },
333 { object: obj, name: "1", type: "new" }, 333 { object: obj, name: "1", type: "new" },
334 ]); 334 ]);
335 335
336 // Observing array length (including truncation)
337 reset();
338 var arr = ['a', 'b', 'c', 'd'];
339 var arr2 = ['alpha', 'beta'];
340 var arr3 = ['hello'];
341 // TODO(adamk): Enable this test case when it can run in a reasonable
342 // amount of time.
343 //var slow_arr = new Array(1000000000);
344 //slow_arr[500000000] = 'hello';
345 Object.defineProperty(arr, '0', {configurable: false});
346 Object.defineProperty(arr, '2', {get: function(){}});
347 Object.defineProperty(arr2, '0', {get: function(){}, configurable: false});
348 Object.observe(arr, observer.callback);
349 Object.observe(arr2, observer.callback);
350 Object.observe(arr3, observer.callback);
351 arr.length = 2;
352 arr.length = 0;
353 arr.length = 10;
354 arr2.length = 0;
355 arr2.length = 1; // no change expected
356 arr3.length = 0;
357 Object.deliverChangeRecords(observer.callback);
358 observer.assertCallbackRecords([
359 { object: arr, name: '3', type: 'deleted', oldValue: 'd' },
360 // TODO(adamk): oldValue should not be present below
361 { object: arr, name: '2', type: 'deleted', oldValue: undefined },
362 { object: arr, name: 'length', type: 'updated', oldValue: 4 },
363 { object: arr, name: '1', type: 'deleted', oldValue: 'b' },
364 { object: arr, name: 'length', type: 'updated', oldValue: 2 },
365 { object: arr, name: 'length', type: 'updated', oldValue: 1 },
366 { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' },
367 { object: arr2, name: 'length', type: 'updated', oldValue: 2 },
368 { object: arr3, name: '0', type: 'deleted', oldValue: 'hello' },
369 { object: arr3, name: 'length', type: 'updated', oldValue: 1 },
370 ]);
336 371
337 // Assignments in loops (checking different IC states). 372 // Assignments in loops (checking different IC states).
338 reset(); 373 reset();
339 var obj = {}; 374 var obj = {};
340 Object.observe(obj, observer.callback); 375 Object.observe(obj, observer.callback);
341 for (var i = 0; i < 5; i++) { 376 for (var i = 0; i < 5; i++) {
342 obj["a" + i] = i; 377 obj["a" + i] = i;
343 } 378 }
344 Object.deliverChangeRecords(observer.callback); 379 Object.deliverChangeRecords(observer.callback);
345 observer.assertCallbackRecords([ 380 observer.assertCallbackRecords([
(...skipping 11 matching lines...) Expand all
357 obj[i] = i; 392 obj[i] = i;
358 } 393 }
359 Object.deliverChangeRecords(observer.callback); 394 Object.deliverChangeRecords(observer.callback);
360 observer.assertCallbackRecords([ 395 observer.assertCallbackRecords([
361 { object: obj, name: "0", type: "new" }, 396 { object: obj, name: "0", type: "new" },
362 { object: obj, name: "1", type: "new" }, 397 { object: obj, name: "1", type: "new" },
363 { object: obj, name: "2", type: "new" }, 398 { object: obj, name: "2", type: "new" },
364 { object: obj, name: "3", type: "new" }, 399 { object: obj, name: "3", type: "new" },
365 { object: obj, name: "4", type: "new" }, 400 { object: obj, name: "4", type: "new" },
366 ]); 401 ]);
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