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

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

Issue 11414094: Make Object.observe on the global object functional (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add test for attaching via Context::New Created 8 years 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 | « test/cctest/test-object-observe.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 d88c24eac5bcd87c98ecf0e7b6899ada76c0e050..d79e9f2b083a9d914c66b594f4388000b59d5207 100644
--- a/test/mjsunit/harmony/object-observe.js
+++ b/test/mjsunit/harmony/object-observe.js
@@ -32,6 +32,14 @@ function reset() {
allObservers.forEach(function(observer) { observer.reset(); });
}
+function stringifyNoThrow(arg) {
+ try {
+ return JSON.stringify(arg);
+ } catch (e) {
+ return '{<circular reference>}';
+ }
+}
+
function createObserver() {
"use strict"; // So that |this| in callback can be undefined.
@@ -58,7 +66,7 @@ function createObserver() {
for (var i = 0; i < recs.length; i++) {
if ('name' in recs[i])
recs[i].name = String(recs[i].name);
- print(i, JSON.stringify(this.records[i]), JSON.stringify(recs[i]));
+ print(i, stringifyNoThrow(this.records[i]), stringifyNoThrow(recs[i]));
assertSame(this.records[i].object, recs[i].object);
assertEquals('string', typeof recs[i].type);
assertPropertiesEqual(this.records[i], recs[i]);
@@ -499,7 +507,7 @@ function createProxy(create, x) {
},
target: {isProxy: true},
callback: function(changeRecords) {
- print("callback", JSON.stringify(handler.proxy), JSON.stringify(got));
+ print("callback", stringifyNoThrow(handler.proxy), stringifyNoThrow(got));
for (var i in changeRecords) {
var got = changeRecords[i];
var change = {object: handler.proxy, name: got.name, type: got.type};
@@ -538,9 +546,7 @@ function blacklisted(obj, prop) {
// TODO(observe): oldValue when reconfiguring array length
(obj instanceof Array && prop === "length") ||
// TODO(observe): prototype property on functions
- (obj instanceof Function && prop === "prototype") ||
- // TODO(observe): global object
- obj === this;
+ (obj instanceof Function && prop === "prototype")
}
for (var i in objects) for (var j in properties) {
@@ -548,7 +554,7 @@ for (var i in objects) for (var j in properties) {
var prop = properties[j];
if (blacklisted(obj, prop)) continue;
var desc = Object.getOwnPropertyDescriptor(obj, prop);
- print("***", typeof obj, JSON.stringify(obj), prop);
+ print("***", typeof obj, stringifyNoThrow(obj), prop);
if (!desc || desc.configurable)
TestObserveConfigurable(obj, prop);
else if (desc.writable)
« no previous file with comments | « test/cctest/test-object-observe.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698