19258b6bc66e09368ada54001f619d53b4fc976d5ager@chromium.org// Copyright 2008 the V8 project authors. All rights reserved. 29a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Redistribution and use in source and binary forms, with or without 39a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// modification, are permitted provided that the following conditions are 49a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// met: 59a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 69a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions of source code must retain the above copyright 79a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// notice, this list of conditions and the following disclaimer. 89a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Redistributions in binary form must reproduce the above 99a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// copyright notice, this list of conditions and the following 109a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// disclaimer in the documentation and/or other materials provided 119a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// with the distribution. 129a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// * Neither the name of Google Inc. nor the names of its 139a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// contributors may be used to endorse or promote products derived 149a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// from this software without specific prior written permission. 159a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// 169a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 179a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 189a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 199a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 209a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 219a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 229a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 239a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 249a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 259a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 269a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 279a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 289a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Flags: --expose-debug-as debug 299a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Test the mirror object for unresolved functions. 309a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 313291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgfunction MirrorRefCache(json_refs) { 323291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org var tmp = eval('(' + json_refs + ')'); 333291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org this.refs_ = []; 343291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org for (var i = 0; i < tmp.length; i++) { 353291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org this.refs_[tmp[i].handle] = tmp[i]; 363291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org } 373291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org} 383291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org 393291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgMirrorRefCache.prototype.lookup = function(handle) { 403291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org return this.refs_[handle]; 413291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org} 423291210ab99f306b74430ebbc4b7d939629e699fager@chromium.org 439a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comvar mirror = new debug.UnresolvedFunctionMirror("f"); 443291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgvar serializer = debug.MakeMirrorSerializer(); 45b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.orgvar json = JSON.stringify(serializer.serializeValue(mirror)); 46b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.orgvar refs = new MirrorRefCache( 47b3284ad36ee358a35b81379ad1c449e4f8021362kasperl@chromium.org JSON.stringify(serializer.serializeReferencedObjects())); 489a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 499a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Check the mirror hierachy for unresolved functions. 509a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(mirror instanceof debug.Mirror); 519a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(mirror instanceof debug.ValueMirror); 529a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(mirror instanceof debug.ObjectMirror); 539a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(mirror instanceof debug.FunctionMirror); 549a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com 559a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Check the mirror properties for unresolved functions. 569a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertTrue(mirror.isUnresolvedFunction()); 579a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('function', mirror.type()); 589a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertFalse(mirror.isPrimitive()); 599a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals("Function", mirror.className()); 609a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals("f", mirror.name()); 619085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.orgassertEquals('undefined', typeof mirror.inferredName()); 629a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertFalse(mirror.resolved()); 639a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals(void 0, mirror.source()); 649a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', mirror.constructorFunction().type()); 659a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', mirror.protoObject().type()); 669a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals('undefined', mirror.prototypeObject().type()); 671805e21b0aece8c05f4960a5c0751c4463557891fschneider@chromium.org 689a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.com// Parse JSON representation of unresolved functions and check. 693291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgvar fromJSON = eval('(' + json + ')'); 703291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals('function', fromJSON.type, 'Unexpected mirror type in JSON'); 713291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals('Function', fromJSON.className, 'Unexpected mirror class name in JSON'); 723291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals(mirror.constructorFunction().handle(), fromJSON.constructorFunction.ref, 'Unexpected constructor function handle in JSON'); 733291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals('undefined', refs.lookup(fromJSON.constructorFunction.ref).type, 'Unexpected constructor function type in JSON'); 743291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals(mirror.protoObject().handle(), fromJSON.protoObject.ref, 'Unexpected proto object handle in JSON'); 753291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals('undefined', refs.lookup(fromJSON.protoObject.ref).type, 'Unexpected proto object type in JSON'); 763291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals(mirror.prototypeObject().handle(), fromJSON.prototypeObject.ref, 'Unexpected prototype object handle in JSON'); 773291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals('undefined', refs.lookup(fromJSON.prototypeObject.ref).type, 'Unexpected prototype object type in JSON'); 789a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertFalse(fromJSON.resolved); 799a4089a092cad9ff23b6416b92cd5d818dc101d1mads.s.ager@gmail.comassertEquals("f", fromJSON.name); 809085a016223a6b72bf580d5781c93ec7b9e54422ager@chromium.orgassertFalse('inferredName' in fromJSON); 813291210ab99f306b74430ebbc4b7d939629e699fager@chromium.orgassertEquals(void 0, fromJSON.source); 82