18 KiB
Debugger
_Auto generated documentation for WebKit inspector
Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.
- Commands
- enable
- disable
- setBreakpointsActive
- setBreakpointByUrl
- setBreakpoint
- removeBreakpoint
- continueToLocation
- stepOver
- stepInto
- stepOut
- pause
- resume
- searchInContent
- getScriptSource
- getFunctionDetails
- setPauseOnExceptions
- evaluateOnCallFrame
- setOverlayMessage
- Events
- globalObjectCleared
- scriptParsed
- scriptFailedToParse
- breakpointResolved
- paused
- resumed
- didSampleProbe
- playBreakpointActionSound
- Types
- BreakpointId
- BreakpointActionIdentifier
- ScriptId
- CallFrameId
- Location
- BreakpointAction
- BreakpointOptions
- FunctionDetails
- CallFrame
- Scope
- ProbeSample
- AssertPauseReason
- BreakpointPauseReason
- CSPViolationPauseReason
Commands
Debugger.enable(callback)
Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
Parameters
callback ( function )
Results
error ( error )
Debugger.disable(callback)
Disables debugger for given page.
Parameters
callback ( function )
Results
error ( error )
Debugger.setBreakpointsActive(active, callback)
Activates / deactivates all breakpoints on the page.
Parameters
active ( boolean )
New value for breakpoints active state.
callback ( function )
Results
error ( error )
Debugger.setBreakpointByUrl(lineNumber, [url], [urlRegex], [columnNumber], [BreakpointOptions], callback)
Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads.
Parameters
lineNumber ( integer )
Line number to set breakpoint at.
url ( optional string )
URL of the resources to set breakpoint on.
urlRegex ( optional string )
Regex pattern for the URLs of the resources to set breakpoints on. Either
urlorurlRegexmust be specified.
columnNumber ( optional integer )
Offset in the line to set breakpoint at.
options ( optional BreakpointOptions )
Options to apply to this breakpoint to modify its behavior.
callback ( function )
Results
error ( error )
breakpointId ( BreakpointId )
Id of the created breakpoint for further reference.
locations ( array of Location )
List of the locations this breakpoint resolved into upon addition.
Debugger.setBreakpoint(Location, [BreakpointOptions], callback)
Sets JavaScript breakpoint at a given location.
Parameters
location ( Location )
Location to set breakpoint in.
options ( optional BreakpointOptions )
Options to apply to this breakpoint to modify its behavior.
callback ( function )
Results
error ( error )
breakpointId ( BreakpointId )
Id of the created breakpoint for further reference.
actualLocation ( Location )
Location this breakpoint resolved into.
Debugger.removeBreakpoint(BreakpointId, callback)
Removes JavaScript breakpoint.
Parameters
breakpointId ( BreakpointId )
callback ( function )
Results
error ( error )
Debugger.continueToLocation(Location, callback)
Continues execution until specific location is reached.
Parameters
location ( Location )
Location to continue to.
callback ( function )
Results
error ( error )
Debugger.stepOver(callback)
Steps over the statement.
Parameters
callback ( function )
Results
error ( error )
Debugger.stepInto(callback)
Steps into the function call.
Parameters
callback ( function )
Results
error ( error )
Debugger.stepOut(callback)
Steps out of the function call.
Parameters
callback ( function )
Results
error ( error )
Debugger.pause(callback)
Stops on the next JavaScript statement.
Parameters
callback ( function )
Results
error ( error )
Debugger.resume(callback)
Resumes JavaScript execution.
Parameters
callback ( function )
Results
error ( error )
Debugger.searchInContent(ScriptId, query, [caseSensitive], [isRegex], callback)
Searches for given string in script content.
Parameters
scriptId ( ScriptId )
Id of the script to search in.
query ( string )
String to search for.
caseSensitive ( optional boolean )
If true, search is case sensitive.
isRegex ( optional boolean )
If true, treats string parameter as regex.
callback ( function )
Results
error ( error )
result ( array of GenericTypes.SearchMatch )
List of search matches.
Debugger.getScriptSource(ScriptId, callback)
Returns source for the script with given id.
Parameters
scriptId ( ScriptId )
Id of the script to get source for.
callback ( function )
Results
error ( error )
scriptSource ( string )
Script source.
Debugger.getFunctionDetails(Runtime.RemoteObjectId, callback)
Returns detailed information on given function.
Parameters
functionId ( Runtime.RemoteObjectId )
Id of the function to get location for.
callback ( function )
Results
error ( error )
details ( FunctionDetails )
Information about the function.
Debugger.setPauseOnExceptions(state, callback)
Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none.
Parameters
state ( string enumerated ["none","uncaught","all"] )
Pause on exceptions mode.
callback ( function )
Results
error ( error )
Debugger.evaluateOnCallFrame(CallFrameId, expression, [objectGroup], [includeCommandLineAPI], [doNotPauseOnExceptionsAndMuteConsole], [returnByValue], [generatePreview], [saveResult], callback)
Evaluates expression on a given call frame.
Parameters
callFrameId ( CallFrameId )
Call frame identifier to evaluate on.
expression ( string )
Expression to evaluate.
objectGroup ( optional string )
String object group name to put result into (allows rapid releasing resulting object handles using
releaseObjectGroup).
includeCommandLineAPI ( optional boolean )
Specifies whether command line API should be available to the evaluated expression, defaults to false.
doNotPauseOnExceptionsAndMuteConsole ( optional boolean )
Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.
returnByValue ( optional boolean )
Whether the result is expected to be a JSON object that should be sent by value.
generatePreview ( optional boolean )
Whether preview should be generated for the result.
saveResult ( optional boolean )
Whether the resulting value should be considered for saving in the $n history.
callback ( function )
Results
error ( error )
result ( Runtime.RemoteObject )
Object wrapper for the evaluation result.
wasThrown ( optional boolean )
True if the result was thrown during the evaluation.
savedResultIndex ( optional integer )
If the result was saved, this is the $n index that can be used to access the value.
Debugger.setOverlayMessage([message], callback)
Sets overlay message.
Parameters
message ( optional string )
Overlay message to display when paused in debugger.
callback ( function )
Results
error ( error )
Events
Event: globalObjectCleared
Called when global has been cleared and debugger client should reset its state. Happens upon navigation or reload.
Event: scriptParsed
Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.
Results
scriptId ( ScriptId )
Identifier of the script parsed.
url ( string )
URL or name of the script parsed (if any).
startLine ( integer )
Line offset of the script within the resource with given URL (for script tags).
startColumn ( integer )
Column offset of the script within the resource with given URL.
endLine ( integer )
Last line of the script.
endColumn ( integer )
Length of the last line of the script.
isContentScript ( optional boolean )
Determines whether this script is a user extension script.
sourceMapURL ( optional string )
URL of source map associated with script (if any).
hasSourceURL ( optional boolean )
True, if this script has sourceURL.
Event: scriptFailedToParse
Fired when virtual machine fails to parse the script.
Results
url ( string )
URL of the script that failed to parse.
scriptSource ( string )
Source text of the script that failed to parse.
startLine ( integer )
Line offset of the script within the resource.
errorLine ( integer )
Line with error.
errorMessage ( string )
Parse error message.
Event: breakpointResolved
Fired when breakpoint is resolved to an actual script and location.
Results
breakpointId ( BreakpointId )
Breakpoint unique identifier.
location ( Location )
Actual breakpoint location.
Event: paused
Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria.
Results
callFrames ( array of CallFrame )
Call stack the virtual machine stopped on.
reason ( string enumerated ["XHR","DOM","EventListener","exception","assert","CSPViolation","DebuggerStatement","Breakpoint","PauseOnNextStatement","other"] )
Pause reason.
data ( optional object )
Object containing break-specific auxiliary properties.
Event: resumed
Fired when the virtual machine resumed execution.
Event: didSampleProbe
Fires when a new probe sample is collected.
Results
sample ( ProbeSample )
A collected probe sample.
Event: playBreakpointActionSound
Fired when a "sound" breakpoint action is triggered on a breakpoint.
Results
breakpointActionId ( BreakpointActionIdentifier )
Breakpoint action identifier.
Types
Class: BreakpointId
Type: string
Breakpoint identifier.
Class: BreakpointActionIdentifier
Type: integer
Breakpoint action identifier.
Class: ScriptId
Type: string
Unique script identifier.
Class: CallFrameId
Type: string
Call frame identifier.
Class: Location
Type: object
Location in the source code.
Properties
scriptId ( ScriptId )
Script identifier as reported in the
Debugger.scriptParsed.
lineNumber ( integer )
Line number in the script.
columnNumber ( optional integer )
Column number in the script.
Class: BreakpointAction
Type: object
Action to perform when a breakpoint is triggered.
Properties
type ( string enumerated ["log","evaluate","sound","probe"] )
Different kinds of breakpoint actions.
data ( optional string )
Data associated with this breakpoint type (e.g. for type "eval" this is the JavaScript string to evalulate).
id ( optional BreakpointActionIdentifier )
A frontend-assigned identifier for this breakpoint action.
Class: BreakpointOptions
Type: object
Extra options that modify breakpoint behavior.
Properties
condition ( optional string )
Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
actions ( optional array of BreakpointAction )
Actions to perform automatically when the breakpoint is triggered.
autoContinue ( optional boolean )
Automatically continue after hitting this breakpoint and running actions.
Class: FunctionDetails
Type: object
Information about the function.
Properties
location ( Location )
Location of the function.
name ( optional string )
Name of the function. Not present for anonymous functions.
displayName ( optional string )
Display name of the function(specified in 'displayName' property on the function object).
inferredName ( optional string )
Name of the function inferred from its initial assignment.
scopeChain ( optional array of Scope )
Scope chain for this closure.
Class: CallFrame
Type: object
JavaScript call frame. Array of call frames form the call stack.
Properties
callFrameId ( CallFrameId )
Call frame identifier. This identifier is only valid while the virtual machine is paused.
functionName ( string )
Name of the JavaScript function called on this call frame.
location ( Location )
Location in the source code.
scopeChain ( array of Scope )
Scope chain for this call frame.
this ( Runtime.RemoteObject )
thisobject for this call frame.
Class: Scope
Type: object
Scope description.
Properties
type ( string enumerated ["global","local","with","closure","catch","functionName"] )
Scope type.
object ( Runtime.RemoteObject )
Object representing the scope. For
globalandwithscopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
Class: ProbeSample
Type: object
A sample collected by evaluating a probe breakpoint action.
Properties
probeId ( BreakpointActionIdentifier )
Identifier of the probe breakpoint action that created the sample.
sampleId ( integer )
Unique identifier for this sample.
batchId ( integer )
A batch identifier which is the same for all samples taken at the same breakpoint hit.
timestamp ( number )
Timestamp of when the sample was taken.
payload ( Runtime.RemoteObject )
Contents of the sample.
Class: AssertPauseReason
Type: object
The pause reason auxiliary data when paused because of an assertion.
Properties
message ( optional string )
The console.assert message string if provided.
Class: BreakpointPauseReason
Type: object
The pause reason auxiliary data when paused because of hitting a breakpoint.
Properties
breakpointId ( string )
The identifier of the breakpoint causing the pause.
Class: CSPViolationPauseReason
Type: object
The pause reason auxiliary data when paused because of a Content Security Policy directive.
Properties
directive ( string )
The CSP directive that blocked script execution.