Index: test/mjsunit/mirror-error.js |
=================================================================== |
--- test/mjsunit/mirror-error.js (revision 1079) |
+++ test/mjsunit/mirror-error.js (working copy) |
@@ -28,10 +28,24 @@ |
// Flags: --expose-debug-as debug |
// Test the mirror object for regular error objects |
+function MirrorRefCache(json_refs) { |
+ var tmp = eval('(' + json_refs + ')'); |
+ this.refs_ = []; |
+ for (var i = 0; i < tmp.length; i++) { |
+ this.refs_[tmp[i].handle] = tmp[i]; |
+ } |
+} |
+ |
+MirrorRefCache.prototype.lookup = function(handle) { |
+ return this.refs_[handle]; |
+} |
+ |
function testErrorMirror(e) { |
// Create mirror and JSON representation. |
var mirror = debug.MakeMirror(e); |
- var json = mirror.toJSONProtocol(true); |
+ var serializer = debug.MakeMirrorSerializer(); |
+ var json = serializer.serializeValue(mirror); |
+ var refs = new MirrorRefCache(serializer.serializeReferencedObjects()); |
// Check the mirror hierachy. |
assertTrue(mirror instanceof debug.Mirror); |
@@ -49,7 +63,18 @@ |
var fromJSON = eval('(' + json + ')'); |
assertEquals('error', fromJSON.type); |
assertEquals('Error', fromJSON.className); |
- assertEquals(fromJSON.message, e.message, 'message'); |
+ if (e.message) { |
+ var found_message = false; |
+ for (var i in fromJSON.properties) { |
+ var p = fromJSON.properties[i]; |
+ print(p.name); |
+ if (p.name == 'message') { |
+ assertEquals(e.message, refs.lookup(p.ref).value); |
+ found_message = true; |
+ } |
+ } |
+ assertTrue(found_message, 'Property message not found'); |
+ } |
// Check the formatted text (regress 1231579). |
assertEquals(fromJSON.text, e.toString(), 'toString'); |