Runtime

Runtime domain exposes JavaScript runtime by means of remote evaluation and mirror objects. Evaluation results are returned as mirror object that expose object type, string representation and unique identifier that can be used for further object reference. Original objects are maintained in memory unless they are either explicitly released or are released along with the other objects in their object group.

Commands

Runtime.awaitPromise

Add handler to promise with given promise object id.

Parameters
Name Type Description
promiseObjectId RemoteObjectId Identifier of the promise.
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.
Return Object
Name Type Description
result RemoteObject Promise result. Will contain rejected value if promise was rejected.
exceptionDetails (optional) ExceptionDetails Exception details if stack strace is available.

Runtime.callFunctionOn

Calls function with given declaration on the given object. Object group of the result is
inherited from the target object.

Parameters
Name Type Description
functionDeclaration string Declaration of the function to call.
objectId (optional) RemoteObjectId Identifier of the object to call function on. Either objectId or executionContextId should
be specified.
arguments (optional) array<CallArgument> Call arguments. All call arguments must belong to the same JavaScript world as the target
object.
silent (optional) boolean In silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides `setPauseOnException` state.
returnByValue (optional) boolean Whether the result is expected to be a JSON object which should be sent by value.
Can be overriden by `serializationOptions`.
generatePreview (optional) Experimental boolean Whether preview should be generated for the result.
userGesture (optional) boolean Whether execution should be treated as initiated by user in the UI.
awaitPromise (optional) boolean Whether execution should `await` for resulting value and return once awaited promise is
resolved.
executionContextId (optional) ExecutionContextId Specifies execution context which global object will be used to call function on. Either
executionContextId or objectId should be specified.
objectGroup (optional) string Symbolic group name that can be used to release multiple objects. If objectGroup is not
specified and objectId is, objectGroup will be inherited from object.
throwOnSideEffect (optional) Experimental boolean Whether to throw an exception if side effect cannot be ruled out during evaluation.
uniqueContextId (optional) Experimental string An alternative way to specify the execution context to call function on.
Compared to contextId that may be reused across processes, this is guaranteed to be
system-unique, so it can be used to prevent accidental function call
in context different than intended (e.g. as a result of navigation across process
boundaries).
This is mutually exclusive with `executionContextId`.
serializationOptions (optional) Experimental SerializationOptions Specifies the result serialization. If provided, overrides
`generatePreview` and `returnByValue`.
Return Object
Name Type Description
result RemoteObject Call result.
exceptionDetails (optional) ExceptionDetails Exception details.

Runtime.compileScript

Compiles expression.

Parameters
Name Type Description
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 (optional) ExecutionContextId Specifies in which execution context to perform script run. If the parameter is omitted the
evaluation will be performed in the context of the inspected page.
Return Object
Name Type Description
scriptId (optional) ScriptId Id of the script.
exceptionDetails (optional) ExceptionDetails Exception details.

Runtime.disable

Disables reporting of execution contexts creation.

Runtime.discardConsoleEntries

Discards collected exceptions and console API calls.

Runtime.enable

Enables reporting of execution contexts creation by means of `executionContextCreated` event.
When the reporting gets enabled the event will be sent immediately for each existing execution
context.

Runtime.evaluate

Evaluates expression on global object.

