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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/harmony/object-observe.js
diff --git a/test/mjsunit/harmony/object-observe.js b/test/mjsunit/harmony/object-observe.js
index 276f1fec2474c00e0037fb2aee9347b6719b8602..6a0fc0dfea131f367345a1ac15ec858243377431 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -250,26 +250,76 @@ obj.a = 2;
obj["a"] = 3;
delete obj.a;
obj.a = 4;
+obj.a = 4; // ignored
obj.a = 5;
Object.defineProperty(obj, "a", {value: 6});
Object.defineProperty(obj, "a", {writable: false});
obj.a = 7; // ignored
Object.defineProperty(obj, "a", {value: 8});
+Object.defineProperty(obj, "a", {value: 7, writable: true});
Object.defineProperty(obj, "a", {get: function() {}});
-delete obj.a;
Object.defineProperty(obj, "a", {get: function() {}});
+delete obj.a;
+delete obj.a;
+Object.defineProperty(obj, "a", {get: function() {}, configurable: true});
+Object.defineProperty(obj, "a", {value: 9, writable: true});
+obj.a = 10;
Object.deliverChangeRecords(observer.callback);
-// TODO(observe): oldValue not included yet.
observer.assertCallbackRecords([
- { object: obj, name: "a", type: "updated" },
- { object: obj, name: "a", type: "updated" },
- { object: obj, name: "a", type: "deleted" },
+ { object: obj, name: "a", type: "updated", oldValue: 1 },
+ { object: obj, name: "a", type: "updated", oldValue: 2 },
+ { object: obj, name: "a", type: "deleted", oldValue: 3 },
{ object: obj, name: "a", type: "new" },
- { object: obj, name: "a", type: "updated" },
- { object: obj, name: "a", type: "updated" },
- { object: obj, name: "a", type: "reconfigured" },
- { object: obj, name: "a", type: "updated" },
+ { object: obj, name: "a", type: "updated", oldValue: 4 },
+ { object: obj, name: "a", type: "updated", oldValue: 5 },
+ { object: obj, name: "a", type: "reconfigured", oldValue: 6 },
+ { object: obj, name: "a", type: "updated", oldValue: 6 },
+ { object: obj, name: "a", type: "reconfigured", oldValue: 8 },
+ { object: obj, name: "a", type: "reconfigured", oldValue: 7 },
{ object: obj, name: "a", type: "reconfigured" },
{ object: obj, name: "a", type: "deleted" },
{ object: obj, name: "a", type: "new" },
+ { object: obj, name: "a", type: "reconfigured" },
+ { object: obj, name: "a", type: "updated", oldValue: 9 },
+]);
+
+// Observing indexed properties.
+reset();
+var obj = {'1': 1}
+Object.observe(obj, observer.callback);
+obj[1] = 2;
+obj[1] = 3;
+delete obj[1];
+obj[1] = 4;
+obj[1] = 4; // ignored
+obj[1] = 5;
+Object.defineProperty(obj, "1", {value: 6});
+Object.defineProperty(obj, "1", {writable: false});
+obj[1] = 7; // ignored
+Object.defineProperty(obj, "1", {value: 8});
+Object.defineProperty(obj, "1", {value: 7, writable: true});
+Object.defineProperty(obj, "1", {get: function() {}});
+delete obj[1];
+delete obj[1];
+Object.defineProperty(obj, "1", {get: function() {}, configurable: true});
+Object.defineProperty(obj, "1", {value: 9, writable: true});
+obj[1] = 10;
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: obj, name: "1", type: "updated", oldValue: 1 },
+ { object: obj, name: "1", type: "updated", oldValue: 2 },
+ { object: obj, name: "1", type: "deleted", oldValue: 3 },
+ { object: obj, name: "1", type: "new" },
+ { object: obj, name: "1", type: "updated", oldValue: 4 },
+ { object: obj, name: "1", type: "updated", oldValue: 5 },
+ { object: obj, name: "1", type: "reconfigured", oldValue: 6 },
+ { object: obj, name: "1", type: "updated", oldValue: 6 },
+ { object: obj, name: "1", type: "reconfigured", oldValue: 8 },
+ { object: obj, name: "1", type: "reconfigured", oldValue: 7 },
+ // TODO(observe): oldValue should not be present below.
+ { object: obj, name: "1", type: "deleted", oldValue: undefined },
+ { object: obj, name: "1", type: "new" },
+ // TODO(observe): oldValue should be absent below, and type = "reconfigured".
+ { object: obj, name: "1", type: "updated", oldValue: undefined },
+ { object: obj, name: "1", type: "updated", oldValue: 9 },
]);
« 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