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 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 obj[''] = ''; | 293 obj[''] = ''; |
294 obj[''] = ' '; | 294 obj[''] = ' '; |
295 delete obj['']; | 295 delete obj['']; |
296 Object.deliverChangeRecords(observer.callback); | 296 Object.deliverChangeRecords(observer.callback); |
297 observer.assertCallbackRecords([ | 297 observer.assertCallbackRecords([ |
298 { object: obj, type: 'new', name: '' }, | 298 { object: obj, type: 'new', name: '' }, |
299 { object: obj, type: 'updated', name: '', oldValue: '' }, | 299 { object: obj, type: 'updated', name: '', oldValue: '' }, |
300 { object: obj, type: 'deleted', name: '', oldValue: ' ' }, | 300 { object: obj, type: 'deleted', name: '', oldValue: ' ' }, |
301 ]); | 301 ]); |
302 | 302 |
| 303 // Object.preventExtensions |
| 304 reset(); |
| 305 var obj = { foo: 'bar'}; |
| 306 Object.observe(obj, observer.callback); |
| 307 obj.baz = 'bat'; |
| 308 Object.preventExtensions(obj); |
| 309 |
| 310 Object.deliverChangeRecords(observer.callback); |
| 311 observer.assertCallbackRecords([ |
| 312 { object: obj, type: 'new', name: 'baz' }, |
| 313 { object: obj, type: 'preventExtensions' }, |
| 314 ]); |
| 315 |
| 316 reset(); |
| 317 var obj = { foo: 'bar'}; |
| 318 Object.preventExtensions(obj); |
| 319 Object.observe(obj, observer.callback); |
| 320 Object.preventExtensions(obj); |
| 321 Object.deliverChangeRecords(observer.callback); |
| 322 observer.assertNotCalled(); |
| 323 |
| 324 // Object.freeze |
| 325 reset(); |
| 326 var obj = { a: 'a' }; |
| 327 Object.defineProperty(obj, 'b', { |
| 328 writable: false, |
| 329 configurable: true, |
| 330 value: 'b' |
| 331 }); |
| 332 Object.defineProperty(obj, 'c', { |
| 333 writable: true, |
| 334 configurable: false, |
| 335 value: 'c' |
| 336 }); |
| 337 Object.defineProperty(obj, 'd', { |
| 338 writable: false, |
| 339 configurable: false, |
| 340 value: 'd' |
| 341 }); |
| 342 Object.observe(obj, observer.callback); |
| 343 Object.freeze(obj); |
| 344 |
| 345 Object.deliverChangeRecords(observer.callback); |
| 346 observer.assertCallbackRecords([ |
| 347 { object: obj, type: 'reconfigured', name: 'a' }, |
| 348 { object: obj, type: 'reconfigured', name: 'b' }, |
| 349 { object: obj, type: 'reconfigured', name: 'c' }, |
| 350 { object: obj, type: 'preventExtensions' }, |
| 351 ]); |
| 352 |
| 353 reset(); |
| 354 var obj = { foo: 'bar'}; |
| 355 Object.freeze(obj); |
| 356 Object.observe(obj, observer.callback); |
| 357 Object.freeze(obj); |
| 358 Object.deliverChangeRecords(observer.callback); |
| 359 observer.assertNotCalled(); |
| 360 |
| 361 // Object.seal |
| 362 reset(); |
| 363 var obj = { a: 'a' }; |
| 364 Object.defineProperty(obj, 'b', { |
| 365 writable: false, |
| 366 configurable: true, |
| 367 value: 'b' |
| 368 }); |
| 369 Object.defineProperty(obj, 'c', { |
| 370 writable: true, |
| 371 configurable: false, |
| 372 value: 'c' |
| 373 }); |
| 374 Object.defineProperty(obj, 'd', { |
| 375 writable: false, |
| 376 configurable: false, |
| 377 value: 'd' |
| 378 }); |
| 379 Object.observe(obj, observer.callback); |
| 380 Object.seal(obj); |
| 381 |
| 382 Object.deliverChangeRecords(observer.callback); |
| 383 observer.assertCallbackRecords([ |
| 384 { object: obj, type: 'reconfigured', name: 'a' }, |
| 385 { object: obj, type: 'reconfigured', name: 'b' }, |
| 386 { object: obj, type: 'preventExtensions' }, |
| 387 ]); |
| 388 |
| 389 reset(); |
| 390 var obj = { foo: 'bar'}; |
| 391 Object.seal(obj); |
| 392 Object.observe(obj, observer.callback); |
| 393 Object.seal(obj); |
| 394 Object.deliverChangeRecords(observer.callback); |
| 395 observer.assertNotCalled(); |
| 396 |
303 // Observing a continuous stream of changes, while itermittantly unobserving. | 397 // Observing a continuous stream of changes, while itermittantly unobserving. |
304 reset(); | 398 reset(); |
| 399 var obj = {}; |
305 Object.observe(obj, observer.callback); | 400 Object.observe(obj, observer.callback); |
306 Object.getNotifier(obj).notify({ | 401 Object.getNotifier(obj).notify({ |
307 type: 'updated', | 402 type: 'updated', |
308 val: 1 | 403 val: 1 |
309 }); | 404 }); |
310 | 405 |
311 Object.unobserve(obj, observer.callback); | 406 Object.unobserve(obj, observer.callback); |
312 Object.getNotifier(obj).notify({ | 407 Object.getNotifier(obj).notify({ |
313 type: 'updated', | 408 type: 'updated', |
314 val: 2 | 409 val: 2 |
(...skipping 1306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 for (var n1 = 0; n1 < 3; ++n1) | 1716 for (var n1 = 0; n1 < 3; ++n1) |
1622 for (var n2 = 0; n2 < 3; ++n2) | 1717 for (var n2 = 0; n2 < 3; ++n2) |
1623 for (var i in mutation) | 1718 for (var i in mutation) |
1624 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); | 1719 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); |
1625 | 1720 |
1626 for (var b1 = 0; b1 < 2; ++b1) | 1721 for (var b1 = 0; b1 < 2; ++b1) |
1627 for (var b2 = 0; b2 < 2; ++b2) | 1722 for (var b2 = 0; b2 < 2; ++b2) |
1628 for (var n = 0; n < 3; ++n) | 1723 for (var n = 0; n < 3; ++n) |
1629 for (var i in mutationByIncr) | 1724 for (var i in mutationByIncr) |
1630 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); | 1725 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); |
OLD | NEW |