OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
104 assertEquals(ctor_name, refs.lookup(fromJSON.constructorFunction.ref).name, 'U nexpected constructor function name in JSON'); | 104 assertEquals(ctor_name, refs.lookup(fromJSON.constructorFunction.ref).name, 'U nexpected constructor function name in JSON'); |
105 assertEquals(mirror.protoObject().handle(), fromJSON.protoObject.ref, 'Unexpec ted proto object handle in JSON'); | 105 assertEquals(mirror.protoObject().handle(), fromJSON.protoObject.ref, 'Unexpec ted proto object handle in JSON'); |
106 assertEquals(mirror.protoObject().type(), refs.lookup(fromJSON.protoObject.ref ).type, 'Unexpected proto object type in JSON'); | 106 assertEquals(mirror.protoObject().type(), refs.lookup(fromJSON.protoObject.ref ).type, 'Unexpected proto object type in JSON'); |
107 assertEquals(mirror.prototypeObject().handle(), fromJSON.prototypeObject.ref, 'Unexpected prototype object handle in JSON'); | 107 assertEquals(mirror.prototypeObject().handle(), fromJSON.prototypeObject.ref, 'Unexpected prototype object handle in JSON'); |
108 assertEquals(mirror.prototypeObject().type(), refs.lookup(fromJSON.prototypeOb ject.ref).type, 'Unexpected prototype object type in JSON'); | 108 assertEquals(mirror.prototypeObject().type(), refs.lookup(fromJSON.prototypeOb ject.ref).type, 'Unexpected prototype object type in JSON'); |
109 assertEquals(void 0, fromJSON.namedInterceptor, 'No named interceptor expected in JSON'); | 109 assertEquals(void 0, fromJSON.namedInterceptor, 'No named interceptor expected in JSON'); |
110 assertEquals(void 0, fromJSON.indexedInterceptor, 'No indexed interceptor expe cted in JSON'); | 110 assertEquals(void 0, fromJSON.indexedInterceptor, 'No indexed interceptor expe cted in JSON'); |
111 | 111 |
112 // Check that the serialization contains all properties. | 112 // Check that the serialization contains all properties. |
113 assertEquals(names.length, fromJSON.properties.length, 'Some properties missin g in JSON'); | 113 assertEquals(names.length, fromJSON.properties.length, 'Some properties missin g in JSON'); |
114 for (var i = 0; i < fromJSON.properties.length; i++) { | 114 for (var j = 0; j < names.length; j++) { |
115 var name = fromJSON.properties[i].name; | 115 var name = names[j]; |
116 if (typeof name == 'undefined') name = fromJSON.properties[i].index; | 116 // Serialization of symbol-named properties to JSON doesn't really |
rossberg
2014/08/06 15:54:34
This isn't ever supposed to work; symbol propertie
| |
117 // work currently, as they don't get a {name: ...} entry. | |
118 if (typeof name === 'symbol') continue; | |
117 var found = false; | 119 var found = false; |
118 for (var j = 0; j < names.length; j++) { | 120 for (var i = 0; i < fromJSON.properties.length; i++) { |
119 if (names[j] == name) { | 121 if (fromJSON.properties[i].name == name) { |
120 // Check that serialized handle is correct. | 122 // Check that serialized handle is correct. |
121 assertEquals(properties[i].value().handle(), fromJSON.properties[i].ref, 'Unexpected serialized handle'); | 123 assertEquals(properties[i].value().handle(), fromJSON.properties[i].ref, 'Unexpected serialized handle'); |
122 | 124 |
123 // Check that serialized name is correct. | 125 // Check that serialized name is correct. |
124 assertEquals(properties[i].name(), fromJSON.properties[i].name, 'Unexpec ted serialized name'); | 126 assertEquals(properties[i].name(), fromJSON.properties[i].name, 'Unexpec ted serialized name'); |
125 | 127 |
126 // If property type is normal property type is not serialized. | 128 // If property type is normal property type is not serialized. |
127 if (properties[i].propertyType() != debug.PropertyType.Normal) { | 129 if (properties[i].propertyType() != debug.PropertyType.Normal) { |
128 assertEquals(properties[i].propertyType(), fromJSON.properties[i].prop ertyType, 'Unexpected serialized property type'); | 130 assertEquals(properties[i].propertyType(), fromJSON.properties[i].prop ertyType, 'Unexpected serialized property type'); |
129 } else { | 131 } else { |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
163 assertTrue(found, '"' + name + '" not found (' + json + ')'); | 165 assertTrue(found, '"' + name + '" not found (' + json + ')'); |
164 } | 166 } |
165 } | 167 } |
166 | 168 |
167 | 169 |
168 function Point(x,y) { | 170 function Point(x,y) { |
169 this.x_ = x; | 171 this.x_ = x; |
170 this.y_ = y; | 172 this.y_ = y; |
171 } | 173 } |
172 | 174 |
175 var object_with_symbol = {}; | |
176 object_with_symbol[Symbol.iterator] = 42; | |
177 | |
173 // Test a number of different objects. | 178 // Test a number of different objects. |
174 testObjectMirror({}, 'Object', 'Object'); | 179 testObjectMirror({}, 'Object', 'Object'); |
175 testObjectMirror({'a':1,'b':2}, 'Object', 'Object'); | 180 testObjectMirror({'a':1,'b':2}, 'Object', 'Object'); |
176 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object'); | 181 testObjectMirror({'1':void 0,'2':null,'f':function pow(x,y){return Math.pow(x,y) ;}}, 'Object', 'Object'); |
177 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); | 182 testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); |
178 testObjectMirror(this, 'global', '', true); // Global object has special proper ties | 183 testObjectMirror(this, 'global', '', true); // Global object has special proper ties |
179 testObjectMirror(this.__proto__, 'Object', ''); | 184 testObjectMirror(this.__proto__, 'Object', ''); |
180 testObjectMirror([], 'Array', 'Array'); | 185 testObjectMirror([], 'Array', 'Array'); |
181 testObjectMirror([1,2], 'Array', 'Array'); | 186 testObjectMirror([1,2], 'Array', 'Array'); |
182 testObjectMirror(Object(17), 'Number', 'Number'); | 187 testObjectMirror(Object(17), 'Number', 'Number'); |
188 testObjectMirror(object_with_symbol, 'Object', 'Object'); | |
183 | 189 |
184 // Test circular references. | 190 // Test circular references. |
185 o = {}; | 191 o = {}; |
186 o.o = o; | 192 o.o = o; |
187 testObjectMirror(o, 'Object', 'Object'); | 193 testObjectMirror(o, 'Object', 'Object'); |
188 | 194 |
189 // Test that non enumerable properties are part of the mirror | 195 // Test that non enumerable properties are part of the mirror |
190 global_mirror = debug.MakeMirror(this); | 196 global_mirror = debug.MakeMirror(this); |
191 assertEquals('property', global_mirror.property("Math").type()); | 197 assertEquals('property', global_mirror.property("Math").type()); |
192 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes()); | 198 assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + glob al_mirror.property("Math").attributes()); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 } | 263 } |
258 assertTrue("[[BoundThis]]" in property_map); | 264 assertTrue("[[BoundThis]]" in property_map); |
259 assertEquals("function", property_map["[[BoundThis]]"].value().type()); | 265 assertEquals("function", property_map["[[BoundThis]]"].value().type()); |
260 assertEquals(Array, property_map["[[BoundThis]]"].value().value()); | 266 assertEquals(Array, property_map["[[BoundThis]]"].value().value()); |
261 assertTrue("[[TargetFunction]]" in property_map); | 267 assertTrue("[[TargetFunction]]" in property_map); |
262 assertEquals("function", property_map["[[TargetFunction]]"].value().type()); | 268 assertEquals("function", property_map["[[TargetFunction]]"].value().type()); |
263 assertEquals(Number, property_map["[[TargetFunction]]"].value().value()); | 269 assertEquals(Number, property_map["[[TargetFunction]]"].value().value()); |
264 assertTrue("[[BoundArgs]]" in property_map); | 270 assertTrue("[[BoundArgs]]" in property_map); |
265 assertEquals("object", property_map["[[BoundArgs]]"].value().type()); | 271 assertEquals("object", property_map["[[BoundArgs]]"].value().type()); |
266 assertEquals(1, property_map["[[BoundArgs]]"].value().value().length); | 272 assertEquals(1, property_map["[[BoundArgs]]"].value().value().length); |
OLD | NEW |