OLD | NEW |
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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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) | 336 // Observing array length (including truncation) |
337 reset(); | 337 reset(); |
338 var arr = ['a', 'b', 'c', 'd']; | 338 var arr = ['a', 'b', 'c', 'd']; |
339 var arr2 = ['alpha', 'beta']; | 339 var arr2 = ['alpha', 'beta']; |
340 var arr3 = ['hello']; | 340 var arr3 = ['hello']; |
| 341 arr3[2] = 'goodbye'; |
| 342 arr3.length = 6; |
341 // TODO(adamk): Enable this test case when it can run in a reasonable | 343 // TODO(adamk): Enable this test case when it can run in a reasonable |
342 // amount of time. | 344 // amount of time. |
343 //var slow_arr = new Array(1000000000); | 345 //var slow_arr = new Array(1000000000); |
344 //slow_arr[500000000] = 'hello'; | 346 //slow_arr[500000000] = 'hello'; |
345 Object.defineProperty(arr, '0', {configurable: false}); | 347 Object.defineProperty(arr, '0', {configurable: false}); |
346 Object.defineProperty(arr, '2', {get: function(){}}); | 348 Object.defineProperty(arr, '2', {get: function(){}}); |
347 Object.defineProperty(arr2, '0', {get: function(){}, configurable: false}); | 349 Object.defineProperty(arr2, '0', {get: function(){}, configurable: false}); |
348 Object.observe(arr, observer.callback); | 350 Object.observe(arr, observer.callback); |
349 Object.observe(arr2, observer.callback); | 351 Object.observe(arr2, observer.callback); |
350 Object.observe(arr3, observer.callback); | 352 Object.observe(arr3, observer.callback); |
351 arr.length = 2; | 353 arr.length = 2; |
352 arr.length = 0; | 354 arr.length = 0; |
353 arr.length = 10; | 355 arr.length = 10; |
354 arr2.length = 0; | 356 arr2.length = 0; |
355 arr2.length = 1; // no change expected | 357 arr2.length = 1; // no change expected |
356 arr3.length = 0; | 358 arr3.length = 0; |
| 359 Object.defineProperty(arr3, 'length', {value: 5}); |
| 360 Object.defineProperty(arr3, 'length', {value: 10, writable: false}); |
357 Object.deliverChangeRecords(observer.callback); | 361 Object.deliverChangeRecords(observer.callback); |
| 362 observer.records.forEach(function(r){print(JSON.stringify(r))}); |
358 observer.assertCallbackRecords([ | 363 observer.assertCallbackRecords([ |
359 { object: arr, name: '3', type: 'deleted', oldValue: 'd' }, | 364 { object: arr, name: '3', type: 'deleted', oldValue: 'd' }, |
360 // TODO(adamk): oldValue should not be present below | 365 // TODO(adamk): oldValue should not be present below |
361 { object: arr, name: '2', type: 'deleted', oldValue: undefined }, | 366 { object: arr, name: '2', type: 'deleted', oldValue: undefined }, |
362 { object: arr, name: 'length', type: 'updated', oldValue: 4 }, | 367 { object: arr, name: 'length', type: 'updated', oldValue: 4 }, |
363 { object: arr, name: '1', type: 'deleted', oldValue: 'b' }, | 368 { object: arr, name: '1', type: 'deleted', oldValue: 'b' }, |
364 { object: arr, name: 'length', type: 'updated', oldValue: 2 }, | 369 { object: arr, name: 'length', type: 'updated', oldValue: 2 }, |
365 { object: arr, name: 'length', type: 'updated', oldValue: 1 }, | 370 { object: arr, name: 'length', type: 'updated', oldValue: 1 }, |
366 { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' }, | 371 { object: arr2, name: '1', type: 'deleted', oldValue: 'beta' }, |
367 { object: arr2, name: 'length', type: 'updated', oldValue: 2 }, | 372 { object: arr2, name: 'length', type: 'updated', oldValue: 2 }, |
| 373 { object: arr3, name: '2', type: 'deleted', oldValue: 'goodbye' }, |
368 { object: arr3, name: '0', type: 'deleted', oldValue: 'hello' }, | 374 { object: arr3, name: '0', type: 'deleted', oldValue: 'hello' }, |
369 { object: arr3, name: 'length', type: 'updated', oldValue: 1 }, | 375 { object: arr3, name: 'length', type: 'updated', oldValue: 6 }, |
| 376 { object: arr3, name: 'length', type: 'updated', oldValue: 0 }, |
| 377 { object: arr3, name: 'length', type: 'updated', oldValue: 5 }, |
| 378 // TODO(adamk): This record should be merged with the above |
| 379 { object: arr3, name: 'length', type: 'reconfigured' }, |
370 ]); | 380 ]); |
371 | 381 |
372 // Assignments in loops (checking different IC states). | 382 // Assignments in loops (checking different IC states). |
373 reset(); | 383 reset(); |
374 var obj = {}; | 384 var obj = {}; |
375 Object.observe(obj, observer.callback); | 385 Object.observe(obj, observer.callback); |
376 for (var i = 0; i < 5; i++) { | 386 for (var i = 0; i < 5; i++) { |
377 obj["a" + i] = i; | 387 obj["a" + i] = i; |
378 } | 388 } |
379 Object.deliverChangeRecords(observer.callback); | 389 Object.deliverChangeRecords(observer.callback); |
(...skipping 12 matching lines...) Expand all Loading... |
392 obj[i] = i; | 402 obj[i] = i; |
393 } | 403 } |
394 Object.deliverChangeRecords(observer.callback); | 404 Object.deliverChangeRecords(observer.callback); |
395 observer.assertCallbackRecords([ | 405 observer.assertCallbackRecords([ |
396 { object: obj, name: "0", type: "new" }, | 406 { object: obj, name: "0", type: "new" }, |
397 { object: obj, name: "1", type: "new" }, | 407 { object: obj, name: "1", type: "new" }, |
398 { object: obj, name: "2", type: "new" }, | 408 { object: obj, name: "2", type: "new" }, |
399 { object: obj, name: "3", type: "new" }, | 409 { object: obj, name: "3", type: "new" }, |
400 { object: obj, name: "4", type: "new" }, | 410 { object: obj, name: "4", type: "new" }, |
401 ]); | 411 ]); |
OLD | NEW |