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

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

Issue 23464058: Allow implicit conversion of acceptList values to string during Object.observe (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: cr changes Created 7 years, 3 months 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 | Annotate | Revision Log
« no previous file with comments | « 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 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 Object.defineProperty(changeRecordWithAccessor, 'name', { 103 Object.defineProperty(changeRecordWithAccessor, 'name', {
104 get: function() { 104 get: function() {
105 recordCreated = true; 105 recordCreated = true;
106 return "bar"; 106 return "bar";
107 }, 107 },
108 enumerable: true 108 enumerable: true
109 }) 109 })
110 110
111 111
112 // Object.observe 112 // Object.observe
113 assertThrows(function() { Object.observe("non-object", observer.callback); }, Ty peError); 113 assertThrows(function() { Object.observe("non-object", observer.callback); },
114 TypeError);
114 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError); 115 assertThrows(function() { Object.observe(obj, nonFunction); }, TypeError);
115 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError); 116 assertThrows(function() { Object.observe(obj, frozenFunction); }, TypeError);
116 assertThrows(function() { Object.observe(obj, function() {}, 1); }, TypeError); 117 assertEquals(obj, Object.observe(obj, observer.callback, [1]));
117 assertThrows(function() { Object.observe(obj, function() {}, [undefined]); }, Ty peError); 118 assertEquals(obj, Object.observe(obj, observer.callback, [true]));
118 assertThrows(function() { Object.observe(obj, function() {}, [1]); }, TypeError) ; 119 assertEquals(obj, Object.observe(obj, observer.callback, ['foo', null]));
119 assertThrows(function() { Object.observe(obj, function() {}, ['foo', null]); }, TypeError); 120 assertEquals(obj, Object.observe(obj, observer.callback, [undefined]));
120 assertEquals(obj, Object.observe(obj, observer.callback, ['foo', 'bar', 'baz'])) ; 121 assertEquals(obj, Object.observe(obj, observer.callback,
122 ['foo', 'bar', 'baz']));
121 assertEquals(obj, Object.observe(obj, observer.callback, [])); 123 assertEquals(obj, Object.observe(obj, observer.callback, []));
122 assertEquals(obj, Object.observe(obj, observer.callback, undefined)); 124 assertEquals(obj, Object.observe(obj, observer.callback, undefined));
123 assertEquals(obj, Object.observe(obj, observer.callback)); 125 assertEquals(obj, Object.observe(obj, observer.callback));
124 126
125 // Object.unobserve 127 // Object.unobserve
126 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError); 128 assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError);
127 assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError); 129 assertThrows(function() { Object.unobserve(obj, nonFunction); }, TypeError);
128 assertEquals(obj, Object.unobserve(obj, observer.callback)); 130 assertEquals(obj, Object.unobserve(obj, observer.callback));
129 131
130 132
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 type: 'deleted', 197 type: 'deleted',
196 name: 'bar', 198 name: 'bar',
197 expando2: 'str' 199 expando2: 'str'
198 }); 200 });
199 Object.deliverChangeRecords(observer.callback); 201 Object.deliverChangeRecords(observer.callback);
200 observer.assertCallbackRecords([ 202 observer.assertCallbackRecords([
201 { object: obj, name: 'foo', type: 'updated', expando: 1 }, 203 { object: obj, name: 'foo', type: 'updated', expando: 1 },
202 { object: obj, name: 'bar', type: 'deleted', expando2: 'str' } 204 { object: obj, name: 'bar', type: 'deleted', expando2: 'str' }
203 ]); 205 ]);
204 206
207 // Non-string accept values are coerced to strings
208 reset();
209 Object.observe(obj, observer.callback, [true, 1, null, undefined]);
210 notifier = Object.getNotifier(obj);
211 notifier.notify({ type: 'true' });
212 notifier.notify({ type: 'false' });
213 notifier.notify({ type: '1' });
214 notifier.notify({ type: '-1' });
215 notifier.notify({ type: 'null' });
216 notifier.notify({ type: 'nill' });
217 notifier.notify({ type: 'undefined' });
218 notifier.notify({ type: 'defined' });
219 Object.deliverChangeRecords(observer.callback);
220 observer.assertCallbackRecords([
221 { object: obj, type: 'true' },
222 { object: obj, type: '1' },
223 { object: obj, type: 'null' },
224 { object: obj, type: 'undefined' }
225 ]);
205 226
206 // No delivery takes place if no records are pending 227 // No delivery takes place if no records are pending
207 reset(); 228 reset();
208 Object.deliverChangeRecords(observer.callback); 229 Object.deliverChangeRecords(observer.callback);
209 observer.assertNotCalled(); 230 observer.assertNotCalled();
210 231
211 232
212 // Multiple observation has no effect. 233 // Multiple observation has no effect.
213 reset(); 234 reset();
214 Object.observe(obj, observer.callback); 235 Object.observe(obj, observer.callback);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 Object.unobserve(obj, observer.callback); 321 Object.unobserve(obj, observer.callback);
301 Object.deliverChangeRecords(observer.callback); 322 Object.deliverChangeRecords(observer.callback);
302 observer.assertCallbackRecords([ 323 observer.assertCallbackRecords([
303 { object: obj, type: 'updated', val: 1 }, 324 { object: obj, type: 'updated', val: 1 },
304 { object: obj, type: 'updated', val: 3 }, 325 { object: obj, type: 'updated', val: 3 },
305 { object: obj, type: 'updated', val: 5 } 326 { object: obj, type: 'updated', val: 5 }
306 ]); 327 ]);
307 328
308 // Accept 329 // Accept
309 reset(); 330 reset();
310 Object.observe(obj, observer.callback, []); 331 Object.observe(obj, observer.callback, ['somethingElse']);
311 Object.getNotifier(obj).notify({ 332 Object.getNotifier(obj).notify({
312 type: 'new' 333 type: 'new'
313 }); 334 });
314 Object.getNotifier(obj).notify({ 335 Object.getNotifier(obj).notify({
315 type: 'updated' 336 type: 'updated'
316 }); 337 });
317 Object.getNotifier(obj).notify({ 338 Object.getNotifier(obj).notify({
318 type: 'deleted' 339 type: 'deleted'
319 }); 340 });
320 Object.getNotifier(obj).notify({ 341 Object.getNotifier(obj).notify({
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 for (var n1 = 0; n1 < 3; ++n1) 1546 for (var n1 = 0; n1 < 3; ++n1)
1526 for (var n2 = 0; n2 < 3; ++n2) 1547 for (var n2 = 0; n2 < 3; ++n2)
1527 for (var i in mutation) 1548 for (var i in mutation)
1528 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2); 1549 TestFastElementsLength(mutation[i], b1 != 0, b2 != 0, 20*n1, 20*n2);
1529 1550
1530 for (var b1 = 0; b1 < 2; ++b1) 1551 for (var b1 = 0; b1 < 2; ++b1)
1531 for (var b2 = 0; b2 < 2; ++b2) 1552 for (var b2 = 0; b2 < 2; ++b2)
1532 for (var n = 0; n < 3; ++n) 1553 for (var n = 0; n < 3; ++n)
1533 for (var i in mutationByIncr) 1554 for (var i in mutationByIncr)
1534 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1); 1555 TestFastElementsLength(mutationByIncr[i], b1 != 0, b2 != 0, 7*n, 7*n+1);
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698