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

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

Issue 47703003: Make Object.freeze/seal/preventExtensions observable (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: whitespace Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
« src/objects.cc ('K') | « 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 f94ab75e9a84d2cf0d819510782b23a660057bcc..d190016ca79c46e2da96f8fb7a140bea9047561b 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -300,8 +300,79 @@ observer.assertCallbackRecords([
{ object: obj, type: 'deleted', name: '', oldValue: ' ' },
]);
+// Object.preventExtensions
rossberg 2013/10/30 19:11:45 Cases you could add: - invoking preventExtensions
rafaelw 2013/10/30 23:00:30 Good catch. Note that we now exit early from JSObj
rossberg 2013/10/31 08:03:20 Can you add a similar test for seal and freeze?
rafaelw 2013/11/05 12:20:31 Done.
+reset();
+var obj = { foo: 'bar'};
+Object.observe(obj, observer.callback);
+obj.baz = 'bat';
+Object.preventExtensions(obj);
+
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: obj, type: 'new', name: 'baz' },
+ { object: obj, type: 'preventExtensions' },
+]);
+
+// Object.freeze
+reset();
+var obj = { a: 'a' };
+Object.defineProperty(obj, 'b', {
+ writable: false,
+ configurable: true,
+ value: 'b'
+});
+Object.defineProperty(obj, 'c', {
+ writable: true,
+ configurable: false,
+ value: 'c'
+});
+Object.defineProperty(obj, 'd', {
+ writable: false,
+ configurable: false,
+ value: 'd'
+});
+Object.observe(obj, observer.callback);
+Object.freeze(obj);
+
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: obj, type: 'reconfigured', name: 'a' },
+ { object: obj, type: 'reconfigured', name: 'b' },
+ { object: obj, type: 'reconfigured', name: 'c' },
+ { object: obj, type: 'preventExtensions' },
+]);
+
+// Object.seal
+reset();
+var obj = { a: 'a' };
+Object.defineProperty(obj, 'b', {
+ writable: false,
+ configurable: true,
+ value: 'b'
+});
+Object.defineProperty(obj, 'c', {
+ writable: true,
+ configurable: false,
+ value: 'c'
+});
+Object.defineProperty(obj, 'd', {
+ writable: false,
+ configurable: false,
+ value: 'd'
+});
+Object.observe(obj, observer.callback);
+Object.seal(obj);
+
+Object.deliverChangeRecords(observer.callback);
+observer.assertCallbackRecords([
+ { object: obj, type: 'reconfigured', name: 'a' },
+ { object: obj, type: 'reconfigured', name: 'b' },
+ { object: obj, type: 'preventExtensions' },
+]);
+
// Observing a continuous stream of changes, while itermittantly unobserving.
reset();
+var obj = {};
Object.observe(obj, observer.callback);
Object.getNotifier(obj).notify({
type: 'updated',
« src/objects.cc ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698