devtools-protocol

Debugger

Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.

Methodsenable, disable, getPossibleBreakpoints, setBreakpointsActive, setBreakpointByUrl, setBreakpoint, removeBreakpoint, stepOver, stepInto, stepOut, pause, resume, getScriptSource, setPauseOnExceptions, evaluateOnCallFrame, setVariableValue, setBlackboxPatterns
EventsscriptParsed, breakpointResolved, paused, resumed
TypesBreakpointId, CallFrameId, Location, BreakLocation, CallFrame, Scope

Methods

enable

Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.


disable

Disables debugger for given page.


getPossibleBreakpoints

Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.

Parameters
start Location Start of range to search possible breakpoint locations in.
end Location End of range to search possible breakpoint locations in (excluding). When not specified, end of scripts is used as end of range.
Returns
locations BreakLocation List of the possible breakpoint locations.

setBreakpointsActive

Activates / deactivates all breakpoints on the page.

Parameters
active boolean New value for breakpoints active state.

setBreakpointByUrl

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 url or urlRegex must be specified.
columnNumber
optional
integer Offset in the line to set breakpoint at.
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.
Returns
breakpointId BreakpointId Id of the created breakpoint for further reference.
locations Location[] List of the locations this breakpoint resolved into upon addition.

setBreakpoint

Sets JavaScript breakpoint at a given location.

Parameters
location Location Location to set breakpoint in.
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.
Returns
breakpointId BreakpointId Id of the created breakpoint for further reference.
actualLocation Location Location this breakpoint resolved into.

removeBreakpoint

Removes JavaScript breakpoint.

Parameters
breakpointId BreakpointId

stepOver

Steps over the statement.


stepInto

Steps into the function call.


stepOut

Steps out of the function call.


pause

Stops on the next JavaScript statement.


resume

Resumes JavaScript execution.


getScriptSource

Returns source for the script with given id.

Parameters
scriptId Runtime.ScriptId Id of the script to get source for.
Returns
scriptSource string Script source.

setPauseOnExceptions

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
Allowed values: none, uncaught, all
Pause on exceptions mode.

evaluateOnCallFrame

Evaluates expression on a given call frame.

Parameters
callFrameId CallFrameId Call frame identifier to evaluate on.
expression string Expression to evaluate.
Returns
result Runtime.RemoteObject Object wrapper for the evaluation result.

setVariableValue

Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.

Parameters
scopeNumber integer 0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually.
variableName string Variable name.
newValue Runtime.CallArgument New variable value.
callFrameId CallFrameId Id of callframe that holds variable.

setBlackboxPatterns

Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. The debugger will try to leave blackboxed script by performing ‘step in’ several times, finally resorting to ‘step out’ if unsuccessful.

Parameters
patterns string[] Array of regexps that will be used to check script url for blackbox state.

Events

scriptParsed

Fired when the script is parsed. This event is also fired for all known and uncollected scripts upon enabling debugger.

Parameters
scriptId Runtime.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.
executionContextId Runtime.ExecutionContextId Specifies script creation context.
sourceMapURL
optional
string URL of source map associated with script (if any).
length
optional
integer This script length.
msMimeType
optional
string This is the mime type.

breakpointResolved

Fired when breakpoint is resolved to an actual script and location.

Parameters
breakpointId BreakpointId Breakpoint unique identifier.
location Location Actual breakpoint location.

paused

Fired when the debuggers breaks for a breakpoint or exception.

Parameters
callFrames CallFrame[] Call stack the debugger stopped on.
reason string
Allowed values: breakpoint, step, exception, other, EventListener
Pause reason.
data
optional
object Object containing break-specific auxiliary properties.
hitBreakpoints
optional
string[] Hit breakpoints IDs
asyncStackTrace
optional
StackTrace JavaScript async stack trace.

resumed

Fired when the debugger resumes execution.


Types

BreakpointId string

Breakpoint identifier.


CallFrameId string

Call frame identifier.


Location object

Location in the source code.

Properties
scriptId Runtime.ScriptId Script identifier as reported in the Debugger.scriptParsed.
lineNumber integer Line number in the script (0-based).
columnNumber
optional
integer Column number in the script (0-based).
msLength integer Microsoft: Length of code (i.e. number of characters) at this call frame.

BreakLocation object

Break location in the source code.

Properties
scriptId Runtime.ScriptId Script identifier as reported in the Debugger.scriptParsed.
lineNumber integer Line number in the script (0-based).
columnNumber
optional
integer Column number in the script (0-based).
msLength integer Microsoft: Length of code (i.e. number of characters) at this call frame.
type
optional
string Allowed values: debuggerStatement, call, return.

CallFrame 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 debugger is paused.
functionName string Name of the JavaScript function called on this call frame.
functionLocation
optional
Location Location in the source code.
location Location Location in the source code.
url string JavaScript script name or url.
scopeChain Scope[] Scope chain for this call frame.
this Runtime.RemoteObject this object for this call frame.
returnValue
optional
Runtime.RemoteObject The value being returned, if the function is at return point.

Scope object

Scope description.

Properties
type string
Allowed values: global, local, with, closure, catch, block, script, eval, module, return
Scope type.
object Runtime.RemoteObject Object representing the scope. For global and with scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
name
optional
string
startLocation
optional
Location Location in the source code where scope starts
endLocation
optional
Location Location in the source code where scope ends

Dependencies

Runtime