Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(197)

Side by Side Diff: test/mjsunit/harmony/object-observe.js

Issue 11377171: Object.observe: Use [[DefineOwnProperty]] to create properties of changeRecord (Closed) Base URL: git://github.com/v8/v8.git@bleeding_edge
Patch Set: removing InternalObject* Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« src/object-observe.js ('K') | « src/object-observe.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 assertThrows(function() { notify.call('hello', { type: 'a' }); }, TypeError); 121 assertThrows(function() { notify.call('hello', { type: 'a' }); }, TypeError);
122 assertThrows(function() { notify.call(false, { type: 'a' }); }, TypeError); 122 assertThrows(function() { notify.call(false, { type: 'a' }); }, TypeError);
123 assertThrows(function() { notify.call({}, { type: 'a' }); }, TypeError); 123 assertThrows(function() { notify.call({}, { type: 'a' }); }, TypeError);
124 assertFalse(recordCreated); 124 assertFalse(recordCreated);
125 notifier.notify(changeRecordWithAccessor); 125 notifier.notify(changeRecordWithAccessor);
126 assertFalse(recordCreated); // not observed yet 126 assertFalse(recordCreated); // not observed yet
127 127
128 // Object.deliverChangeRecords 128 // Object.deliverChangeRecords
129 assertThrows(function() { Object.deliverChangeRecords(nonFunction); }, TypeError ); 129 assertThrows(function() { Object.deliverChangeRecords(nonFunction); }, TypeError );
130 130
131 Object.observe(obj, observer.callback);
132
133 // notify uses to [[CreateOwnProperty]] to create changeRecord;
134 reset();
135 var protoExpandoAccessed = false;
136 Object.defineProperty(Object.prototype, 'protoExpando',
137 {
138 configurable: true,
139 set: function() { protoExpandoAccessed = true; }
140 }
141 );
142 notifier.notify({ type: 'foo', protoExpando: 'val'});
143 assertFalse(protoExpandoAccessed);
144 delete Object.prototype.protoExpando;
145 Object.deliverChangeRecords(observer.callback);
146
131 // Multiple records are delivered. 147 // Multiple records are delivered.
132 Object.observe(obj, observer.callback); 148 reset();
133 notifier.notify({ 149 notifier.notify({
134 type: 'updated', 150 type: 'updated',
135 name: 'foo', 151 name: 'foo',
136 expando: 1 152 expando: 1
137 }); 153 });
138 154
139 notifier.notify({ 155 notifier.notify({
140 object: notifier, // object property is ignored 156 object: notifier, // object property is ignored
141 type: 'deleted', 157 type: 'deleted',
142 name: 'bar', 158 name: 'bar',
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 Object.observe(dummy, observer.callback); 613 Object.observe(dummy, observer.callback);
598 Object.unobserve(dummy, observer.callback); 614 Object.unobserve(dummy, observer.callback);
599 var array = [0]; 615 var array = [0];
600 Object.observe(array, observer.callback); 616 Object.observe(array, observer.callback);
601 array.splice(0, 1); 617 array.splice(0, 1);
602 Object.deliverChangeRecords(observer.callback); 618 Object.deliverChangeRecords(observer.callback);
603 observer.assertCallbackRecords([ 619 observer.assertCallbackRecords([
604 { object: array, name: '0', type: 'deleted', oldValue: 0 }, 620 { object: array, name: '0', type: 'deleted', oldValue: 0 },
605 { object: array, name: 'length', type: 'updated', oldValue: 1}, 621 { object: array, name: 'length', type: 'updated', oldValue: 1},
606 ]); 622 ]);
OLDNEW
« src/object-observe.js ('K') | « src/object-observe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698