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

Unified Diff: test/mjsunit/harmony/object-observe.js

Issue 11347037: Object.observe: generate change records for named properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. 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/v8natives.js ('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 07656d35dba7f31ec25a3c7fabfeb39cdbb23ea3..276f1fec2474c00e0037fb2aee9347b6719b8602 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -25,7 +25,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --harmony-object-observe
+// Flags: --harmony-observation
var allObservers = [];
function reset() {
@@ -88,6 +88,7 @@ var recordCreated = false;
Object.defineProperty(changeRecordWithAccessor, 'name', {
get: function() {
recordCreated = true;
+ return "bar";
},
enumerable: true
})
@@ -103,6 +104,7 @@ assertThrows(function() { Object.unobserve(4, observer.callback); }, TypeError);
// Object.notify
assertThrows(function() { Object.notify(obj, {}); }, TypeError);
assertThrows(function() { Object.notify(obj, { type: 4 }); }, TypeError);
+assertFalse(recordCreated);
Object.notify(obj, changeRecordWithAccessor);
assertFalse(recordCreated);
@@ -217,7 +219,7 @@ observer.assertCallbackRecords([
{ object: obj, type: 'foo', val: 5 }
]);
-// Observing multiple objects; records appear in order;.
+// Observing multiple objects; records appear in order.
reset();
var obj2 = {};
var obj3 = {}
@@ -238,4 +240,36 @@ observer.assertCallbackRecords([
{ object: obj, type: 'foo' },
{ object: obj2, type: 'foo' },
{ object: obj3, type: 'foo' }
-]);
+]);
+
+// Observing named properties.
+reset();
+var obj = {a: 1}
+Object.observe(obj, observer.callback);
+obj.a = 2;
+obj["a"] = 3;
+delete obj.a;
+obj.a = 4;
+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", {get: function() {}});
+delete obj.a;
+Object.defineProperty(obj, "a", {get: function() {}});
+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: "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: "reconfigured" },
+ { object: obj, name: "a", type: "deleted" },
+ { object: obj, name: "a", type: "new" },
+]);
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698