mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | // Flags: --expose-debug-as debug |
| 29 | // Test the mirror object for objects |
| 30 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 31 | function MirrorRefCache(json_refs) { |
| 32 | var tmp = eval('(' + json_refs + ')'); |
| 33 | this.refs_ = []; |
| 34 | for (var i = 0; i < tmp.length; i++) { |
| 35 | this.refs_[tmp[i].handle] = tmp[i]; |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | MirrorRefCache.prototype.lookup = function(handle) { |
| 40 | return this.refs_[handle]; |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 41 | }; |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 42 | |
| 43 | function testObjectMirror(obj, cls_name, ctor_name, hasSpecialProperties) { |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 44 | // Create mirror and JSON representation. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 45 | var mirror = debug.MakeMirror(obj); |
| 46 | var serializer = debug.MakeMirrorSerializer(); |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 47 | var json = JSON.stringify(serializer.serializeValue(mirror)); |
| 48 | var refs = new MirrorRefCache( |
| 49 | JSON.stringify(serializer.serializeReferencedObjects())); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 50 | |
| 51 | // Check the mirror hierachy. |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 52 | assertTrue(mirror instanceof debug.Mirror, 'Unexpected mirror hierarchy'); |
| 53 | assertTrue(mirror instanceof debug.ValueMirror, 'Unexpected mirror hierarchy'); |
| 54 | assertTrue(mirror instanceof debug.ObjectMirror, 'Unexpected mirror hierarchy'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 55 | |
| 56 | // Check the mirror properties. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 57 | assertTrue(mirror.isObject(), 'Unexpected mirror'); |
| 58 | assertEquals('object', mirror.type(), 'Unexpected mirror type'); |
| 59 | assertFalse(mirror.isPrimitive(), 'Unexpected primitive mirror'); |
| 60 | assertEquals(cls_name, mirror.className(), 'Unexpected mirror class name'); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 61 | assertTrue(mirror.constructorFunction() instanceof debug.ObjectMirror, 'Unexpected mirror hierarchy'); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 62 | assertEquals(ctor_name, mirror.constructorFunction().name(), 'Unexpected constructor function name'); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 63 | assertTrue(mirror.protoObject() instanceof debug.Mirror, 'Unexpected mirror hierarchy'); |
| 64 | assertTrue(mirror.prototypeObject() instanceof debug.Mirror, 'Unexpected mirror hierarchy'); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 65 | assertFalse(mirror.hasNamedInterceptor(), 'No named interceptor expected'); |
| 66 | assertFalse(mirror.hasIndexedInterceptor(), 'No indexed interceptor expected'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 67 | |
| 68 | var names = mirror.propertyNames(); |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 69 | var properties = mirror.properties(); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 70 | assertEquals(names.length, properties.length); |
| 71 | for (var i = 0; i < properties.length; i++) { |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 72 | assertTrue(properties[i] instanceof debug.Mirror, 'Unexpected mirror hierarchy'); |
| 73 | assertTrue(properties[i] instanceof debug.PropertyMirror, 'Unexpected mirror hierarchy'); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 74 | assertEquals('property', properties[i].type(), 'Unexpected mirror type'); |
| 75 | assertEquals(names[i], properties[i].name(), 'Unexpected property name'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 76 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 77 | |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 78 | var internalProperties = mirror.internalProperties(); |
| 79 | for (var i = 0; i < internalProperties.length; i++) { |
| 80 | assertTrue(internalProperties[i] instanceof debug.Mirror, 'Unexpected mirror hierarchy'); |
| 81 | assertTrue(internalProperties[i] instanceof debug.InternalPropertyMirror, 'Unexpected mirror hierarchy'); |
| 82 | assertEquals('internalProperty', internalProperties[i].type(), 'Unexpected mirror type'); |
| 83 | } |
| 84 | |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 85 | for (var p in obj) { |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 86 | var property_mirror = mirror.property(p); |
| 87 | assertTrue(property_mirror instanceof debug.PropertyMirror); |
| 88 | assertEquals(p, property_mirror.name()); |
| 89 | // If the object has some special properties don't test for these. |
| 90 | if (!hasSpecialProperties) { |
| 91 | assertEquals(0, property_mirror.attributes(), property_mirror.name()); |
| 92 | assertFalse(property_mirror.isReadOnly()); |
| 93 | assertTrue(property_mirror.isEnum()); |
| 94 | assertTrue(property_mirror.canDelete()); |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | // Parse JSON representation and check. |
| 99 | var fromJSON = eval('(' + json + ')'); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 100 | assertEquals('object', fromJSON.type, 'Unexpected mirror type in JSON'); |
| 101 | assertEquals(cls_name, fromJSON.className, 'Unexpected mirror class name in JSON'); |
| 102 | assertEquals(mirror.constructorFunction().handle(), fromJSON.constructorFunction.ref, 'Unexpected constructor function handle in JSON'); |
| 103 | assertEquals('function', refs.lookup(fromJSON.constructorFunction.ref).type, 'Unexpected constructor function type in JSON'); |
| 104 | assertEquals(ctor_name, refs.lookup(fromJSON.constructorFunction.ref).name, 'Unexpected constructor function name in JSON'); |
| 105 | assertEquals(mirror.protoObject().handle(), fromJSON.protoObject.ref, 'Unexpected proto object handle 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'); |
| 108 | assertEquals(mirror.prototypeObject().type(), refs.lookup(fromJSON.prototypeObject.ref).type, 'Unexpected prototype object type in JSON'); |
| 109 | assertEquals(void 0, fromJSON.namedInterceptor, 'No named interceptor expected in JSON'); |
| 110 | assertEquals(void 0, fromJSON.indexedInterceptor, 'No indexed interceptor expected in JSON'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 111 | |
| 112 | // Check that the serialization contains all properties. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 113 | assertEquals(names.length, fromJSON.properties.length, 'Some properties missing in JSON'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 114 | for (var i = 0; i < fromJSON.properties.length; i++) { |
| 115 | var name = fromJSON.properties[i].name; |
kasperl@chromium.org | b3284ad | 2009-05-18 06:12:45 +0000 | [diff] [blame] | 116 | if (typeof name == 'undefined') name = fromJSON.properties[i].index; |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 117 | var found = false; |
| 118 | for (var j = 0; j < names.length; j++) { |
| 119 | if (names[j] == name) { |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 120 | // Check that serialized handle is correct. |
| 121 | assertEquals(properties[i].value().handle(), fromJSON.properties[i].ref, 'Unexpected serialized handle'); |
| 122 | |
| 123 | // Check that serialized name is correct. |
| 124 | assertEquals(properties[i].name(), fromJSON.properties[i].name, 'Unexpected serialized name'); |
| 125 | |
| 126 | // If property type is normal property type is not serialized. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 127 | if (properties[i].propertyType() != debug.PropertyType.Normal) { |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 128 | assertEquals(properties[i].propertyType(), fromJSON.properties[i].propertyType, 'Unexpected serialized property type'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 129 | } else { |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 130 | assertTrue(typeof(fromJSON.properties[i].propertyType) === 'undefined', 'Unexpected serialized property type'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 131 | } |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 132 | |
| 133 | // If there are no attributes attributes are not serialized. |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 134 | if (properties[i].attributes() != debug.PropertyAttribute.None) { |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 135 | assertEquals(properties[i].attributes(), fromJSON.properties[i].attributes, 'Unexpected serialized attributes'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 136 | } else { |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 137 | assertTrue(typeof(fromJSON.properties[i].attributes) === 'undefined', 'Unexpected serialized attributes'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 138 | } |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 139 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 140 | // Lookup the serialized object from the handle reference. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 141 | var o = refs.lookup(fromJSON.properties[i].ref); |
| 142 | assertTrue(o != void 0, 'Referenced object is not serialized'); |
| 143 | |
| 144 | assertEquals(properties[i].value().type(), o.type, 'Unexpected serialized property type for ' + name); |
| 145 | if (properties[i].value().isPrimitive()) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 146 | if (properties[i].value().type() == "null" || |
| 147 | properties[i].value().type() == "undefined") { |
| 148 | // Null and undefined has no value property. |
| 149 | assertFalse("value" in o, 'Unexpected value property for ' + name); |
| 150 | } else if (properties[i].value().type() == "number" && |
| 151 | !isFinite(properties[i].value().value())) { |
| 152 | assertEquals(String(properties[i].value().value()), o.value, |
| 153 | 'Unexpected serialized property value for ' + name); |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 154 | } else { |
| 155 | assertEquals(properties[i].value().value(), o.value, 'Unexpected serialized property value for ' + name); |
| 156 | } |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 157 | } else if (properties[i].value().isFunction()) { |
| 158 | assertEquals(properties[i].value().source(), o.source, 'Unexpected serialized property value for ' + name); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 159 | } |
| 160 | found = true; |
| 161 | } |
| 162 | } |
christian.plesner.hansen@gmail.com | aca4968 | 2009-01-07 14:29:04 +0000 | [diff] [blame] | 163 | assertTrue(found, '"' + name + '" not found (' + json + ')'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
| 167 | |
| 168 | function Point(x,y) { |
| 169 | this.x_ = x; |
| 170 | this.y_ = y; |
| 171 | } |
| 172 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 173 | // Test a number of different objects. |
| 174 | testObjectMirror({}, 'Object', 'Object'); |
| 175 | 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'); |
| 177 | testObjectMirror(new Point(-1.2,2.003), 'Object', 'Point'); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 178 | testObjectMirror(this, 'global', '', true); // Global object has special properties |
ager@chromium.org | ddb913d | 2009-01-27 10:01:48 +0000 | [diff] [blame] | 179 | testObjectMirror(this.__proto__, 'Object', ''); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 180 | testObjectMirror([], 'Array', 'Array'); |
| 181 | testObjectMirror([1,2], 'Array', 'Array'); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 182 | testObjectMirror(Object(17), 'Number', 'Number'); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 183 | |
christian.plesner.hansen@gmail.com | aca4968 | 2009-01-07 14:29:04 +0000 | [diff] [blame] | 184 | // Test circular references. |
| 185 | o = {}; |
| 186 | o.o = o; |
| 187 | testObjectMirror(o, 'Object', 'Object'); |
| 188 | |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 189 | // Test that non enumerable properties are part of the mirror |
| 190 | global_mirror = debug.MakeMirror(this); |
| 191 | assertEquals('property', global_mirror.property("Math").type()); |
| 192 | assertFalse(global_mirror.property("Math").isEnum(), "Math is enumerable" + global_mirror.property("Math").attributes()); |
| 193 | |
| 194 | math_mirror = global_mirror.property("Math").value(); |
| 195 | assertEquals('property', math_mirror.property("E").type()); |
| 196 | assertFalse(math_mirror.property("E").isEnum(), "Math.E is enumerable"); |
| 197 | assertTrue(math_mirror.property("E").isReadOnly()); |
| 198 | assertFalse(math_mirror.property("E").canDelete()); |
| 199 | |
| 200 | // Test objects with JavaScript accessors. |
| 201 | o = {} |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 202 | o.__defineGetter__('a', function(){return 'a';}); |
| 203 | o.__defineSetter__('b', function(){}); |
| 204 | o.__defineGetter__('c', function(){throw 'c';}); |
| 205 | o.__defineSetter__('c', function(){throw 'c';}); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 206 | testObjectMirror(o, 'Object', 'Object'); |
| 207 | mirror = debug.MakeMirror(o); |
| 208 | // a has getter but no setter. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 209 | assertTrue(mirror.property('a').hasGetter()); |
| 210 | assertFalse(mirror.property('a').hasSetter()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 211 | assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType()); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 212 | assertEquals('function', mirror.property('a').getter().type()); |
| 213 | assertEquals('undefined', mirror.property('a').setter().type()); |
| 214 | assertEquals('function (){return \'a\';}', mirror.property('a').getter().source()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 215 | // b has setter but no getter. |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 216 | assertFalse(mirror.property('b').hasGetter()); |
| 217 | assertTrue(mirror.property('b').hasSetter()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 218 | assertEquals(debug.PropertyType.Callbacks, mirror.property('b').propertyType()); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 219 | assertEquals('undefined', mirror.property('b').getter().type()); |
| 220 | assertEquals('function', mirror.property('b').setter().type()); |
| 221 | assertEquals('function (){}', mirror.property('b').setter().source()); |
| 222 | assertFalse(mirror.property('b').isException()); |
| 223 | // c has both getter and setter. The getter throws an exception. |
| 224 | assertTrue(mirror.property('c').hasGetter()); |
| 225 | assertTrue(mirror.property('c').hasSetter()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 226 | assertEquals(debug.PropertyType.Callbacks, mirror.property('c').propertyType()); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 227 | assertEquals('function', mirror.property('c').getter().type()); |
| 228 | assertEquals('function', mirror.property('c').setter().type()); |
| 229 | assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source()); |
| 230 | assertEquals('function (){throw \'c\';}', mirror.property('c').setter().source()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 231 | |
| 232 | // Test objects with native accessors. |
| 233 | mirror = debug.MakeMirror(new String('abc')); |
| 234 | assertTrue(mirror instanceof debug.ObjectMirror); |
ager@chromium.org | 3291210 | 2009-01-16 10:38:43 +0000 | [diff] [blame] | 235 | assertFalse(mirror.property('length').hasGetter()); |
| 236 | assertFalse(mirror.property('length').hasSetter()); |
| 237 | assertTrue(mirror.property('length').isNative()); |
mads.s.ager@gmail.com | 9a4089a | 2008-09-01 08:55:01 +0000 | [diff] [blame] | 238 | assertEquals('a', mirror.property(0).value().value()); |
| 239 | assertEquals('b', mirror.property(1).value().value()); |
| 240 | assertEquals('c', mirror.property(2).value().value()); |
mstarzinger@chromium.org | de88679 | 2012-09-11 13:22:37 +0000 | [diff] [blame] | 241 | |
| 242 | // Test value wrapper internal properties. |
| 243 | mirror = debug.MakeMirror(Object("Capybara")); |
| 244 | var ip = mirror.internalProperties(); |
| 245 | assertEquals(1, ip.length); |
| 246 | assertEquals("[[PrimitiveValue]]", ip[0].name()); |
| 247 | assertEquals("string", ip[0].value().type()); |
| 248 | assertEquals("Capybara", ip[0].value().value()); |
| 249 | |
| 250 | // Test bound function internal properties. |
| 251 | mirror = debug.MakeMirror(Number.bind(Array, 2)); |
| 252 | ip = mirror.internalProperties(); |
| 253 | assertEquals(3, ip.length); |
| 254 | var property_map = {}; |
| 255 | for (var i = 0; i < ip.length; i++) { |
| 256 | property_map[ip[i].name()] = ip[i]; |
| 257 | } |
| 258 | assertTrue("[[BoundThis]]" in property_map); |
| 259 | assertEquals("function", property_map["[[BoundThis]]"].value().type()); |
| 260 | assertEquals(Array, property_map["[[BoundThis]]"].value().value()); |
| 261 | assertTrue("[[TargetFunction]]" in property_map); |
| 262 | assertEquals("function", property_map["[[TargetFunction]]"].value().type()); |
| 263 | assertEquals(Number, property_map["[[TargetFunction]]"].value().value()); |
| 264 | assertTrue("[[BoundArgs]]" in property_map); |
| 265 | assertEquals("object", property_map["[[BoundArgs]]"].value().type()); |
| 266 | assertEquals(1, property_map["[[BoundArgs]]"].value().value().length); |