Reviewers: Yang,

Message:
PTAL.  This needs to be fixed in order to ship iterators; otherwise symbolic
properties cause the mirror serializer to bail.  Even with this patch they
aren't serialized nicely.  Not sure what impact on Chromium is; are they
expecting indexed properties to be numbers and not names?

Description:
Mirror object properties are always names

[email protected]
BUG=

Please review this at https://codereview.chromium.org/443843004/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+20, -8 lines):
  M src/mirror-debugger.js
  M test/mjsunit/mirror-object.js


Index: src/mirror-debugger.js
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js
index 932294157b0258f297614ddd9abd50a23fbec98a..a90f6035195afec0d660649bd8656732e0123c3b 100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -759,7 +759,7 @@ ObjectMirror.prototype.propertyNames = function(kind, limit) {
   // Copy names for indexed properties.
   if (kind & PropertyKind.Indexed) {
     for (var i = 0; index < limit && i < elementNames.length; i++) {
-      names[index++] = elementNames[i];
+      names[index++] = %ToString(elementNames[i]);
     }
   }

@@ -797,7 +797,8 @@ ObjectMirror.prototype.internalProperties = function() {


 ObjectMirror.prototype.property = function(name) {
-  var details = %DebugGetPropertyDetails(this.value_, %ToString(name));
+  name = IS_SYMBOL(name) ? name : %ToString(name);
+  var details = %DebugGetPropertyDetails(this.value_, name);
   if (details) {
     return new PropertyMirror(this, name, details);
   }
@@ -1357,7 +1358,7 @@ SetMirror.prototype.values = function() {
 /**
  * Base mirror object for properties.
  * @param {ObjectMirror} mirror The mirror object having this property
- * @param {string} name The name of the property
+ * @param {Name} name The name of the property (a string or a symbol)
  * @param {Array} details Details about the property
  * @constructor
  * @extends Mirror
Index: test/mjsunit/mirror-object.js
diff --git a/test/mjsunit/mirror-object.js b/test/mjsunit/mirror-object.js
index 8bf8a2d4f83181d46340bf00a34ec8f450ebcf86..e719b9b47997defbeea75b13e391d64f6a69e714 100644
--- a/test/mjsunit/mirror-object.js
+++ b/test/mjsunit/mirror-object.js
@@ -40,6 +40,10 @@ MirrorRefCache.prototype.lookup = function(handle) {
   return this.refs_[handle];
 };

+function isName(val) {
+  return typeof val === 'string' || typeof val === 'symbol';
+}
+
 function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) {
   // Create mirror and JSON representation.
   var mirror = debug.MakeMirror(obj);
@@ -72,6 +76,7 @@ function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) { assertTrue(properties[i] instanceof debug.Mirror, 'Unexpected mirror hierarchy'); assertTrue(properties[i] instanceof debug.PropertyMirror, 'Unexpected mirror hierarchy'); assertEquals('property', properties[i].type(), 'Unexpected mirror type'); + assertTrue(isName(names[i]), "Expected string or symbol property name"); assertEquals(names[i], properties[i].name(), 'Unexpected property name');
   }

@@ -111,12 +116,14 @@ function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) {

   // Check that the serialization contains all properties.
assertEquals(names.length, fromJSON.properties.length, 'Some properties missing in JSON');
-  for (var i = 0; i < fromJSON.properties.length; i++) {
-    var name = fromJSON.properties[i].name;
-    if (typeof name == 'undefined') name = fromJSON.properties[i].index;
+  for (var j = 0; j < names.length; j++) {
+    var name = names[j];
+    // Serialization of symbol-named properties to JSON doesn't really
+    // work currently, as they don't get a {name: ...} entry.
+    if (typeof name === 'symbol') continue;
     var found = false;
-    for (var j = 0; j < names.length; j++) {
-      if (names[j] == name) {
+    for (var i = 0; i < fromJSON.properties.length; i++) {
+      if (fromJSON.properties[i].name == name) {
         // Check that serialized handle is correct.
assertEquals(properties[i].value().handle(), fromJSON.properties[i].ref, 'Unexpected serialized handle');

@@ -170,6 +177,9 @@ function Point(x,y) {
   this.y_ = y;
 }

+var object_with_symbol = {};
+object_with_symbol[Symbol.iterator] = 42;
+
 // Test a number of different objects.
 testObjectMirror({}, 'Object', 'Object');
 testObjectMirror({'a':1,'b':2}, 'Object', 'Object');
@@ -180,6 +190,7 @@ testObjectMirror(this.__proto__, 'Object', '');
 testObjectMirror([], 'Array', 'Array');
 testObjectMirror([1,2], 'Array', 'Array');
 testObjectMirror(Object(17), 'Number', 'Number');
+testObjectMirror(object_with_symbol, 'Object', 'Object');

 // Test circular references.
 o = {};


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to