| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 if (!("enumerable" in descriptor)) | 443 if (!("enumerable" in descriptor)) |
| 444 descriptor.enumerable = false; | 444 descriptor.enumerable = false; |
| 445 if ("symbol" in descriptor) | 445 if ("symbol" in descriptor) |
| 446 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr
oupName); | 446 descriptor.symbol = this._wrapObject(descriptor.symbol, objectGr
oupName); |
| 447 push(descriptors, descriptor); | 447 push(descriptors, descriptor); |
| 448 } | 448 } |
| 449 return descriptors; | 449 return descriptors; |
| 450 }, | 450 }, |
| 451 | 451 |
| 452 /** | 452 /** |
| 453 * @param {string} functionId | |
| 454 * @return {!DebuggerAgent.FunctionDetails|string} | |
| 455 */ | |
| 456 getFunctionDetails: function(functionId) | |
| 457 { | |
| 458 var parsedFunctionId = this._parseObjectId(functionId); | |
| 459 var func = this._objectForId(parsedFunctionId); | |
| 460 if (typeof func !== "function") | |
| 461 return "Cannot resolve function by id."; | |
| 462 var details = nullifyObjectProto(/** @type {!DebuggerAgent.FunctionDetai
ls} */ (InjectedScriptHost.functionDetails(func))); | |
| 463 if ("rawScopes" in details) { | |
| 464 var objectGroupName = InjectedScriptHost.idToObjectGroupName(parsedF
unctionId.id); | |
| 465 var rawScopes = details["rawScopes"]; | |
| 466 delete details["rawScopes"]; | |
| 467 var scopes = []; | |
| 468 for (var i = 0; i < rawScopes.length; ++i) | |
| 469 scopes[i] = InjectedScript.CallFrameProxy._createScopeJson(rawSc
opes[i].type, rawScopes[i].name, rawScopes[i].object, objectGroupName); | |
| 470 details.scopeChain = scopes; | |
| 471 } | |
| 472 return details; | |
| 473 }, | |
| 474 | |
| 475 /** | |
| 476 * @param {string} objectId | 453 * @param {string} objectId |
| 477 * @return {!Array.<!Object>|string} | 454 * @return {!Array.<!Object>|string} |
| 478 */ | 455 */ |
| 479 getCollectionEntries: function(objectId) | 456 getCollectionEntries: function(objectId) |
| 480 { | 457 { |
| 481 var parsedObjectId = this._parseObjectId(objectId); | 458 var parsedObjectId = this._parseObjectId(objectId); |
| 482 var object = this._objectForId(parsedObjectId); | 459 var object = this._objectForId(parsedObjectId); |
| 483 if (!object || typeof object !== "object") | 460 if (!object || typeof object !== "object") |
| 484 return "Could not find object with given id"; | 461 return "Could not find object with given id"; |
| 485 var entries = InjectedScriptHost.collectionEntries(object); | 462 var entries = InjectedScriptHost.collectionEntries(object); |
| (...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1221 this.location = { scriptId: toString(callFrame.sourceID), lineNumber: callFr
ame.line, columnNumber: callFrame.column, __proto__: null }; | 1198 this.location = { scriptId: toString(callFrame.sourceID), lineNumber: callFr
ame.line, columnNumber: callFrame.column, __proto__: null }; |
| 1222 this.scopeChain = this._wrapScopeChain(callFrame); | 1199 this.scopeChain = this._wrapScopeChain(callFrame); |
| 1223 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); | 1200 this.this = injectedScript._wrapObject(callFrame.thisObject, "backtrace"); |
| 1224 if (callFrame.isAtReturn) | 1201 if (callFrame.isAtReturn) |
| 1225 this.returnValue = injectedScript._wrapObject(callFrame.returnValue, "ba
cktrace"); | 1202 this.returnValue = injectedScript._wrapObject(callFrame.returnValue, "ba
cktrace"); |
| 1226 } | 1203 } |
| 1227 | 1204 |
| 1228 InjectedScript.CallFrameProxy.prototype = { | 1205 InjectedScript.CallFrameProxy.prototype = { |
| 1229 /** | 1206 /** |
| 1230 * @param {!JavaScriptCallFrame} callFrame | 1207 * @param {!JavaScriptCallFrame} callFrame |
| 1231 * @return {!Array.<!DebuggerAgent.Scope>} | 1208 * @return {!Array<!DebuggerAgent.Scope>} |
| 1232 */ | 1209 */ |
| 1233 _wrapScopeChain: function(callFrame) | 1210 _wrapScopeChain: function(callFrame) |
| 1234 { | 1211 { |
| 1235 var scopeChain = callFrame.scopeChain; | 1212 var scopeChain = callFrame.scopeChain; |
| 1236 var scopeChainProxy = []; | 1213 var scopeChainProxy = []; |
| 1237 for (var i = 0; i < scopeChain.length; ++i) | 1214 for (var i = 0; i < scopeChain.length; ++i) |
| 1238 scopeChainProxy[i] = InjectedScript.CallFrameProxy._createScopeJson(
callFrame.scopeType(i), callFrame.scopeName(i), scopeChain[i], "backtrace", call
Frame.scopeStartLocation(i), callFrame.scopeEndLocation(i) ); | 1215 scopeChainProxy[i] = this._createScopeJson(callFrame.scopeType(i), c
allFrame.scopeName(i), scopeChain[i], callFrame.scopeStartLocation(i), callFrame
.scopeEndLocation(i) ); |
| 1239 return scopeChainProxy; | 1216 return scopeChainProxy; |
| 1240 }, | 1217 }, |
| 1241 | 1218 |
| 1219 /** |
| 1220 * @param {!DebuggerAgent.ScopeType<string>} scopeType |
| 1221 * @param {string} scopeName |
| 1222 * @param {*} scopeObject |
| 1223 * @param {?DebuggerAgent.Location} startLocation |
| 1224 * @param {?DebuggerAgent.Location} endLocation |
| 1225 * @return {!DebuggerAgent.Scope} |
| 1226 */ |
| 1227 _createScopeJson: function(scopeType, scopeName, scopeObject, startLocation,
endLocation) |
| 1228 { |
| 1229 var scope = { |
| 1230 object: injectedScript._wrapObject(scopeObject, "backtrace"), |
| 1231 type: scopeType, |
| 1232 __proto__: null |
| 1233 }; |
| 1234 if (scopeName) |
| 1235 scope.name = scopeName; |
| 1236 |
| 1237 if (startLocation) |
| 1238 scope.startLocation = startLocation; |
| 1239 if (endLocation) |
| 1240 scope.endLocation = endLocation; |
| 1241 |
| 1242 return scope; |
| 1243 }, |
| 1244 |
| 1242 __proto__: null | 1245 __proto__: null |
| 1243 } | 1246 } |
| 1244 | 1247 |
| 1245 /** | 1248 /** |
| 1246 * @const | |
| 1247 * @type {!Object.<number, !DebuggerAgent.ScopeType>} | |
| 1248 */ | |
| 1249 InjectedScript.CallFrameProxy._scopeTypeNames = { | |
| 1250 0: "global", | |
| 1251 1: "local", | |
| 1252 2: "with", | |
| 1253 3: "closure", | |
| 1254 4: "catch", | |
| 1255 5: "block", | |
| 1256 6: "script", | |
| 1257 __proto__: null | |
| 1258 }; | |
| 1259 | |
| 1260 /** | |
| 1261 * @param {number} scopeTypeCode | |
| 1262 * @param {string} scopeName | |
| 1263 * @param {*} scopeObject | |
| 1264 * @param {string} groupId | |
| 1265 * @param {?DebuggerAgent.Location=} startLocation | |
| 1266 * @param {?DebuggerAgent.Location=} endLocation | |
| 1267 * @return {!DebuggerAgent.Scope} | |
| 1268 */ | |
| 1269 InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeNa
me, scopeObject, groupId, startLocation, endLocation) | |
| 1270 { | |
| 1271 var scope = { | |
| 1272 object: injectedScript._wrapObject(scopeObject, groupId), | |
| 1273 type: InjectedScript.CallFrameProxy._scopeTypeNames[scopeTypeCode], | |
| 1274 __proto__: null | |
| 1275 }; | |
| 1276 if (scopeName) | |
| 1277 scope.name = scopeName; | |
| 1278 | |
| 1279 if (startLocation) | |
| 1280 scope.startLocation = startLocation; | |
| 1281 if (endLocation) | |
| 1282 scope.endLocation = endLocation; | |
| 1283 | |
| 1284 return scope; | |
| 1285 } | |
| 1286 | |
| 1287 /** | |
| 1288 * @constructor | 1249 * @constructor |
| 1289 * @param {!CommandLineAPIImpl} commandLineAPIImpl | 1250 * @param {!CommandLineAPIImpl} commandLineAPIImpl |
| 1290 */ | 1251 */ |
| 1291 function CommandLineAPI(commandLineAPIImpl) | 1252 function CommandLineAPI(commandLineAPIImpl) |
| 1292 { | 1253 { |
| 1293 /** | 1254 /** |
| 1294 * @param {string} name The name of the method for which a toString method s
hould be generated. | 1255 * @param {string} name The name of the method for which a toString method s
hould be generated. |
| 1295 * @return {function():string} | 1256 * @return {function():string} |
| 1296 */ | 1257 */ |
| 1297 function customToStringMethod(name) | 1258 function customToStringMethod(name) |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1612 */ | 1573 */ |
| 1613 _logEvent: function(event) | 1574 _logEvent: function(event) |
| 1614 { | 1575 { |
| 1615 inspectedGlobalObject.console.log(event.type, event); | 1576 inspectedGlobalObject.console.log(event.type, event); |
| 1616 } | 1577 } |
| 1617 } | 1578 } |
| 1618 | 1579 |
| 1619 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1580 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1620 return injectedScript; | 1581 return injectedScript; |
| 1621 }) | 1582 }) |
| OLD | NEW |