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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 Object.observe(obj3, observer.callback); | 296 Object.observe(obj3, observer.callback); |
297 Object.deliverChangeRecords(observer.callback); | 297 Object.deliverChangeRecords(observer.callback); |
298 observer.assertCallbackRecords([ | 298 observer.assertCallbackRecords([ |
299 { object: obj, type: 'foo1' }, | 299 { object: obj, type: 'foo1' }, |
300 { object: obj2, type: 'foo2' }, | 300 { object: obj2, type: 'foo2' }, |
301 { object: obj3, type: 'foo3' } | 301 { object: obj3, type: 'foo3' } |
302 ]); | 302 ]); |
303 | 303 |
304 | 304 |
305 // Recursive observation. | 305 // Recursive observation. |
| 306 /* TODO(rossberg): temporarily disabled until fixed. |
306 var obj = {a: 1}; | 307 var obj = {a: 1}; |
307 var callbackCount = 0; | 308 var callbackCount = 0; |
308 function recursiveObserver(r) { | 309 function recursiveObserver(r) { |
309 assertEquals(1, r.length); | 310 assertEquals(1, r.length); |
310 ++callbackCount; | 311 ++callbackCount; |
311 if (r[0].oldValue < 100) ++obj[r[0].name]; | 312 if (r[0].oldValue < 100) ++obj[r[0].name]; |
312 } | 313 } |
313 Object.observe(obj, recursiveObserver); | 314 Object.observe(obj, recursiveObserver); |
314 ++obj.a; | 315 ++obj.a; |
315 Object.deliverChangeRecords(recursiveObserver); | 316 Object.deliverChangeRecords(recursiveObserver); |
316 assertEquals(100, callbackCount); | 317 assertEquals(100, callbackCount); |
317 | 318 |
318 var obj1 = {a: 1}; | 319 var obj1 = {a: 1}; |
319 var obj2 = {a: 1}; | 320 var obj2 = {a: 1}; |
320 var recordCount = 0; | 321 var recordCount = 0; |
321 function recursiveObserver2(r) { | 322 function recursiveObserver2(r) { |
322 recordCount += r.length; | 323 recordCount += r.length; |
323 if (r[0].oldValue < 100) { | 324 if (r[0].oldValue < 100) { |
324 ++obj1.a; | 325 ++obj1.a; |
325 ++obj2.a; | 326 ++obj2.a; |
326 } | 327 } |
327 } | 328 } |
328 Object.observe(obj1, recursiveObserver2); | 329 Object.observe(obj1, recursiveObserver2); |
329 Object.observe(obj2, recursiveObserver2); | 330 Object.observe(obj2, recursiveObserver2); |
330 ++obj1.a; | 331 ++obj1.a; |
331 Object.deliverChangeRecords(recursiveObserver2); | 332 Object.deliverChangeRecords(recursiveObserver2); |
332 assertEquals(199, recordCount); | 333 assertEquals(199, recordCount); |
| 334 */ |
333 | 335 |
334 | 336 |
335 // Observing named properties. | 337 // Observing named properties. |
336 reset(); | 338 reset(); |
337 var obj = {a: 1} | 339 var obj = {a: 1} |
338 Object.observe(obj, observer.callback); | 340 Object.observe(obj, observer.callback); |
339 obj.a = 2; | 341 obj.a = 2; |
340 obj["a"] = 3; | 342 obj["a"] = 3; |
341 delete obj.a; | 343 delete obj.a; |
342 obj.a = 4; | 344 obj.a = 4; |
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 assertEquals('updated', lengthRecord.type); | 990 assertEquals('updated', lengthRecord.type); |
989 assertSame(oldSize, lengthRecord.oldValue); | 991 assertSame(oldSize, lengthRecord.oldValue); |
990 } | 992 } |
991 } | 993 } |
992 | 994 |
993 for (var b1 = 0; b1 < 2; ++b1) | 995 for (var b1 = 0; b1 < 2; ++b1) |
994 for (var b2 = 0; b2 < 2; ++b2) | 996 for (var b2 = 0; b2 < 2; ++b2) |
995 for (var n1 = 0; n1 < 3; ++n1) | 997 for (var n1 = 0; n1 < 3; ++n1) |
996 for (var n2 = 0; n2 < 3; ++n2) | 998 for (var n2 = 0; n2 < 3; ++n2) |
997 TestFastElementsLength(b1 != 0, b2 != 0, 20*n1, 20*n2); | 999 TestFastElementsLength(b1 != 0, b2 != 0, 20*n1, 20*n2); |
OLD | NEW |