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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 assertThrows(function() { notify.call('hello', { type: 'a' }); }, TypeError); | 122 assertThrows(function() { notify.call('hello', { type: 'a' }); }, TypeError); |
123 assertThrows(function() { notify.call(false, { type: 'a' }); }, TypeError); | 123 assertThrows(function() { notify.call(false, { type: 'a' }); }, TypeError); |
124 assertThrows(function() { notify.call({}, { type: 'a' }); }, TypeError); | 124 assertThrows(function() { notify.call({}, { type: 'a' }); }, TypeError); |
125 assertFalse(recordCreated); | 125 assertFalse(recordCreated); |
126 notifier.notify(changeRecordWithAccessor); | 126 notifier.notify(changeRecordWithAccessor); |
127 assertFalse(recordCreated); // not observed yet | 127 assertFalse(recordCreated); // not observed yet |
128 | 128 |
129 // Object.deliverChangeRecords | 129 // Object.deliverChangeRecords |
130 assertThrows(function() { Object.deliverChangeRecords(nonFunction); }, TypeError
); | 130 assertThrows(function() { Object.deliverChangeRecords(nonFunction); }, TypeError
); |
131 | 131 |
| 132 Object.observe(obj, observer.callback); |
| 133 |
| 134 // notify uses to [[CreateOwnProperty]] to create changeRecord; |
| 135 reset(); |
| 136 var protoExpandoAccessed = false; |
| 137 Object.defineProperty(Object.prototype, 'protoExpando', |
| 138 { |
| 139 configurable: true, |
| 140 set: function() { protoExpandoAccessed = true; } |
| 141 } |
| 142 ); |
| 143 notifier.notify({ type: 'foo', protoExpando: 'val'}); |
| 144 assertFalse(protoExpandoAccessed); |
| 145 delete Object.prototype.protoExpando; |
| 146 Object.deliverChangeRecords(observer.callback); |
| 147 |
132 // Multiple records are delivered. | 148 // Multiple records are delivered. |
133 Object.observe(obj, observer.callback); | 149 reset(); |
134 notifier.notify({ | 150 notifier.notify({ |
135 type: 'updated', | 151 type: 'updated', |
136 name: 'foo', | 152 name: 'foo', |
137 expando: 1 | 153 expando: 1 |
138 }); | 154 }); |
139 | 155 |
140 notifier.notify({ | 156 notifier.notify({ |
141 object: notifier, // object property is ignored | 157 object: notifier, // object property is ignored |
142 type: 'deleted', | 158 type: 'deleted', |
143 name: 'bar', | 159 name: 'bar', |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 Object.observe(dummy, observer.callback); | 614 Object.observe(dummy, observer.callback); |
599 Object.unobserve(dummy, observer.callback); | 615 Object.unobserve(dummy, observer.callback); |
600 var array = [0]; | 616 var array = [0]; |
601 Object.observe(array, observer.callback); | 617 Object.observe(array, observer.callback); |
602 array.splice(0, 1); | 618 array.splice(0, 1); |
603 Object.deliverChangeRecords(observer.callback); | 619 Object.deliverChangeRecords(observer.callback); |
604 observer.assertCallbackRecords([ | 620 observer.assertCallbackRecords([ |
605 { object: array, name: '0', type: 'deleted', oldValue: 0 }, | 621 { object: array, name: '0', type: 'deleted', oldValue: 0 }, |
606 { object: array, name: 'length', type: 'updated', oldValue: 1}, | 622 { object: array, name: 'length', type: 'updated', oldValue: 1}, |
607 ]); | 623 ]); |
OLD | NEW |