Parameters
Name Type Description
expression string Expression to evaluate.
objectGroup (optional) string Symbolic group name that can be used to release multiple objects.
includeCommandLineAPI (optional) boolean Determines whether Command Line API should be available during the evaluation.
silent (optional) boolean In silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides `setPauseOnException` state.
contextId (optional) ExecutionContextId Specifies in which execution context to perform evaluation. If the parameter is omitted the
evaluation will be performed in the context of the inspected page.
This is mutually exclusive with `uniqueContextId`, which offers an
alternative way to identify the execution context that is more reliable
in a multi-process environment.
returnByValue (optional) boolean Whether the result is expected to be a JSON object that should be sent by value.
generatePreview (optional) Experimental boolean Whether preview should be generated for the result.
userGesture (optional) boolean Whether execution should be treated as initiated by user in the UI.
awaitPromise (optional) boolean Whether execution should `await` for resulting value and return once awaited promise is
resolved.
throwOnSideEffect (optional) Experimental boolean Whether to throw an exception if side effect cannot be ruled out during evaluation.
This implies `disableBreaks` below.
timeout (optional) Experimental TimeDelta Terminate execution after timing out (number of milliseconds).
disableBreaks (optional) Experimental boolean Disable breakpoints during execution.
replMode (optional) Experimental boolean Setting this flag to true enables `let` re-declaration and top-level `await`.
Note that `let` variables can only be re-declared if they originate from
`replMode` themselves.
allowUnsafeEvalBlockedByCSP (optional) Experimental boolean The Content Security Policy (CSP) for the target might block 'unsafe-eval'
which includes eval(), Function(), setTimeout() and setInterval()
when called with non-callable arguments. This flag bypasses CSP for this
evaluation and allows unsafe-eval. Defaults to true.
uniqueContextId (optional) Experimental string An alternative way to specify the execution context to evaluate in.
Compared to contextId that may be reused across processes, this is guaranteed to be
system-unique, so it can be used to prevent accidental evaluation of the expression
in context different than intended (e.g. as a result of navigation across process
boundaries).
This is mutually exclusive with `contextId`.
serializationOptions (optional) Experimental SerializationOptions Specifies the result serialization. If provided, overrides
`generatePreview` and `returnByValue`.
Return Object
Name Type Description
result RemoteObject Evaluation result.
exceptionDetails (optional) ExceptionDetails Exception details.

Runtime.getIsolateId

Experimental

Returns the isolate id.

Return Object
Name Type Description
id string The isolate id.

Runtime.getHeapUsage

Experimental

Returns the JavaScript heap usage.
It is the total usage of the corresponding isolate not scoped to a particular Runtime.

Return Object
Name Type Description
usedSize number Used JavaScript heap size in bytes.
totalSize number Allocated JavaScript heap size in bytes.
embedderHeapUsedSize number Used size in bytes in the embedder's garbage-collected heap.
backingStorageSize number Size in bytes of backing storage for array buffers and external strings.

Runtime.getProperties

Returns properties of a given object. Object group of the result is inherited from the target
object.

Parameters
Name Type Description
objectId RemoteObjectId Identifier of the object to return properties for.
ownProperties (optional) boolean If true, returns properties belonging only to the element itself, not to its prototype
chain.
accessorPropertiesOnly (optional) Experimental boolean If true, returns accessor properties (with getter/setter) only; internal properties are not
returned either.
generatePreview (optional) Experimental boolean Whether preview should be generated for the results.
nonIndexedPropertiesOnly (optional) Experimental boolean If true, returns non-indexed properties only.
Return Object
Name Type Description
result array<PropertyDescriptor> Object properties.
internalProperties (optional) array<InternalPropertyDescriptor> Internal object properties (only of the element itself).
privateProperties (optional) Experimental array<PrivatePropertyDescriptor> Object private properties.
exceptionDetails (optional) ExceptionDetails Exception details.

Runtime.globalLexicalScopeNames

Returns all let, const and class variables from global scope.

Parameters
Name Type Description
executionContextId (optional) ExecutionContextId Specifies in which execution context to lookup global scope variables.
Return Object
Name Type Description
names array<string>

Runtime.queryObjects

Parameters
Name Type Description
prototypeObjectId RemoteObjectId Identifier of the prototype to return objects for.
objectGroup (optional) string Symbolic group name that can be used to release the results.
Return Object
Name Type Description
objects RemoteObject Array with objects.

Runtime.releaseObject

Releases remote object with given id.

Parameters
Name Type Description
objectId RemoteObjectId Identifier of the object to release.

Runtime.releaseObjectGroup

Releases all remote objects that belong to a given group.

Parameters
Name Type Description
objectGroup string Symbolic object group name.

Runtime.runIfWaitingForDebugger

Tells inspected instance to run if it was waiting for debugger to attach.

Runtime.runScript

Runs script with given id in a given context.

