Debugger Domain
Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.
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.
setBreakpointsActive#
Activates / deactivates all breakpoints on the page.
Parameters
- active
- boolean New value for breakpoints active state.
setSkipAllPauses#
Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).
Parameters
- skipped
- boolean New value for skip pauses 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
- string URL of the resources to set breakpoint on.
- urlRegex
-
string
Regex pattern for the URLs of the resources to set breakpoints on. Either
url
orurlRegex
must be specified. - columnNumber
- integer Offset in the line to set breakpoint at.
- condition
- string Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
Return object
- breakpointId
- BreakpointId Id of the created breakpoint for further reference.
- locations
- array [ 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
- string Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true.
Return object
- breakpointId
- BreakpointId Id of the created breakpoint for further reference.
- actualLocation
- Location Location this breakpoint resolved into.
continueToLocation#
Continues execution until specific location is reached.
Parameters
- location
- Location Location to continue to.
- interstatementLocation
- boolean Allows breakpoints at the intemediate positions inside statements.
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.
stepIntoAsync#
Steps into the first async operation handler that was scheduled by or after the current statement.
searchInContent#
Searches for given string in script content.
Parameters
- scriptId
- ScriptId Id of the script to search in.
- query
- string String to search for.
- caseSensitive
- boolean If true, search is case sensitive.
- isRegex
- boolean If true, treats string parameter as regex.
Return object
- result
- array [ SearchMatch ] List of search matches.
canSetScriptSource#
Always returns true.
Return object
- result
-
boolean
True if
setScriptSource
is supported.
setScriptSource#
Edits JavaScript source live.
Parameters
- scriptId
- ScriptId Id of the script to edit.
- scriptSource
- string New content of the script.
- preview
- boolean If true the change will not actually be applied. Preview mode may be used to get result description without actually modifying the code.
Return object
- callFrames
- array [ CallFrame ] New stack trace in case editing has happened while VM was stopped.
- stackChanged
- boolean Whether current call stack was modified after applying the changes.
- asyncStackTrace
- StackTrace Async stack trace, if any.
restartFrame#
Restarts particular call frame from the beginning.
Parameters
- callFrameId
- CallFrameId Call frame identifier to evaluate on.
Return object
- callFrames
- array [ CallFrame ] New stack trace.
- asyncStackTrace
- StackTrace Async stack trace, if any.
getScriptSource#
Returns source for the script with given id.
Parameters
- scriptId
- ScriptId Id of the script to get source for.
Return object
- scriptSource
- string Script source.
getFunctionDetails#
Returns detailed information on given function.
Parameters
- functionId
- Runtime.RemoteObjectId Id of the function to get details for.
Return object
- details
- FunctionDetails Information about the function.
getGeneratorObjectDetails#
Returns detailed information on given generator object.
Parameters
- objectId
- Runtime.RemoteObjectId Id of the generator object to get details for.
Return object
- details
- GeneratorObjectDetails Information about the generator object.
getCollectionEntries#
Returns entries of given collection.
Parameters
- objectId
- Runtime.RemoteObjectId Id of the collection to get entries for.
Return object
- entries
- array [ CollectionEntry ] Array of collection entries.
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 Pause on exceptions mode. Allowed values: none, uncaught, all.
evaluateOnCallFrame#
Evaluates expression on a given call frame.
Parameters
- callFrameId
- CallFrameId Call frame identifier to evaluate on.
- expression
- string Expression to evaluate.
- objectGroup
-
string
String object group name to put result into (allows rapid releasing resulting object handles using
releaseObjectGroup
). - includeCommandLineAPI
- boolean Specifies whether command line API should be available to the evaluated expression, defaults to false.
- doNotPauseOnExceptionsAndMuteConsole
- boolean Specifies whether evaluation should stop on exceptions and mute console. Overrides setPauseOnException state.
- returnByValue
- boolean Whether the result is expected to be a JSON object that should be sent by value.
- generatePreview
- boolean Whether preview should be generated for the result.
Return object
- result
- Runtime.RemoteObject Object wrapper for the evaluation result.
- wasThrown
- boolean True if the result was thrown during the evaluation.
- exceptionDetails
- ExceptionDetails Exception details.
compileScript#
Compiles expression.
Parameters
- expression
- string Expression to compile.
- sourceURL
- string Source url to be set for the script.
- persistScript
- boolean Specifies whether the compiled script should be persisted.
- executionContextId
- Runtime.ExecutionContextId Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page.
Return object
- scriptId
- ScriptId Id of the script.
- exceptionDetails
- ExceptionDetails Exception details.
runScript#
Runs script with given id in a given context.
Parameters
- scriptId
- ScriptId Id of the script to run.
- executionContextId
- Runtime.ExecutionContextId Specifies in which isolated context to perform script run. Each content script lives in an isolated context and this parameter may be used to specify one of those contexts. If the parameter is omitted or 0 the evaluation will be performed in the context of the inspected page.
- objectGroup
- string Symbolic group name that can be used to release multiple objects.
- doNotPauseOnExceptionsAndMuteConsole
- boolean Specifies whether script run should stop on exceptions and mute console. Overrides setPauseOnException state.
Return object
- result
- Runtime.RemoteObject Run result.
- exceptionDetails
- ExceptionDetails Exception details.
setVariableValue#
Changes value of variable in a callframe or a closure. Either callframe or function must be specified. 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.
- functionObjectId
- Runtime.RemoteObjectId Object id of closure (function) that holds variable.
getStepInPositions#
Lists all positions where step-in is possible for a current statement in a specified call frame
Parameters
- callFrameId
- CallFrameId Id of a call frame where the current statement should be analized
Return object
- stepInPositions
- array [ Location ] experimental
getBacktrace#
Returns call stack including variables changed since VM was paused. VM must be paused.
Return object
- callFrames
- array [ CallFrame ] Call stack the virtual machine stopped on.
- asyncStackTrace
- StackTrace Async stack trace, if any.
skipStackFrames#
Makes backend skip steps in the sources with names matching given pattern. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.
Parameters
- script
- string Regular expression defining the scripts to ignore while stepping.
- skipContentScripts
- boolean True, if all content scripts should be ignored.
setAsyncCallStackDepth#
Enables or disables async call stacks tracking.
Parameters
- maxDepth
-
integer
Maximum depth of async call stacks. Setting to
0
will effectively disable collecting async call stacks (default).
enablePromiseTracker#
Enables promise tracking, information about Promise
s created or updated will now be stored on the backend.
Parameters
- captureStacks
- boolean Whether to capture stack traces for promise creation and settlement events (default: false).
disablePromiseTracker#
Disables promise tracking.
getPromiseById#
Returns Promise
with specified ID.
Parameters
- promiseId
- integer
- objectGroup
- string Symbolic group name that can be used to release multiple objects.
Return object
- promise
-
Runtime.RemoteObject
Object wrapper for
Promise
with specified ID, if any.
flushAsyncOperationEvents#
Fires pending asyncOperationStarted
events (if any), as if a debugger stepping session has just been started.
setAsyncOperationBreakpoint#
Sets breakpoint on AsyncOperation callback handler.
Parameters
- operationId
- integer ID of the async operation to set breakpoint for.
removeAsyncOperationBreakpoint#
Removes AsyncOperation breakpoint.
Parameters
- operationId
- integer ID of the async operation to remove breakpoint for.
Events
globalObjectCleared#
Called when global has been cleared and debugger client should reset its state. Happens upon navigation or reload.
scriptParsed#
Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger.
Parameters
- 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
- boolean Determines whether this script is a user extension script.
- isInternalScript
- boolean Determines whether this script is an internal script.
- sourceMapURL
- string URL of source map associated with script (if any).
- hasSourceURL
- boolean True, if this script has sourceURL.
scriptFailedToParse#
Fired when virtual machine fails to parse the script.
Parameters
- 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
- boolean Determines whether this script is a user extension script.
- isInternalScript
- boolean Determines whether this script is an internal script.
- sourceMapURL
- string URL of source map associated with script (if any).
- hasSourceURL
- boolean True, if this script has sourceURL.
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 virtual machine stopped on breakpoint or exception or any other stop criteria.
Parameters
- callFrames
- array [ CallFrame ] Call stack the virtual machine stopped on.
- reason
- string Pause reason. Allowed values: XHR, DOM, EventListener, exception, assert, CSPViolation, debugCommand, promiseRejection, AsyncOperation, other.
- data
- object Object containing break-specific auxiliary properties.
- hitBreakpoints
- array [string] Hit breakpoints IDs
- asyncStackTrace
- StackTrace Async stack trace, if any.
resumed#
Fired when the virtual machine resumed execution.
promiseUpdated#
Fired when a Promise
is created, updated or garbage collected.
Parameters
- eventType
- string Type of the event. Allowed values: new, update, gc.
- promise
-
PromiseDetails
Information about the updated
Promise
.
asyncOperationStarted#
Fired when an async operation is scheduled (while in a debugger stepping session).
Parameters
- operation
- AsyncOperation Information about the async operation.
asyncOperationCompleted#
Fired when an async operation is completed (while in a debugger stepping session).
Parameters
- id
- integer ID of the async operation that was completed.
Types
Location#
Location in the source code.
Type: object
Properties
- scriptId
-
ScriptId
Script identifier as reported in the
Debugger.scriptParsed
. - lineNumber
- integer Line number in the script (0-based).
- columnNumber
- integer Column number in the script (0-based).
GeneratorObjectDetails#
Information about the generator object.
Type: object
Properties
- function
- Runtime.RemoteObject Generator function.
- functionName
- string Name of the generator function.
- status
- string Current generator object status. Allowed values: running, suspended, closed.
- location
- Location If suspended, location where generator function was suspended (e.g. location of the last 'yield'). Otherwise, location of the generator function.
CollectionEntry#
Collection entry.
Type: object
Properties
- key
- Runtime.RemoteObject Entry key of a map-like collection, otherwise not provided.
- value
- Runtime.RemoteObject Entry value.
CallFrame#
JavaScript call frame. Array of call frames form the call stack.
Type: object
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.
- functionLocation
- Location Location in the source code.
- location
- Location Location in the source code.
- scopeChain
- array [ Scope ] Scope chain for this call frame.
- this
-
Runtime.RemoteObject
this
object for this call frame. - returnValue
- Runtime.RemoteObject The value being returned, if the function is at return point.
StackTrace#
JavaScript call stack, including async stack traces.
Type: object
Properties
- callFrames
- array [ CallFrame ] Call frames of the stack trace.
- description
- string String label of this stack trace. For async traces this may be a name of the function that initiated the async call.
- asyncStackTrace
- StackTrace Async stack trace, if any.
Scope#
Scope description.
Type: object
Properties
- type
- string Scope type. Allowed values: global, local, with, closure, catch, block, script.
- object
-
Runtime.RemoteObject
Object representing the scope. For
global
andwith
scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties.
ExceptionDetails#
Detailed information on exception (or error) that was thrown during script compilation or execution.
Type: object
Properties
- text
- string Exception text.
- url
- string URL of the message origin.
- scriptId
- string Script ID of the message origin.
- line
- integer Line number in the resource that generated this message.
- column
- integer Column number in the resource that generated this message.
- stackTrace
- Console.StackTrace JavaScript stack trace for assertions and error messages.
SetScriptSourceError#
Error data for setScriptSource command. compileError is a case type for uncompilable script source error.
Type: object
Properties
- compileError
- object
PromiseDetails#
Information about the promise. All fields but id are optional and if present they reflect the new state of the property on the promise with given id.
Type: object
Properties
- id
- integer Unique id of the promise.
- status
- string Status of the promise. Allowed values: pending, resolved, rejected.
- parentId
- integer Id of the parent promise.
- callFrame
- Console.CallFrame Top call frame on promise creation.
- creationTime
- number Creation time of the promise.
- settlementTime
- number Settlement time of the promise.
- creationStack
- Console.StackTrace JavaScript stack trace on promise creation.
- asyncCreationStack
- Console.AsyncStackTrace JavaScript asynchronous stack trace on promise creation, if available.
- settlementStack
- Console.StackTrace JavaScript stack trace on promise settlement.
- asyncSettlementStack
- Console.AsyncStackTrace JavaScript asynchronous stack trace on promise settlement, if available.
AsyncOperation#
Information about the async operation.
Type: object
Properties
- id
- integer Unique id of the async operation.
- description
- string String description of the async operation.
- stackTrace
- Console.StackTrace Stack trace where async operation was scheduled.
- asyncStackTrace
- Console.AsyncStackTrace Asynchronous stack trace where async operation was scheduled, if available.
SearchMatch#
Search match for resource.
Type: object
Properties
- lineNumber
- number Line number in resource content.
- lineContent
- string Line with match content.