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

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

Issue 11365111: Object.observe: generate change records for indexed properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments; simplifications. 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 | Annotate | Revision Log
« no previous file with comments | « src/runtime.cc ('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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 ]); 243 ]);
244 244
245 // Observing named properties. 245 // Observing named properties.
246 reset(); 246 reset();
247 var obj = {a: 1} 247 var obj = {a: 1}
248 Object.observe(obj, observer.callback); 248 Object.observe(obj, observer.callback);
249 obj.a = 2; 249 obj.a = 2;
250 obj["a"] = 3; 250 obj["a"] = 3;
251 delete obj.a; 251 delete obj.a;
252 obj.a = 4; 252 obj.a = 4;
253 obj.a = 4; // ignored
253 obj.a = 5; 254 obj.a = 5;
254 Object.defineProperty(obj, "a", {value: 6}); 255 Object.defineProperty(obj, "a", {value: 6});
255 Object.defineProperty(obj, "a", {writable: false}); 256 Object.defineProperty(obj, "a", {writable: false});
256 obj.a = 7; // ignored 257 obj.a = 7; // ignored
257 Object.defineProperty(obj, "a", {value: 8}); 258 Object.defineProperty(obj, "a", {value: 8});
259 Object.defineProperty(obj, "a", {value: 7, writable: true});
260 Object.defineProperty(obj, "a", {get: function() {}});
258 Object.defineProperty(obj, "a", {get: function() {}}); 261 Object.defineProperty(obj, "a", {get: function() {}});
259 delete obj.a; 262 delete obj.a;
260 Object.defineProperty(obj, "a", {get: function() {}}); 263 delete obj.a;
264 Object.defineProperty(obj, "a", {get: function() {}, configurable: true});
265 Object.defineProperty(obj, "a", {value: 9, writable: true});
266 obj.a = 10;
261 Object.deliverChangeRecords(observer.callback); 267 Object.deliverChangeRecords(observer.callback);
262 // TODO(observe): oldValue not included yet.
263 observer.assertCallbackRecords([ 268 observer.assertCallbackRecords([
264 { object: obj, name: "a", type: "updated" }, 269 { object: obj, name: "a", type: "updated", oldValue: 1 },
265 { object: obj, name: "a", type: "updated" }, 270 { object: obj, name: "a", type: "updated", oldValue: 2 },
266 { object: obj, name: "a", type: "deleted" }, 271 { object: obj, name: "a", type: "deleted", oldValue: 3 },
267 { object: obj, name: "a", type: "new" }, 272 { object: obj, name: "a", type: "new" },
268 { object: obj, name: "a", type: "updated" }, 273 { object: obj, name: "a", type: "updated", oldValue: 4 },
269 { object: obj, name: "a", type: "updated" }, 274 { object: obj, name: "a", type: "updated", oldValue: 5 },
270 { object: obj, name: "a", type: "reconfigured" }, 275 { object: obj, name: "a", type: "reconfigured", oldValue: 6 },
271 { object: obj, name: "a", type: "updated" }, 276 { object: obj, name: "a", type: "updated", oldValue: 6 },
277 { object: obj, name: "a", type: "reconfigured", oldValue: 8 },
278 { object: obj, name: "a", type: "reconfigured", oldValue: 7 },
272 { object: obj, name: "a", type: "reconfigured" }, 279 { object: obj, name: "a", type: "reconfigured" },
273 { object: obj, name: "a", type: "deleted" }, 280 { object: obj, name: "a", type: "deleted" },
274 { object: obj, name: "a", type: "new" }, 281 { object: obj, name: "a", type: "new" },
282 { object: obj, name: "a", type: "reconfigured" },
283 { object: obj, name: "a", type: "updated", oldValue: 9 },
275 ]); 284 ]);
285
286 // Observing indexed properties.
287 reset();
288 var obj = {'1': 1}
289 Object.observe(obj, observer.callback);
290 obj[1] = 2;
291 obj[1] = 3;
292 delete obj[1];
293 obj[1] = 4;
294 obj[1] = 4; // ignored
295 obj[1] = 5;
296 Object.defineProperty(obj, "1", {value: 6});
297 Object.defineProperty(obj, "1", {writable: false});
298 obj[1] = 7; // ignored
299 Object.defineProperty(obj, "1", {value: 8});
300 Object.defineProperty(obj, "1", {value: 7, writable: true});
301 Object.defineProperty(obj, "1", {get: function() {}});
302 delete obj[1];
303 delete obj[1];
304 Object.defineProperty(obj, "1", {get: function() {}, configurable: true});
305 Object.defineProperty(obj, "1", {value: 9, writable: true});
306 obj[1] = 10;
307 Object.deliverChangeRecords(observer.callback);
308 observer.assertCallbackRecords([
309 { object: obj, name: "1", type: "updated", oldValue: 1 },
310 { object: obj, name: "1", type: "updated", oldValue: 2 },
311 { object: obj, name: "1", type: "deleted", oldValue: 3 },
312 { object: obj, name: "1", type: "new" },
313 { object: obj, name: "1", type: "updated", oldValue: 4 },
314 { object: obj, name: "1", type: "updated", oldValue: 5 },
315 { object: obj, name: "1", type: "reconfigured", oldValue: 6 },
316 { object: obj, name: "1", type: "updated", oldValue: 6 },
317 { object: obj, name: "1", type: "reconfigured", oldValue: 8 },
318 { object: obj, name: "1", type: "reconfigured", oldValue: 7 },
319 // TODO(observe): oldValue should not be present below.
320 { object: obj, name: "1", type: "deleted", oldValue: undefined },
321 { object: obj, name: "1", type: "new" },
322 // TODO(observe): oldValue should be absent below, and type = "reconfigured".
323 { object: obj, name: "1", type: "updated", oldValue: undefined },
324 { object: obj, name: "1", type: "updated", oldValue: 9 },
325 ]);
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698