Parameters
Name Type Description
scriptId ScriptId Id of the script to run.
executionContextId (optional) ExecutionContextId Specifies in which execution context to perform script run. If the parameter is omitted the
evaluation will be performed in the context of the inspected page.
objectGroup (optional) string Symbolic group name that can be used to release multiple objects.
silent (optional) boolean In silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides `setPauseOnException` state.
includeCommandLineAPI (optional) boolean Determines whether Command Line API should be available during the evaluation.
returnByValue (optional) boolean Whether the result is expected to be a JSON object which should be sent by value.
generatePreview (optional) boolean Whether preview should be generated for the result.
awaitPromise (optional) boolean Whether execution should `await` for resulting value and return once awaited promise is
resolved.
Return Object
Name Type Description
result RemoteObject Run result.
exceptionDetails (optional) ExceptionDetails Exception details.

Runtime.setAsyncCallStackDepth

Enables or disables async call stacks tracking.

Redirects to: Debugger

Parameters
Name Type Description
maxDepth integer Maximum depth of async call stacks. Setting to `0` will effectively disable collecting async
call stacks (default).

Runtime.setCustomObjectFormatterEnabled

Experimental
Parameters
Name Type Description
enabled boolean

Runtime.setMaxCallStackSizeToCapture

Experimental
Parameters
Name Type Description
size integer

Runtime.terminateExecution

Experimental

Terminate current or next JavaScript execution.
Will cancel the termination when the outer-most script execution ends.

Runtime.addBinding

If executionContextId is empty, adds binding with the given name on the
global objects of all inspected contexts, including those created later,
bindings survive reloads.
Binding function takes exactly one argument, this argument should be string,
in case of any other input, function throws an exception.
Each binding function call produces Runtime.bindingCalled notification.

Parameters
Name Type Description
name string
executionContextId (optional) Experimental Deprecated ExecutionContextId If specified, the binding would only be exposed to the specified
execution context. If omitted and `executionContextName` is not set,
the binding is exposed to all execution contexts of the target.
This parameter is mutually exclusive with `executionContextName`.
Deprecated in favor of `executionContextName` due to an unclear use case
and bugs in implementation (crbug.com/1169639). `executionContextId` will be
removed in the future.
executionContextName (optional) string If specified, the binding is exposed to the executionContext with
matching name, even for contexts created after the binding is added.
See also `ExecutionContext.name` and `worldName` parameter to
`Page.addScriptToEvaluateOnNewDocument`.
This parameter is mutually exclusive with `executionContextId`.

Runtime.removeBinding

This method does not remove binding function from global object but
unsubscribes current runtime agent from Runtime.bindingCalled notifications.

Parameters
Name Type Description
name string

Runtime.getExceptionDetails

Experimental

This method tries to lookup and populate exception details for a
JavaScript Error object.
Note that the stackTrace portion of the resulting exceptionDetails will
only be populated if the Runtime domain was enabled at the time when the
Error was thrown.

Parameters
Name Type Description
errorObjectId RemoteObjectId The error object for which to resolve the exception details.
Return Object
Name Type Description
exceptionDetails (optional) ExceptionDetails

Events

Runtime.bindingCalled

Experimental

Notification is issued every time when binding is called.

Parameters
Name Type Description
name string
payload string
executionContextId ExecutionContextId Identifier of the context where the call was made.

Runtime.consoleAPICalled

Issued when console API was called.

Parameters
Name Type Description
type string Type of the call.
args array<RemoteObject> Call arguments.
executionContextId ExecutionContextId Identifier of the context where the call was made.
timestamp Timestamp Call timestamp.
stackTrace (optional) StackTrace Stack trace captured when the call was made. The async stack chain is automatically reported for
the following call types: `assert`, `error`, `trace`, `warning`. For other types the async call
chain can be retrieved using `Debugger.getStackTrace` and `stackTrace.parentId` field.
context (optional) Experimental string Console context descriptor for calls on non-default console context (not console.*):
'anonymous#unique-logger-id' for call on unnamed context, 'name#unique-logger-id' for call
on named context.

Runtime.exceptionRevoked

Issued when unhandled exception was revoked.

Parameters
Name Type Description
reason string Reason describing why exception was revoked.
exceptionId integer The id of revoked exception, as reported in `exceptionThrown`.

Runtime.exceptionThrown

Issued when exception was thrown and unhandled.

Parameters
Name Type Description
timestamp Timestamp Timestamp of the exception.
exceptionDetails ExceptionDetails

Runtime.executionContextCreated

Issued when new execution context is created.

Parameters
Name Type Description
context ExecutionContextDescription A newly created execution context.

Runtime.executionContextDestroyed

