| 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 12 matching lines...) Expand all Loading... |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 /** | 31 /** |
| 32 * @constructor | 32 * @constructor |
| 33 * @extends {WebInspector.Object} | 33 * @extends {WebInspector.TargetAwareObject} |
| 34 * @param {!WebInspector.Target} target | 34 * @param {!WebInspector.Target} target |
| 35 */ | 35 */ |
| 36 WebInspector.DebuggerModel = function(target) | 36 WebInspector.DebuggerModel = function(target) |
| 37 { | 37 { |
| 38 WebInspector.TargetAwareObject.call(this, target); |
| 39 |
| 38 target.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this))
; | 40 target.registerDebuggerDispatcher(new WebInspector.DebuggerDispatcher(this))
; |
| 39 this._agent = target.debuggerAgent(); | 41 this._agent = target.debuggerAgent(); |
| 40 this._target = target; | |
| 41 | 42 |
| 42 /** @type {?WebInspector.DebuggerPausedDetails} */ | 43 /** @type {?WebInspector.DebuggerPausedDetails} */ |
| 43 this._debuggerPausedDetails = null; | 44 this._debuggerPausedDetails = null; |
| 44 /** @type {!Object.<string, !WebInspector.Script>} */ | 45 /** @type {!Object.<string, !WebInspector.Script>} */ |
| 45 this._scripts = {}; | 46 this._scripts = {}; |
| 46 /** @type {!StringMap.<!Array.<!WebInspector.Script>>} */ | 47 /** @type {!StringMap.<!Array.<!WebInspector.Script>>} */ |
| 47 this._scriptsBySourceURL = new StringMap(); | 48 this._scriptsBySourceURL = new StringMap(); |
| 48 | 49 |
| 49 this._breakpointsActive = true; | 50 this._breakpointsActive = true; |
| 50 | 51 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 62 * Keep these in sync with WebCore::ScriptDebugServer | 63 * Keep these in sync with WebCore::ScriptDebugServer |
| 63 * | 64 * |
| 64 * @enum {string} | 65 * @enum {string} |
| 65 */ | 66 */ |
| 66 WebInspector.DebuggerModel.PauseOnExceptionsState = { | 67 WebInspector.DebuggerModel.PauseOnExceptionsState = { |
| 67 DontPauseOnExceptions : "none", | 68 DontPauseOnExceptions : "none", |
| 68 PauseOnAllExceptions : "all", | 69 PauseOnAllExceptions : "all", |
| 69 PauseOnUncaughtExceptions: "uncaught" | 70 PauseOnUncaughtExceptions: "uncaught" |
| 70 }; | 71 }; |
| 71 | 72 |
| 72 /** | |
| 73 * @constructor | |
| 74 * @implements {WebInspector.RawLocation} | |
| 75 * @param {string} scriptId | |
| 76 * @param {number} lineNumber | |
| 77 * @param {number} columnNumber | |
| 78 */ | |
| 79 WebInspector.DebuggerModel.Location = function(scriptId, lineNumber, columnNumbe
r) | |
| 80 { | |
| 81 this.scriptId = scriptId; | |
| 82 this.lineNumber = lineNumber; | |
| 83 this.columnNumber = columnNumber; | |
| 84 } | |
| 85 | |
| 86 WebInspector.DebuggerModel.Events = { | 73 WebInspector.DebuggerModel.Events = { |
| 87 DebuggerWasEnabled: "DebuggerWasEnabled", | 74 DebuggerWasEnabled: "DebuggerWasEnabled", |
| 88 DebuggerWasDisabled: "DebuggerWasDisabled", | 75 DebuggerWasDisabled: "DebuggerWasDisabled", |
| 89 DebuggerPaused: "DebuggerPaused", | 76 DebuggerPaused: "DebuggerPaused", |
| 90 DebuggerResumed: "DebuggerResumed", | 77 DebuggerResumed: "DebuggerResumed", |
| 91 ParsedScriptSource: "ParsedScriptSource", | 78 ParsedScriptSource: "ParsedScriptSource", |
| 92 FailedToParseScriptSource: "FailedToParseScriptSource", | 79 FailedToParseScriptSource: "FailedToParseScriptSource", |
| 93 BreakpointResolved: "BreakpointResolved", | 80 BreakpointResolved: "BreakpointResolved", |
| 94 GlobalObjectCleared: "GlobalObjectCleared", | 81 GlobalObjectCleared: "GlobalObjectCleared", |
| 95 CallFrameSelected: "CallFrameSelected", | 82 CallFrameSelected: "CallFrameSelected", |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 var enabled = WebInspector.settings.enableAsyncStackTraces.get(); | 171 var enabled = WebInspector.settings.enableAsyncStackTraces.get(); |
| 185 this._agent.setAsyncCallStackDepth(enabled ? maxAsyncStackChainDepth : 0
); | 172 this._agent.setAsyncCallStackDepth(enabled ? maxAsyncStackChainDepth : 0
); |
| 186 }, | 173 }, |
| 187 | 174 |
| 188 _debuggerWasDisabled: function() | 175 _debuggerWasDisabled: function() |
| 189 { | 176 { |
| 190 this._debuggerEnabled = false; | 177 this._debuggerEnabled = false; |
| 191 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Debugger
WasDisabled); | 178 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Debugger
WasDisabled); |
| 192 }, | 179 }, |
| 193 | 180 |
| 194 /** | |
| 195 * @param {!WebInspector.DebuggerModel.Location} rawLocation | |
| 196 */ | |
| 197 continueToLocation: function(rawLocation) | |
| 198 { | |
| 199 this._agent.continueToLocation(rawLocation); | |
| 200 }, | |
| 201 | |
| 202 stepInto: function() | 181 stepInto: function() |
| 203 { | 182 { |
| 204 /** | 183 /** |
| 205 * @this {WebInspector.DebuggerModel} | 184 * @this {WebInspector.DebuggerModel} |
| 206 */ | 185 */ |
| 207 function callback() | 186 function callback() |
| 208 { | 187 { |
| 209 this._agent.stepInto(); | 188 this._agent.stepInto(); |
| 210 } | 189 } |
| 211 this._agent.setOverlayMessage(undefined, callback.bind(this)); | 190 this._agent.setOverlayMessage(undefined, callback.bind(this)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 this._agent.setOverlayMessage(undefined, callback.bind(this)); | 226 this._agent.setOverlayMessage(undefined, callback.bind(this)); |
| 248 }, | 227 }, |
| 249 | 228 |
| 250 /** | 229 /** |
| 251 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 230 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 252 * @param {string} condition | 231 * @param {string} condition |
| 253 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>):void=} callback | 232 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>):void=} callback |
| 254 */ | 233 */ |
| 255 setBreakpointByScriptLocation: function(rawLocation, condition, callback) | 234 setBreakpointByScriptLocation: function(rawLocation, condition, callback) |
| 256 { | 235 { |
| 257 var script = this.scriptForId(rawLocation.scriptId); | 236 var script = rawLocation.script(); |
| 258 if (script.sourceURL) | 237 if (script.sourceURL) |
| 259 this.setBreakpointByURL(script.sourceURL, rawLocation.lineNumber, ra
wLocation.columnNumber, condition, callback); | 238 this.setBreakpointByURL(script.sourceURL, rawLocation.lineNumber, ra
wLocation.columnNumber, condition, callback); |
| 260 else | 239 else |
| 261 this.setBreakpointBySourceId(rawLocation, condition, callback); | 240 this.setBreakpointBySourceId(rawLocation, condition, callback); |
| 262 }, | 241 }, |
| 263 | 242 |
| 264 /** | 243 /** |
| 265 * @param {string} url | 244 * @param {string} url |
| 266 * @param {number} lineNumber | 245 * @param {number} lineNumber |
| 267 * @param {number=} columnNumber | 246 * @param {number=} columnNumber |
| 268 * @param {string=} condition | 247 * @param {string=} condition |
| 269 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>)=} callback | 248 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>)=} callback |
| 270 */ | 249 */ |
| 271 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb
ack) | 250 setBreakpointByURL: function(url, lineNumber, columnNumber, condition, callb
ack) |
| 272 { | 251 { |
| 273 // Adjust column if needed. | 252 // Adjust column if needed. |
| 274 var minColumnNumber = 0; | 253 var minColumnNumber = 0; |
| 275 var scripts = this._scriptsBySourceURL.get(url) || []; | 254 var scripts = this._scriptsBySourceURL.get(url) || []; |
| 276 for (var i = 0, l = scripts.length; i < l; ++i) { | 255 for (var i = 0, l = scripts.length; i < l; ++i) { |
| 277 var script = scripts[i]; | 256 var script = scripts[i]; |
| 278 if (lineNumber === script.lineOffset) | 257 if (lineNumber === script.lineOffset) |
| 279 minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, sc
ript.columnOffset) : script.columnOffset; | 258 minColumnNumber = minColumnNumber ? Math.min(minColumnNumber, sc
ript.columnOffset) : script.columnOffset; |
| 280 } | 259 } |
| 281 columnNumber = Math.max(columnNumber, minColumnNumber); | 260 columnNumber = Math.max(columnNumber, minColumnNumber); |
| 282 | 261 |
| 262 var target = this.target(); |
| 283 /** | 263 /** |
| 284 * @param {?Protocol.Error} error | 264 * @param {?Protocol.Error} error |
| 285 * @param {!DebuggerAgent.BreakpointId} breakpointId | 265 * @param {!DebuggerAgent.BreakpointId} breakpointId |
| 286 * @param {!Array.<!DebuggerAgent.Location>} locations | 266 * @param {!Array.<!DebuggerAgent.Location>} locations |
| 287 */ | 267 */ |
| 288 function didSetBreakpoint(error, breakpointId, locations) | 268 function didSetBreakpoint(error, breakpointId, locations) |
| 289 { | 269 { |
| 290 if (callback) { | 270 if (callback) { |
| 291 var rawLocations = /** @type {!Array.<!WebInspector.DebuggerMode
l.Location>} */ (locations); | 271 var rawLocations = locations.map(WebInspector.DebuggerModel.Loca
tion.fromPayload.bind(WebInspector.DebuggerModel.Location, target)); |
| 292 callback(error ? null : breakpointId, rawLocations); | 272 callback(error ? null : breakpointId, rawLocations); |
| 293 } | 273 } |
| 294 } | 274 } |
| 295 this._agent.setBreakpointByUrl(lineNumber, url, undefined, columnNumber,
condition, undefined, didSetBreakpoint); | 275 this._agent.setBreakpointByUrl(lineNumber, url, undefined, columnNumber,
condition, undefined, didSetBreakpoint); |
| 296 WebInspector.userMetrics.ScriptsBreakpointSet.record(); | 276 WebInspector.userMetrics.ScriptsBreakpointSet.record(); |
| 297 }, | 277 }, |
| 298 | 278 |
| 299 /** | 279 /** |
| 300 * @param {!WebInspector.DebuggerModel.Location} rawLocation | 280 * @param {!WebInspector.DebuggerModel.Location} rawLocation |
| 301 * @param {string} condition | 281 * @param {string} condition |
| 302 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>)=} callback | 282 * @param {function(?DebuggerAgent.BreakpointId, !Array.<!WebInspector.Debug
gerModel.Location>)=} callback |
| 303 */ | 283 */ |
| 304 setBreakpointBySourceId: function(rawLocation, condition, callback) | 284 setBreakpointBySourceId: function(rawLocation, condition, callback) |
| 305 { | 285 { |
| 286 var target = this.target(); |
| 287 |
| 306 /** | 288 /** |
| 307 * @param {?Protocol.Error} error | 289 * @param {?Protocol.Error} error |
| 308 * @param {!DebuggerAgent.BreakpointId} breakpointId | 290 * @param {!DebuggerAgent.BreakpointId} breakpointId |
| 309 * @param {!DebuggerAgent.Location} actualLocation | 291 * @param {!DebuggerAgent.Location} actualLocation |
| 310 */ | 292 */ |
| 311 function didSetBreakpoint(error, breakpointId, actualLocation) | 293 function didSetBreakpoint(error, breakpointId, actualLocation) |
| 312 { | 294 { |
| 313 if (callback) { | 295 if (callback) { |
| 314 var rawLocation = /** @type {!WebInspector.DebuggerModel.Locatio
n} */ (actualLocation); | 296 var location = WebInspector.DebuggerModel.Location.fromPayload(t
arget, actualLocation); |
| 315 callback(error ? null : breakpointId, [rawLocation]); | 297 callback(error ? null : breakpointId, [location]); |
| 316 } | 298 } |
| 317 } | 299 } |
| 318 this._agent.setBreakpoint(rawLocation, condition, didSetBreakpoint); | 300 this._agent.setBreakpoint(rawLocation.payload(), condition, didSetBreakp
oint); |
| 319 WebInspector.userMetrics.ScriptsBreakpointSet.record(); | 301 WebInspector.userMetrics.ScriptsBreakpointSet.record(); |
| 320 }, | 302 }, |
| 321 | 303 |
| 322 /** | 304 /** |
| 323 * @param {!DebuggerAgent.BreakpointId} breakpointId | 305 * @param {!DebuggerAgent.BreakpointId} breakpointId |
| 324 * @param {function()=} callback | 306 * @param {function()=} callback |
| 325 */ | 307 */ |
| 326 removeBreakpoint: function(breakpointId, callback) | 308 removeBreakpoint: function(breakpointId, callback) |
| 327 { | 309 { |
| 328 this._agent.removeBreakpoint(breakpointId, innerCallback); | 310 this._agent.removeBreakpoint(breakpointId, innerCallback); |
| 329 | 311 |
| 330 /** | 312 /** |
| 331 * @param {?Protocol.Error} error | 313 * @param {?Protocol.Error} error |
| 332 */ | 314 */ |
| 333 function innerCallback(error) | 315 function innerCallback(error) |
| 334 { | 316 { |
| 335 if (error) | 317 if (error) |
| 336 console.error("Failed to remove breakpoint: " + error); | 318 console.error("Failed to remove breakpoint: " + error); |
| 337 if (callback) | 319 if (callback) |
| 338 callback(); | 320 callback(); |
| 339 } | 321 } |
| 340 }, | 322 }, |
| 341 | 323 |
| 342 /** | 324 /** |
| 343 * @param {!DebuggerAgent.BreakpointId} breakpointId | 325 * @param {!DebuggerAgent.BreakpointId} breakpointId |
| 344 * @param {!DebuggerAgent.Location} location | 326 * @param {!DebuggerAgent.Location} location |
| 345 */ | 327 */ |
| 346 _breakpointResolved: function(breakpointId, location) | 328 _breakpointResolved: function(breakpointId, location) |
| 347 { | 329 { |
| 348 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Breakpoi
ntResolved, {breakpointId: breakpointId, location: location}); | 330 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Breakpoi
ntResolved, {breakpointId: breakpointId, location: WebInspector.DebuggerModel.Lo
cation.fromPayload(this.target(), location)}); |
| 349 }, | 331 }, |
| 350 | 332 |
| 351 _globalObjectCleared: function() | 333 _globalObjectCleared: function() |
| 352 { | 334 { |
| 353 this._setDebuggerPausedDetails(null); | 335 this._setDebuggerPausedDetails(null); |
| 354 this._reset(); | 336 this._reset(); |
| 355 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalOb
jectCleared); | 337 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.GlobalOb
jectCleared); |
| 356 }, | 338 }, |
| 357 | 339 |
| 358 _reset: function() | 340 _reset: function() |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 436 |
| 455 /** | 437 /** |
| 456 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames | 438 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames |
| 457 * @param {string} reason | 439 * @param {string} reason |
| 458 * @param {!Object|undefined} auxData | 440 * @param {!Object|undefined} auxData |
| 459 * @param {!Array.<string>} breakpointIds | 441 * @param {!Array.<string>} breakpointIds |
| 460 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace | 442 * @param {!DebuggerAgent.StackTrace=} asyncStackTrace |
| 461 */ | 443 */ |
| 462 _pausedScript: function(callFrames, reason, auxData, breakpointIds, asyncSta
ckTrace) | 444 _pausedScript: function(callFrames, reason, auxData, breakpointIds, asyncSta
ckTrace) |
| 463 { | 445 { |
| 464 this._setDebuggerPausedDetails(new WebInspector.DebuggerPausedDetails(th
is._target, callFrames, reason, auxData, breakpointIds, asyncStackTrace)); | 446 this._setDebuggerPausedDetails(new WebInspector.DebuggerPausedDetails(th
is.target(), callFrames, reason, auxData, breakpointIds, asyncStackTrace)); |
| 465 }, | 447 }, |
| 466 | 448 |
| 467 _resumedScript: function() | 449 _resumedScript: function() |
| 468 { | 450 { |
| 469 this._setDebuggerPausedDetails(null); | 451 this._setDebuggerPausedDetails(null); |
| 470 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Debugger
Resumed); | 452 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.Debugger
Resumed); |
| 471 }, | 453 }, |
| 472 | 454 |
| 473 /** | 455 /** |
| 474 * @param {!DebuggerAgent.ScriptId} scriptId | 456 * @param {!DebuggerAgent.ScriptId} scriptId |
| 475 * @param {string} sourceURL | 457 * @param {string} sourceURL |
| 476 * @param {number} startLine | 458 * @param {number} startLine |
| 477 * @param {number} startColumn | 459 * @param {number} startColumn |
| 478 * @param {number} endLine | 460 * @param {number} endLine |
| 479 * @param {number} endColumn | 461 * @param {number} endColumn |
| 480 * @param {boolean} isContentScript | 462 * @param {boolean} isContentScript |
| 481 * @param {string=} sourceMapURL | 463 * @param {string=} sourceMapURL |
| 482 * @param {boolean=} hasSourceURL | 464 * @param {boolean=} hasSourceURL |
| 483 */ | 465 */ |
| 484 _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, e
ndLine, endColumn, isContentScript, sourceMapURL, hasSourceURL) | 466 _parsedScriptSource: function(scriptId, sourceURL, startLine, startColumn, e
ndLine, endColumn, isContentScript, sourceMapURL, hasSourceURL) |
| 485 { | 467 { |
| 486 var script = new WebInspector.Script(scriptId, sourceURL, startLine, sta
rtColumn, endLine, endColumn, isContentScript, sourceMapURL, hasSourceURL); | 468 var script = new WebInspector.Script(this.target(), scriptId, sourceURL,
startLine, startColumn, endLine, endColumn, isContentScript, sourceMapURL, hasS
ourceURL); |
| 487 this._registerScript(script); | 469 this._registerScript(script); |
| 488 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedSc
riptSource, script); | 470 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.ParsedSc
riptSource, script); |
| 489 }, | 471 }, |
| 490 | 472 |
| 491 /** | 473 /** |
| 492 * @param {!WebInspector.Script} script | 474 * @param {!WebInspector.Script} script |
| 493 */ | 475 */ |
| 494 _registerScript: function(script) | 476 _registerScript: function(script) |
| 495 { | 477 { |
| 496 this._scripts[script.scriptId] = script; | 478 this._scripts[script.scriptId] = script; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 508 /** | 490 /** |
| 509 * @param {!WebInspector.Script} script | 491 * @param {!WebInspector.Script} script |
| 510 * @param {number} lineNumber | 492 * @param {number} lineNumber |
| 511 * @param {number} columnNumber | 493 * @param {number} columnNumber |
| 512 * @return {?WebInspector.DebuggerModel.Location} | 494 * @return {?WebInspector.DebuggerModel.Location} |
| 513 */ | 495 */ |
| 514 createRawLocation: function(script, lineNumber, columnNumber) | 496 createRawLocation: function(script, lineNumber, columnNumber) |
| 515 { | 497 { |
| 516 if (script.sourceURL) | 498 if (script.sourceURL) |
| 517 return this.createRawLocationByURL(script.sourceURL, lineNumber, col
umnNumber) | 499 return this.createRawLocationByURL(script.sourceURL, lineNumber, col
umnNumber) |
| 518 return new WebInspector.DebuggerModel.Location(script.scriptId, lineNumb
er, columnNumber); | 500 return new WebInspector.DebuggerModel.Location(this.target(), script.scr
iptId, lineNumber, columnNumber); |
| 519 }, | 501 }, |
| 520 | 502 |
| 521 /** | 503 /** |
| 522 * @param {string} sourceURL | 504 * @param {string} sourceURL |
| 523 * @param {number} lineNumber | 505 * @param {number} lineNumber |
| 524 * @param {number} columnNumber | 506 * @param {number} columnNumber |
| 525 * @return {?WebInspector.DebuggerModel.Location} | 507 * @return {?WebInspector.DebuggerModel.Location} |
| 526 */ | 508 */ |
| 527 createRawLocationByURL: function(sourceURL, lineNumber, columnNumber) | 509 createRawLocationByURL: function(sourceURL, lineNumber, columnNumber) |
| 528 { | 510 { |
| 529 var closestScript = null; | 511 var closestScript = null; |
| 530 var scripts = this._scriptsBySourceURL.get(sourceURL) || []; | 512 var scripts = this._scriptsBySourceURL.get(sourceURL) || []; |
| 531 for (var i = 0, l = scripts.length; i < l; ++i) { | 513 for (var i = 0, l = scripts.length; i < l; ++i) { |
| 532 var script = scripts[i]; | 514 var script = scripts[i]; |
| 533 if (!closestScript) | 515 if (!closestScript) |
| 534 closestScript = script; | 516 closestScript = script; |
| 535 if (script.lineOffset > lineNumber || (script.lineOffset === lineNum
ber && script.columnOffset > columnNumber)) | 517 if (script.lineOffset > lineNumber || (script.lineOffset === lineNum
ber && script.columnOffset > columnNumber)) |
| 536 continue; | 518 continue; |
| 537 if (script.endLine < lineNumber || (script.endLine === lineNumber &&
script.endColumn <= columnNumber)) | 519 if (script.endLine < lineNumber || (script.endLine === lineNumber &&
script.endColumn <= columnNumber)) |
| 538 continue; | 520 continue; |
| 539 closestScript = script; | 521 closestScript = script; |
| 540 break; | 522 break; |
| 541 } | 523 } |
| 542 return closestScript ? new WebInspector.DebuggerModel.Location(closestSc
ript.scriptId, lineNumber, columnNumber) : null; | 524 return closestScript ? new WebInspector.DebuggerModel.Location(this.targ
et(), closestScript.scriptId, lineNumber, columnNumber) : null; |
| 543 }, | 525 }, |
| 544 | 526 |
| 545 /** | 527 /** |
| 546 * @return {boolean} | 528 * @return {boolean} |
| 547 */ | 529 */ |
| 548 isPaused: function() | 530 isPaused: function() |
| 549 { | 531 { |
| 550 return !!this.debuggerPausedDetails(); | 532 return !!this.debuggerPausedDetails(); |
| 551 }, | 533 }, |
| 552 | 534 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 586 * @param {boolean=} wasThrown | 568 * @param {boolean=} wasThrown |
| 587 * @this {WebInspector.DebuggerModel} | 569 * @this {WebInspector.DebuggerModel} |
| 588 */ | 570 */ |
| 589 function didEvaluate(result, wasThrown) | 571 function didEvaluate(result, wasThrown) |
| 590 { | 572 { |
| 591 if (!result) | 573 if (!result) |
| 592 callback(null, false); | 574 callback(null, false); |
| 593 else if (returnByValue) | 575 else if (returnByValue) |
| 594 callback(null, !!wasThrown, wasThrown ? null : result); | 576 callback(null, !!wasThrown, wasThrown ? null : result); |
| 595 else | 577 else |
| 596 callback(this._target.runtimeModel.createRemoteObject(result), !
!wasThrown); | 578 callback(this.target().runtimeModel.createRemoteObject(result),
!!wasThrown); |
| 597 | 579 |
| 598 if (objectGroup === "console") | 580 if (objectGroup === "console") |
| 599 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.
ConsoleCommandEvaluatedInSelectedCallFrame); | 581 this.dispatchEventToListeners(WebInspector.DebuggerModel.Events.
ConsoleCommandEvaluatedInSelectedCallFrame); |
| 600 } | 582 } |
| 601 | 583 |
| 602 this.selectedCallFrame().evaluate(code, objectGroup, includeCommandLineA
PI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, didEva
luate.bind(this)); | 584 this.selectedCallFrame().evaluate(code, objectGroup, includeCommandLineA
PI, doNotPauseOnExceptionsAndMuteConsole, returnByValue, generatePreview, didEva
luate.bind(this)); |
| 603 }, | 585 }, |
| 604 | 586 |
| 605 /** | 587 /** |
| 606 * @param {function(!Object)} callback | 588 * @param {function(!Object)} callback |
| (...skipping 11 matching lines...) Expand all Loading... |
| 618 function propertiesCollected(properties) | 600 function propertiesCollected(properties) |
| 619 { | 601 { |
| 620 for (var i = 0; properties && i < properties.length; ++i) | 602 for (var i = 0; properties && i < properties.length; ++i) |
| 621 result[properties[i].name] = true; | 603 result[properties[i].name] = true; |
| 622 if (--pendingRequests == 0) | 604 if (--pendingRequests == 0) |
| 623 callback(result); | 605 callback(result); |
| 624 } | 606 } |
| 625 | 607 |
| 626 for (var i = 0; i < selectedCallFrame.scopeChain.length; ++i) { | 608 for (var i = 0; i < selectedCallFrame.scopeChain.length; ++i) { |
| 627 var scope = selectedCallFrame.scopeChain[i]; | 609 var scope = selectedCallFrame.scopeChain[i]; |
| 628 var object = this._target.runtimeModel.createRemoteObject(scope.obje
ct); | 610 var object = this.target().runtimeModel.createRemoteObject(scope.obj
ect); |
| 629 pendingRequests++; | 611 pendingRequests++; |
| 630 object.getAllProperties(false, propertiesCollected); | 612 object.getAllProperties(false, propertiesCollected); |
| 631 } | 613 } |
| 632 }, | 614 }, |
| 633 | 615 |
| 634 /** | 616 /** |
| 635 * @param {boolean} active | 617 * @param {boolean} active |
| 636 */ | 618 */ |
| 637 setBreakpointsActive: function(active) | 619 setBreakpointsActive: function(active) |
| 638 { | 620 { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 691 | 673 |
| 692 applySkipStackFrameSettings: function() | 674 applySkipStackFrameSettings: function() |
| 693 { | 675 { |
| 694 if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabl
ed()) | 676 if (!WebInspector.experimentsSettings.frameworksDebuggingSupport.isEnabl
ed()) |
| 695 return; | 677 return; |
| 696 var settings = WebInspector.settings; | 678 var settings = WebInspector.settings; |
| 697 var patternParameter = settings.skipStackFramesSwitch.get() ? settings.s
kipStackFramesPattern.get() : undefined; | 679 var patternParameter = settings.skipStackFramesSwitch.get() ? settings.s
kipStackFramesPattern.get() : undefined; |
| 698 this._agent.skipStackFrames(patternParameter); | 680 this._agent.skipStackFrames(patternParameter); |
| 699 }, | 681 }, |
| 700 | 682 |
| 701 __proto__: WebInspector.Object.prototype | 683 /** |
| 684 * @param {!WebInspector.RemoteObject} remoteObject |
| 685 * @param {function(?DebuggerAgent.FunctionDetails)} callback |
| 686 */ |
| 687 functionDetails: function(remoteObject, callback) |
| 688 { |
| 689 this._agent.getFunctionDetails(remoteObject.objectId, didGetDetails); |
| 690 |
| 691 /** |
| 692 * @param {?Protocol.Error} error |
| 693 * @param {!DebuggerAgent.FunctionDetails} response |
| 694 */ |
| 695 function didGetDetails(error, response) |
| 696 { |
| 697 if (error) { |
| 698 console.error(error); |
| 699 callback(null); |
| 700 return; |
| 701 } |
| 702 callback(response); |
| 703 } |
| 704 }, |
| 705 |
| 706 __proto__: WebInspector.TargetAwareObject.prototype |
| 702 } | 707 } |
| 703 | 708 |
| 704 WebInspector.DebuggerEventTypes = { | 709 WebInspector.DebuggerEventTypes = { |
| 705 JavaScriptPause: 0, | 710 JavaScriptPause: 0, |
| 706 JavaScriptBreakpoint: 1, | 711 JavaScriptBreakpoint: 1, |
| 707 NativeBreakpoint: 2 | 712 NativeBreakpoint: 2 |
| 708 }; | 713 }; |
| 709 | 714 |
| 710 /** | 715 /** |
| 711 * @constructor | 716 * @constructor |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 * @param {!DebuggerAgent.Location} location | 783 * @param {!DebuggerAgent.Location} location |
| 779 */ | 784 */ |
| 780 breakpointResolved: function(breakpointId, location) | 785 breakpointResolved: function(breakpointId, location) |
| 781 { | 786 { |
| 782 this._debuggerModel._breakpointResolved(breakpointId, location); | 787 this._debuggerModel._breakpointResolved(breakpointId, location); |
| 783 } | 788 } |
| 784 } | 789 } |
| 785 | 790 |
| 786 /** | 791 /** |
| 787 * @constructor | 792 * @constructor |
| 793 * @implements {WebInspector.RawLocation} |
| 794 * @extends {WebInspector.TargetAware} |
| 795 * @param {!WebInspector.Target} target |
| 796 * @param {string} scriptId |
| 797 * @param {number} lineNumber |
| 798 * @param {number=} columnNumber |
| 799 */ |
| 800 WebInspector.DebuggerModel.Location = function(target, scriptId, lineNumber, col
umnNumber) |
| 801 { |
| 802 WebInspector.TargetAware.call(this, target); |
| 803 this._debuggerModel = target.debuggerModel; |
| 804 this.scriptId = scriptId; |
| 805 this.lineNumber = lineNumber; |
| 806 this.columnNumber = columnNumber; |
| 807 } |
| 808 |
| 809 /** |
| 810 * @param {!WebInspector.Target} target |
| 811 * @param {!DebuggerAgent.Location} payload |
| 812 */ |
| 813 WebInspector.DebuggerModel.Location.fromPayload = function(target, payload) |
| 814 { |
| 815 return new WebInspector.DebuggerModel.Location(target, payload.scriptId, pay
load.lineNumber, payload.columnNumber); |
| 816 } |
| 817 |
| 818 WebInspector.DebuggerModel.Location.prototype = { |
| 819 /** |
| 820 * @return {!DebuggerAgent.Location} |
| 821 */ |
| 822 payload: function() |
| 823 { |
| 824 return { scriptId: this.scriptId, lineNumber: this.lineNumber, columnNum
ber: this.columnNumber }; |
| 825 }, |
| 826 |
| 827 /** |
| 828 * @return {!WebInspector.Script} |
| 829 */ |
| 830 script: function() |
| 831 { |
| 832 return this._debuggerModel.scriptForId(this.scriptId); |
| 833 }, |
| 834 |
| 835 /** |
| 836 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDel
egate |
| 837 * @return {!WebInspector.Script.Location} |
| 838 */ |
| 839 createLiveLocation: function(updateDelegate) |
| 840 { |
| 841 return this._debuggerModel.createLiveLocation(this, updateDelegate); |
| 842 }, |
| 843 |
| 844 /** |
| 845 * @return {?WebInspector.UILocation} |
| 846 */ |
| 847 toUILocation: function() |
| 848 { |
| 849 return this._debuggerModel.rawLocationToUILocation(this); |
| 850 }, |
| 851 |
| 852 continueToLocation: function() |
| 853 { |
| 854 this._debuggerModel._agent.continueToLocation(this.payload()); |
| 855 }, |
| 856 |
| 857 __proto__: WebInspector.TargetAware.prototype |
| 858 } |
| 859 |
| 860 /** |
| 861 * @constructor |
| 788 * @extends {WebInspector.TargetAware} | 862 * @extends {WebInspector.TargetAware} |
| 789 * @param {!WebInspector.Target} target | 863 * @param {!WebInspector.Target} target |
| 790 * @param {!WebInspector.Script} script | 864 * @param {!WebInspector.Script} script |
| 791 * @param {!DebuggerAgent.CallFrame} payload | 865 * @param {!DebuggerAgent.CallFrame} payload |
| 792 * @param {boolean=} isAsync | 866 * @param {boolean=} isAsync |
| 793 */ | 867 */ |
| 794 WebInspector.DebuggerModel.CallFrame = function(target, script, payload, isAsync
) | 868 WebInspector.DebuggerModel.CallFrame = function(target, script, payload, isAsync
) |
| 795 { | 869 { |
| 796 WebInspector.TargetAware.call(this, target); | 870 WebInspector.TargetAware.call(this, target); |
| 797 this._debuggerAgent = target.debuggerModel._agent; | 871 this._debuggerAgent = target.debuggerModel._agent; |
| 798 this._script = script; | 872 this._script = script; |
| 799 this._payload = payload; | 873 this._payload = payload; |
| 800 /** @type {!Array.<!WebInspector.Script.Location>} */ | 874 /** @type {!Array.<!WebInspector.Script.Location>} */ |
| 801 this._locations = []; | 875 this._liveLocations = []; |
| 802 this._isAsync = isAsync; | 876 this._isAsync = isAsync; |
| 877 this._location = WebInspector.DebuggerModel.Location.fromPayload(target, pay
load.location); |
| 803 } | 878 } |
| 804 | 879 |
| 805 /** | 880 /** |
| 806 * @param {!WebInspector.Target} target | 881 * @param {!WebInspector.Target} target |
| 807 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames | 882 * @param {!Array.<!DebuggerAgent.CallFrame>} callFrames |
| 808 * @param {boolean=} isAsync | 883 * @param {boolean=} isAsync |
| 809 * @return {!Array.<!WebInspector.DebuggerModel.CallFrame>} | 884 * @return {!Array.<!WebInspector.DebuggerModel.CallFrame>} |
| 810 */ | 885 */ |
| 811 WebInspector.DebuggerModel.CallFrame.fromPayloadArray = function(target, callFra
mes, isAsync) | 886 WebInspector.DebuggerModel.CallFrame.fromPayloadArray = function(target, callFra
mes, isAsync) |
| 812 { | 887 { |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 874 * @return {string} | 949 * @return {string} |
| 875 */ | 950 */ |
| 876 get functionName() | 951 get functionName() |
| 877 { | 952 { |
| 878 return this._payload.functionName; | 953 return this._payload.functionName; |
| 879 }, | 954 }, |
| 880 | 955 |
| 881 /** | 956 /** |
| 882 * @return {!WebInspector.DebuggerModel.Location} | 957 * @return {!WebInspector.DebuggerModel.Location} |
| 883 */ | 958 */ |
| 884 get location() | 959 location: function() |
| 885 { | 960 { |
| 886 var rawLocation = /** @type {!WebInspector.DebuggerModel.Location} */ (t
his._payload.location); | 961 return this._location; |
| 887 return rawLocation; | |
| 888 }, | 962 }, |
| 889 | 963 |
| 890 /** | 964 /** |
| 891 * @return {boolean} | 965 * @return {boolean} |
| 892 */ | 966 */ |
| 893 isAsync: function() | 967 isAsync: function() |
| 894 { | 968 { |
| 895 return !!this._isAsync; | 969 return !!this._isAsync; |
| 896 }, | 970 }, |
| 897 | 971 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 944 } | 1018 } |
| 945 this._debuggerAgent.restartFrame(this._payload.callFrameId, protocolCall
back.bind(this)); | 1019 this._debuggerAgent.restartFrame(this._payload.callFrameId, protocolCall
back.bind(this)); |
| 946 }, | 1020 }, |
| 947 | 1021 |
| 948 /** | 1022 /** |
| 949 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDel
egate | 1023 * @param {function(!WebInspector.UILocation):(boolean|undefined)} updateDel
egate |
| 950 * @return {!WebInspector.LiveLocation} | 1024 * @return {!WebInspector.LiveLocation} |
| 951 */ | 1025 */ |
| 952 createLiveLocation: function(updateDelegate) | 1026 createLiveLocation: function(updateDelegate) |
| 953 { | 1027 { |
| 954 var location = this._script.createLiveLocation(this.location, updateDele
gate); | 1028 var liveLocation = this._location.createLiveLocation(updateDelegate); |
| 955 this._locations.push(location); | 1029 this._liveLocations.push(liveLocation); |
| 956 return location; | 1030 return liveLocation; |
| 957 }, | 1031 }, |
| 958 | 1032 |
| 959 dispose: function() | 1033 dispose: function() |
| 960 { | 1034 { |
| 961 for (var i = 0; i < this._locations.length; ++i) | 1035 for (var i = 0; i < this._liveLocations.length; ++i) |
| 962 this._locations[i].dispose(); | 1036 this._liveLocations[i].dispose(); |
| 963 this._locations = []; | 1037 this._liveLocations = []; |
| 964 }, | 1038 }, |
| 965 | 1039 |
| 966 __proto__: WebInspector.TargetAware.prototype | 1040 __proto__: WebInspector.TargetAware.prototype |
| 967 } | 1041 } |
| 968 | 1042 |
| 969 /** | 1043 /** |
| 970 * @constructor | 1044 * @constructor |
| 971 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames | 1045 * @param {!Array.<!WebInspector.DebuggerModel.CallFrame>} callFrames |
| 972 * @param {?WebInspector.DebuggerModel.StackTrace} asyncStackTrace | 1046 * @param {?WebInspector.DebuggerModel.StackTrace} asyncStackTrace |
| 973 * @param {string=} description | 1047 * @param {string=} description |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1045 this.asyncStackTrace.dispose(); | 1119 this.asyncStackTrace.dispose(); |
| 1046 }, | 1120 }, |
| 1047 | 1121 |
| 1048 __proto__: WebInspector.TargetAware.prototype | 1122 __proto__: WebInspector.TargetAware.prototype |
| 1049 } | 1123 } |
| 1050 | 1124 |
| 1051 /** | 1125 /** |
| 1052 * @type {!WebInspector.DebuggerModel} | 1126 * @type {!WebInspector.DebuggerModel} |
| 1053 */ | 1127 */ |
| 1054 WebInspector.debuggerModel; | 1128 WebInspector.debuggerModel; |
| OLD | NEW |