OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 1221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1232 * @param {!RuntimeAgent.StackTrace=} asyncStackTrace | 1232 * @param {!RuntimeAgent.StackTrace=} asyncStackTrace |
1233 */ | 1233 */ |
1234 WebInspector.DebuggerPausedDetails = function(debuggerModel, callFrames, reason,
auxData, breakpointIds, asyncStackTrace) | 1234 WebInspector.DebuggerPausedDetails = function(debuggerModel, callFrames, reason,
auxData, breakpointIds, asyncStackTrace) |
1235 { | 1235 { |
1236 WebInspector.SDKObject.call(this, debuggerModel.target()); | 1236 WebInspector.SDKObject.call(this, debuggerModel.target()); |
1237 this.debuggerModel = debuggerModel; | 1237 this.debuggerModel = debuggerModel; |
1238 this.callFrames = WebInspector.DebuggerModel.CallFrame.fromPayloadArray(debu
ggerModel, callFrames); | 1238 this.callFrames = WebInspector.DebuggerModel.CallFrame.fromPayloadArray(debu
ggerModel, callFrames); |
1239 this.reason = reason; | 1239 this.reason = reason; |
1240 this.auxData = auxData; | 1240 this.auxData = auxData; |
1241 this.breakpointIds = breakpointIds; | 1241 this.breakpointIds = breakpointIds; |
1242 this.asyncStackTrace = asyncStackTrace; | 1242 if (asyncStackTrace) |
| 1243 this.asyncStackTrace = this._cleanRedundantFrames(asyncStackTrace); |
1243 } | 1244 } |
1244 | 1245 |
1245 WebInspector.DebuggerPausedDetails.prototype = { | 1246 WebInspector.DebuggerPausedDetails.prototype = { |
1246 /** | 1247 /** |
1247 * @return {?WebInspector.RemoteObject} | 1248 * @return {?WebInspector.RemoteObject} |
1248 */ | 1249 */ |
1249 exception: function() | 1250 exception: function() |
1250 { | 1251 { |
1251 if (this.reason !== WebInspector.DebuggerModel.BreakReason.Exception &&
this.reason !== WebInspector.DebuggerModel.BreakReason.PromiseRejection) | 1252 if (this.reason !== WebInspector.DebuggerModel.BreakReason.Exception &&
this.reason !== WebInspector.DebuggerModel.BreakReason.PromiseRejection) |
1252 return null; | 1253 return null; |
1253 return this.target().runtimeModel.createRemoteObject(/** @type {!Runtime
Agent.RemoteObject} */(this.auxData)); | 1254 return this.target().runtimeModel.createRemoteObject(/** @type {!Runtime
Agent.RemoteObject} */(this.auxData)); |
1254 }, | 1255 }, |
1255 | 1256 |
| 1257 /** |
| 1258 * @param {!RuntimeAgent.StackTrace} asyncStackTrace |
| 1259 * @return {!RuntimeAgent.StackTrace} |
| 1260 */ |
| 1261 _cleanRedundantFrames: function(asyncStackTrace) |
| 1262 { |
| 1263 var stack = asyncStackTrace; |
| 1264 var previous = null; |
| 1265 while (stack) { |
| 1266 if (stack.description === "async function" && stack.callFrames.lengt
h) |
| 1267 stack.callFrames.shift(); |
| 1268 if (previous && !stack.callFrames.length) |
| 1269 previous.parent = stack.parent; |
| 1270 else |
| 1271 previous = stack; |
| 1272 stack = stack.parent; |
| 1273 } |
| 1274 return asyncStackTrace; |
| 1275 }, |
| 1276 |
1256 __proto__: WebInspector.SDKObject.prototype | 1277 __proto__: WebInspector.SDKObject.prototype |
1257 } | 1278 } |
1258 | 1279 |
1259 /** | 1280 /** |
1260 * @return {!Array<!WebInspector.DebuggerModel>} | 1281 * @return {!Array<!WebInspector.DebuggerModel>} |
1261 */ | 1282 */ |
1262 WebInspector.DebuggerModel.instances = function() | 1283 WebInspector.DebuggerModel.instances = function() |
1263 { | 1284 { |
1264 var result = []; | 1285 var result = []; |
1265 for (var target of WebInspector.targetManager.targets()) { | 1286 for (var target of WebInspector.targetManager.targets()) { |
1266 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); | 1287 var debuggerModel = WebInspector.DebuggerModel.fromTarget(target); |
1267 if (debuggerModel) | 1288 if (debuggerModel) |
1268 result.push(debuggerModel); | 1289 result.push(debuggerModel); |
1269 } | 1290 } |
1270 return result; | 1291 return result; |
1271 } | 1292 } |
1272 | 1293 |
1273 /** | 1294 /** |
1274 * @param {?WebInspector.Target} target | 1295 * @param {?WebInspector.Target} target |
1275 * @return {?WebInspector.DebuggerModel} | 1296 * @return {?WebInspector.DebuggerModel} |
1276 */ | 1297 */ |
1277 WebInspector.DebuggerModel.fromTarget = function(target) | 1298 WebInspector.DebuggerModel.fromTarget = function(target) |
1278 { | 1299 { |
1279 if (!target || !target.hasJSCapability()) | 1300 if (!target || !target.hasJSCapability()) |
1280 return null; | 1301 return null; |
1281 return /** @type {?WebInspector.DebuggerModel} */ (target.model(WebInspector
.DebuggerModel)); | 1302 return /** @type {?WebInspector.DebuggerModel} */ (target.model(WebInspector
.DebuggerModel)); |
1282 } | 1303 } |
OLD | NEW |