| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 type: 'delete', | 203 type: 'delete', |
| 204 name: 'bar', | 204 name: 'bar', |
| 205 expando2: 'str' | 205 expando2: 'str' |
| 206 }); | 206 }); |
| 207 Object.deliverChangeRecords(observer.callback); | 207 Object.deliverChangeRecords(observer.callback); |
| 208 observer.assertCallbackRecords([ | 208 observer.assertCallbackRecords([ |
| 209 { object: obj, name: 'foo', type: 'update', expando: 1 }, | 209 { object: obj, name: 'foo', type: 'update', expando: 1 }, |
| 210 { object: obj, name: 'bar', type: 'delete', expando2: 'str' } | 210 { object: obj, name: 'bar', type: 'delete', expando2: 'str' } |
| 211 ]); | 211 ]); |
| 212 | 212 |
| 213 // Properties from prototype of synthetic change records are preserved |
| 214 reset(); |
| 215 Object.observe(obj, observer.callback); |
| 216 notifier = Object.getNotifier(obj); |
| 217 var proto = { |
| 218 type: 'update', |
| 219 foo: 'bar' |
| 220 }; |
| 221 var rec = Object.create(proto); |
| 222 rec.oldValue = 3; |
| 223 notifier.notify(rec); |
| 224 |
| 225 proto.type = 'delete'; |
| 226 rec.oldValue = 5; |
| 227 |
| 228 notifier.performChange('delete', function() { |
| 229 return rec; |
| 230 }); |
| 231 |
| 232 Object.deliverChangeRecords(observer.callback); |
| 233 observer.assertCallbackRecords([ |
| 234 { object: obj, type: 'update', foo: 'bar', oldValue: 3 }, |
| 235 { object: obj, type: 'delete', foo: 'bar', oldValue: 5 }, |
| 236 ]); |
| 237 |
| 213 // Non-string accept values are coerced to strings | 238 // Non-string accept values are coerced to strings |
| 214 reset(); | 239 reset(); |
| 215 Object.observe(obj, observer.callback, [true, 1, null, undefined]); | 240 Object.observe(obj, observer.callback, [true, 1, null, undefined]); |
| 216 notifier = Object.getNotifier(obj); | 241 notifier = Object.getNotifier(obj); |
| 217 notifier.notify({ type: 'true' }); | 242 notifier.notify({ type: 'true' }); |
| 218 notifier.notify({ type: 'false' }); | 243 notifier.notify({ type: 'false' }); |
| 219 notifier.notify({ type: '1' }); | 244 notifier.notify({ type: '1' }); |
| 220 notifier.notify({ type: '-1' }); | 245 notifier.notify({ type: '-1' }); |
| 221 notifier.notify({ type: 'null' }); | 246 notifier.notify({ type: 'null' }); |
| 222 notifier.notify({ type: 'nill' }); | 247 notifier.notify({ type: 'nill' }); |
| (...skipping 1566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1789 for (var n1 = 0; n1 < 3; ++n1) | 1814 for (var n1 = 0; n1 < 3; ++n1) |
| 1790 for (var n2 = 0; n2 < 3; ++n2) | 1815 for (var n2 = 0; n2 < 3; ++n2) |
| 1791 for (var i in mutation) | 1816 for (var i in mutation) |
| 1792 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); | 1817 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); |
| 1793 | 1818 |
| 1794 for (var b1 = 0; b1 < 2; ++b1) | 1819 for (var b1 = 0; b1 < 2; ++b1) |
| 1795 for (var b2 = 0; b2 < 2; ++b2) | 1820 for (var b2 = 0; b2 < 2; ++b2) |
| 1796 for (var n = 0; n < 3; ++n) | 1821 for (var n = 0; n < 3; ++n) |
| 1797 for (var i in mutationByIncr) | 1822 for (var i in mutationByIncr) |
| 1798 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); | 1823 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); |
| OLD | NEW |