Chromium Code Reviews| 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1218 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + "}"; | 1195 this.callFrameId = "{\"ordinal\":" + ordinal + ",\"injectedScriptId\":" + in jectedScriptId + "}"; |
| 1219 this.functionName = callFrame.functionName; | 1196 this.functionName = callFrame.functionName; |
| 1220 this.functionLocation = { scriptId: toString(callFrame.sourceID), lineNumber : callFrame.functionLine, columnNumber: callFrame.functionColumn, __proto__: nul l }; | 1197 this.functionLocation = { scriptId: toString(callFrame.sourceID), lineNumber : callFrame.functionLine, columnNumber: callFrame.functionColumn, __proto__: nul l }; |
| 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 = { | |
| 1229 /** | |
| 1230 * @param {!JavaScriptCallFrame} callFrame | |
| 1231 * @return {!Array.<!DebuggerAgent.Scope>} | |
| 1232 */ | |
| 1233 _wrapScopeChain: function(callFrame) | |
| 1234 { | |
| 1235 var scopeChain = callFrame.scopeChain; | |
| 1236 var scopeChainProxy = []; | |
| 1237 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) ); | |
| 1239 return scopeChainProxy; | |
| 1240 }, | |
| 1241 | |
| 1242 __proto__: null | |
| 1243 } | |
| 1244 | |
| 1245 /** | 1205 /** |
| 1246 * @const | 1206 * @const |
| 1247 * @type {!Object.<number, !DebuggerAgent.ScopeType>} | 1207 * @type {!Object.<number, !DebuggerAgent.ScopeType>} |
| 1248 */ | 1208 */ |
| 1249 InjectedScript.CallFrameProxy._scopeTypeNames = { | 1209 InjectedScript.CallFrameProxy._scopeTypeNames = { |
|
dgozman
2016/03/18 23:27:55
Remove this, make JavaScriptCallFrame return strin
kozy
2016/03/19 00:40:23
Done.
| |
| 1250 0: "global", | 1210 0: "global", |
| 1251 1: "local", | 1211 1: "local", |
| 1252 2: "with", | 1212 2: "with", |
| 1253 3: "closure", | 1213 3: "closure", |
| 1254 4: "catch", | 1214 4: "catch", |
| 1255 5: "block", | 1215 5: "block", |
| 1256 6: "script", | 1216 6: "script", |
| 1257 __proto__: null | 1217 __proto__: null |
| 1258 }; | 1218 }; |
| 1259 | 1219 |
| 1260 /** | 1220 InjectedScript.CallFrameProxy.prototype = { |
| 1261 * @param {number} scopeTypeCode | 1221 /** |
| 1262 * @param {string} scopeName | 1222 * @param {!JavaScriptCallFrame} callFrame |
| 1263 * @param {*} scopeObject | 1223 * @return {!Array.<!DebuggerAgent.Scope>} |
| 1264 * @param {string} groupId | 1224 */ |
| 1265 * @param {?DebuggerAgent.Location=} startLocation | 1225 _wrapScopeChain: function(callFrame) |
| 1266 * @param {?DebuggerAgent.Location=} endLocation | 1226 { |
| 1267 * @return {!DebuggerAgent.Scope} | 1227 var scopeChain = callFrame.scopeChain; |
| 1268 */ | 1228 var scopeChainProxy = []; |
| 1269 InjectedScript.CallFrameProxy._createScopeJson = function(scopeTypeCode, scopeNa me, scopeObject, groupId, startLocation, endLocation) | 1229 for (var i = 0; i < scopeChain.length; ++i) |
| 1270 { | 1230 scopeChainProxy[i] = this._createScopeJson(callFrame.scopeType(i), c allFrame.scopeName(i), scopeChain[i], callFrame.scopeStartLocation(i), callFrame .scopeEndLocation(i) ); |
| 1271 var scope = { | 1231 return scopeChainProxy; |
| 1272 object: injectedScript._wrapObject(scopeObject, groupId), | 1232 }, |
| 1273 type: InjectedScript.CallFrameProxy._scopeTypeNames[scopeTypeCode], | |
| 1274 __proto__: null | |
| 1275 }; | |
| 1276 if (scopeName) | |
| 1277 scope.name = scopeName; | |
| 1278 | 1233 |
| 1279 if (startLocation) | 1234 /** |
| 1280 scope.startLocation = startLocation; | 1235 * @param {number} scopeTypeCode |
| 1281 if (endLocation) | 1236 * @param {string} scopeName |
| 1282 scope.endLocation = endLocation; | 1237 * @param {*} scopeObject |
| 1238 * @param {?DebuggerAgent.Location} startLocation | |
| 1239 * @param {?DebuggerAgent.Location} endLocation | |
| 1240 * @return {!DebuggerAgent.Scope} | |
| 1241 */ | |
| 1242 _createScopeJson: function(scopeTypeCode, scopeName, scopeObject, startLocat ion, endLocation) | |
| 1243 { | |
| 1244 var scope = { | |
| 1245 object: injectedScript._wrapObject(scopeObject, "backtrace"), | |
| 1246 type: InjectedScript.CallFrameProxy._scopeTypeNames[scopeTypeCode], | |
| 1247 __proto__: null | |
| 1248 }; | |
| 1249 if (scopeName) | |
| 1250 scope.name = scopeName; | |
| 1283 | 1251 |
| 1284 return scope; | 1252 if (startLocation) |
| 1253 scope.startLocation = startLocation; | |
| 1254 if (endLocation) | |
| 1255 scope.endLocation = endLocation; | |
| 1256 | |
| 1257 return scope; | |
| 1258 }, | |
| 1259 | |
| 1260 __proto__: null | |
| 1285 } | 1261 } |
| 1286 | 1262 |
| 1287 /** | 1263 /** |
| 1288 * @constructor | 1264 * @constructor |
| 1289 * @param {!CommandLineAPIImpl} commandLineAPIImpl | 1265 * @param {!CommandLineAPIImpl} commandLineAPIImpl |
| 1290 */ | 1266 */ |
| 1291 function CommandLineAPI(commandLineAPIImpl) | 1267 function CommandLineAPI(commandLineAPIImpl) |
| 1292 { | 1268 { |
| 1293 /** | 1269 /** |
| 1294 * @param {string} name The name of the method for which a toString method s hould be generated. | 1270 * @param {string} name The name of the method for which a toString method s hould be generated. |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1612 */ | 1588 */ |
| 1613 _logEvent: function(event) | 1589 _logEvent: function(event) |
| 1614 { | 1590 { |
| 1615 inspectedGlobalObject.console.log(event.type, event); | 1591 inspectedGlobalObject.console.log(event.type, event); |
| 1616 } | 1592 } |
| 1617 } | 1593 } |
| 1618 | 1594 |
| 1619 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); | 1595 injectedScript._commandLineAPIImpl = new CommandLineAPIImpl(); |
| 1620 return injectedScript; | 1596 return injectedScript; |
| 1621 }) | 1597 }) |
| OLD | NEW |