Issued when execution context is destroyed.

Parameters
Name Type Description
executionContextId Deprecated ExecutionContextId Id of the destroyed context
executionContextUniqueId Experimental string Unique Id of the destroyed context

Runtime.executionContextsCleared

Issued when all executionContexts were cleared in browser

Runtime.inspectRequested

Issued when object should be inspected (for example, as a result of inspect() command line API
call).

Parameters
Name Type Description
object RemoteObject
hints object
executionContextId (optional) Experimental ExecutionContextId Identifier of the context where the call was made.

Types

ScriptId

(string)

Unique script identifier.

SerializationOptions

(object)

Represents options for serialization. Overrides `generatePreview` and `returnByValue`.

Properties
Name Type Description
serialization string
maxDepth (optional) integer Deep serialization depth. Default is full depth. Respected only in `deep` serialization mode.
additionalParameters (optional) object Embedder-specific parameters. For example if connected to V8 in Chrome these control DOM
serialization via `maxNodeDepth: integer` and `includeShadowTree: "none" | "open" | "all"`.
Values can be only of type string or integer.

DeepSerializedValue

(object)

Represents deep serialized value.

Properties
Name Type Description
type string
value (optional) any
objectId (optional) string
weakLocalObjectReference (optional) integer Set if value reference met more then once during serialization. In such
case, value is provided only to one of the serialized values. Unique
per value in the scope of one CDP call.

RemoteObjectId

(string)

Unique object identifier.

UnserializableValue

(string)

Primitive value which cannot be JSON-stringified. Includes values `-0`, `NaN`, `Infinity`,
`-Infinity`, and bigint literals.

RemoteObject

(object)

Mirror object referencing original JavaScript object.

Properties
Name Type Description
type string Object type.
subtype (optional) string Object subtype hint. Specified for `object` type values only.
NOTE: If you change anything here, make sure to also update
`subtype` in `ObjectPreview` and `PropertyPreview` below.
className (optional) string Object class (constructor) name. Specified for `object` type values only.
value (optional) any Remote object value in case of primitive values or JSON values (if it was requested).
unserializableValue (optional) UnserializableValue Primitive value which can not be JSON-stringified does not have `value`, but gets this
property.
description (optional) string String representation of the object.
deepSerializedValue (optional) Experimental DeepSerializedValue Deep serialized value.
objectId (optional) RemoteObjectId Unique object identifier (for non-primitive values).
preview (optional) Experimental ObjectPreview Preview containing abbreviated property values. Specified for `object` type values only.
customPreview (optional) Experimental CustomPreview

CustomPreview

(object) Experimental
Properties
Name Type Description
header string The JSON-stringified result of formatter.header(object, config) call.
It contains json ML array that represents RemoteObject.
bodyGetterId (optional) RemoteObjectId If formatter returns true as a result of formatter.hasBody call then bodyGetterId will
contain RemoteObjectId for the function that returns result of formatter.body(object, config) call.
The result value is json ML array.

ObjectPreview

(object) Experimental

Object containing abbreviated remote object value.

Properties
Name Type Description
type string Object type.
subtype (optional) string Object subtype hint. Specified for `object` type values only.
description (optional) string String representation of the object.
overflow boolean True iff some of the properties or entries of the original object did not fit.
properties array<PropertyPreview> List of the properties.
entries (optional) array<EntryPreview> List of the entries. Specified for `map` and `set` subtype values only.

PropertyPreview

(object) Experimental
Properties
Name Type Description
name string Property name.
type string Object type. Accessor means that the property itself is an accessor property.
value (optional) string User-friendly property value string.
valuePreview (optional) ObjectPreview Nested value preview.
subtype (optional) string Object subtype hint. Specified for `object` type values only.

EntryPreview

(object) Experimental
Properties
Name Type Description
key (optional) ObjectPreview Preview of the key. Specified for map-like collection entries.
value ObjectPreview Preview of the value.

PropertyDescriptor

(object)

Object property descriptor.

Properties
Name Type Description
name string Property name or symbol description.
value (optional) RemoteObject The value associated with the property.
writable (optional) boolean True if the value associated with the property may be changed (data descriptors only).
get (optional) RemoteObject A function which serves as a getter for the property, or `undefined` if there is no getter
(accessor descriptors only).
set (optional) RemoteObject A function which serves as a setter for the property, or `undefined` if there is no setter
(accessor descriptors only).
configurable boolean True if the type of this property descriptor may be changed and if the property may be
deleted from the corresponding object.
enumerable boolean True if this property shows up during enumeration of the properties on the corresponding
object.
wasThrown (optional) boolean True if the result was thrown during the evaluation.
isOwn (optional) boolean True if the property is owned for the object.
symbol (optional) RemoteObject Property symbol object, if the property is of the `symbol` type.

InternalPropertyDescriptor

(object)

Object internal property descriptor. This property isn't normally visible in JavaScript code.

Properties
Name Type Description
name string Conventional property name.
value (optional) RemoteObject The value associated with the property.

PrivatePropertyDescriptor

(object) Experimental

Object private field descriptor.

Properties
Name Type Description
name string Private property name.
value (optional) RemoteObject The value associated with the private property.
get (optional) RemoteObject A function which serves as a getter for the private property,
or `undefined` if there is no getter (accessor descriptors only).
set (optional) RemoteObject A function which serves as a setter for the private property,
or `undefined` if there is no setter (accessor descriptors only).

CallArgument

(object)

Represents function call argument. Either remote object id `objectId`, primitive `value`,
unserializable primitive value or neither of (for undefined) them should be specified.

Properties
Name Type Description
value (optional) any Primitive value or serializable javascript object.
unserializableValue (optional) UnserializableValue Primitive value which can not be JSON-stringified.
objectId (optional) RemoteObjectId Remote object handle.

ExecutionContextId

(integer)

Id of an execution context.

ExecutionContextDescription

(object)

Description of an isolated world.

Properties
Name Type Description
id ExecutionContextId Unique id of the execution context. It can be used to specify in which execution context
script evaluation should be performed.
origin string Execution context origin.
name string Human readable name describing given context.
uniqueId Experimental string A system-unique execution context identifier. Unlike the id, this is unique across
multiple processes, so can be reliably used to identify specific context while backend
performs a cross-process navigation.
auxData (optional) object Embedder-specific auxiliary data likely matching {isDefault: boolean, type: 'default'|'isolated'|'worker', frameId: string}

ExceptionDetails

(object)

Detailed information about exception (or error) that was thrown during script compilation or
execution.

Properties
Name Type Description
exceptionId integer Exception id.
text string Exception text, which should be used together with exception object when available.
lineNumber integer Line number of the exception location (0-based).
columnNumber integer Column number of the exception location (0-based).
scriptId (optional) ScriptId Script ID of the exception location.
url (optional) string URL of the exception location, to be used when the script was not reported.
stackTrace (optional) StackTrace JavaScript stack trace if available.
exception (optional) RemoteObject Exception object if available.
executionContextId (optional) ExecutionContextId Identifier of the context where exception happened.
exceptionMetaData (optional) Experimental object Dictionary with entries of meta data that the client associated
with this exception, such as information about associated network
requests, etc.

Timestamp

(number)

Number of milliseconds since epoch.

TimeDelta

(number)

Number of milliseconds.

CallFrame

(object)

Stack entry for runtime errors and assertions.

Properties
Name Type Description
functionName string JavaScript function name.
scriptId ScriptId JavaScript script id.
url string JavaScript script name or url.
lineNumber integer JavaScript script line number (0-based).
columnNumber integer JavaScript script column number (0-based).

StackTrace

(object)

Call frames for assertions or error messages.

Properties
Name Type Description
description (optional) string String label of this stack trace. For async traces this may be a name of the function that
initiated the async call.
callFrames array<CallFrame> JavaScript function name.
parent (optional) StackTrace Asynchronous JavaScript stack trace that preceded this stack, if available.
parentId (optional) Experimental StackTraceId Asynchronous JavaScript stack trace that preceded this stack, if available.

UniqueDebuggerId

(string) Experimental

Unique identifier of current debugger.

StackTraceId

(object) Experimental

If `debuggerId` is set stack trace comes from another debugger and can be resolved there. This
allows to track cross-debugger calls. See `Runtime.StackTrace` and `Debugger.paused` for usages.

Properties
Name Type Description
id string
debuggerId (optional) UniqueDebuggerId

Summary