Runtime Domain
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.
Methods
- Runtime.addBinding
- Runtime.callFunctionOn
- Runtime.compileScript
- Runtime.disable
- Runtime.discardConsoleEntries
- Runtime.enable
- Runtime.evaluate
- Runtime.getProperties
- Runtime.globalLexicalScopeNames
- Runtime.releaseObject
- Runtime.releaseObjectGroup
- Runtime.removeBinding
- Runtime.getHeapUsage Experimental
Events
- Runtime.consoleAPICalled
- Runtime.executionContextCreated
- Runtime.executionContextDestroyed
- Runtime.executionContextsCleared
- Runtime.bindingCalled Experimental
Types
Methods
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.
Runtime.addBinding and @cdp Runtime.removeBinding are explicitly supported at any time during a session, even while the JS runtime hasn't been created yet. For this reason they are handled by the HostAgent.
A map from binding names (registered during this session using @cdp Runtime.addBinding) to execution context selectors.
Even though bindings get added to the global scope as functions that can outlive a session, they are treated as session state, matching Chrome's behaviour (a binding not added by the current session will not emit events on it).
Parameters
name stringexecutionContextIdOptional
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.
executionContextNameOptional
stringIf 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.callFunctionOn #
Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
In V8, @cdp Runtime.evaluate and @cdp Runtime.callFunctionOn populate the
result field with the exception value, and some code paths in Chrome
DevTools depend on this.
See
https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/35aa264a622e853bb28b4c83a7b5cc3b2a9747bc/front_end/core/sdk/RemoteObject.ts#L574-L592
Handles Runtime.callFunctionOn request @cdp Runtime.callFunctionOn Allowed even if domain is not enabled.
Parameters
functionDeclaration stringDeclaration of the function to call.
objectIdOptional
Identifier of the object to call function on. Either objectId or executionContextId should be specified.
argumentsOptional
array[ CallArgument ]Call arguments. All call arguments must belong to the same JavaScript world as the target object.
silentOptional
booleanIn silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides setPauseOnException state.
returnByValueOptional
booleanWhether the result is expected to be a JSON object which should be sent by value.
Can be overriden by serializationOptions.
generatePreviewOptional
booleanWhether preview should be generated for the result.
userGestureOptional
booleanWhether execution should be treated as initiated by user in the UI.
awaitPromiseOptional
booleanWhether execution should await for resulting value and return once awaited promise is
resolved.
executionContextIdOptional
Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified.
objectGroupOptional
stringSymbolic group name that can be used to release multiple objects. If objectGroup is not specified and objectId is, objectGroup will be inherited from object.
throwOnSideEffectOptional
booleanWhether to throw an exception if side effect cannot be ruled out during evaluation.
uniqueContextIdOptional
stringAn 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.
serializationOptionsOptional
Specifies the result serialization. If provided, overrides
generatePreview and returnByValue.
Return object
result Call result.
exceptionDetailsOptional
Exception details.
Runtime.compileScript #
Compiles expression.
Handles Runtime.compileScript request @cdp Runtime.compileScript Not allowed if domain is not enabled.
Parameters
expression stringExpression to compile.
sourceURL stringSource url to be set for the script.
persistScript booleanSpecifies whether the compiled script should be persisted.
executionContextIdOptional
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
scriptIdOptional
Id of the script.
exceptionDetailsOptional
Exception details.
Runtime.disable #
Disables reporting of execution contexts creation.
Handles Runtime.disable request @cdp Runtime.disable If domain is already disabled, will return success.
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.
Handles Runtime.enable request @cdp Runtime.enable If domain is already enabled, will return success.
Runtime.evaluate #
Evaluates expression on global object.
In V8, @cdp Runtime.evaluate and @cdp Runtime.callFunctionOn populate the
result field with the exception value, and some code paths in Chrome
DevTools depend on this.
See
https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/35aa264a622e853bb28b4c83a7b5cc3b2a9747bc/front_end/core/sdk/RemoteObject.ts#L574-L592
Handles Runtime.evaluate request @cdp Runtime.evaluate Allowed even if domain is not enabled.
Parameters
expression stringExpression to evaluate.
objectGroupOptional
stringSymbolic group name that can be used to release multiple objects.
includeCommandLineAPIOptional
booleanDetermines whether Command Line API should be available during the evaluation.
silentOptional
booleanIn silent mode exceptions thrown during evaluation are not reported and do not pause
execution. Overrides setPauseOnException state.
contextIdOptional
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.
returnByValueOptional
booleanWhether the result is expected to be a JSON object that should be sent by value.
generatePreviewOptional
booleanWhether preview should be generated for the result.
userGestureOptional
booleanWhether execution should be treated as initiated by user in the UI.
awaitPromiseOptional
booleanWhether execution should await for resulting value and return once awaited promise is
resolved.
throwOnSideEffectOptional
booleanWhether to throw an exception if side effect cannot be ruled out during evaluation.
This implies disableBreaks below.
timeoutOptional
disableBreaksOptional
booleanDisable breakpoints during execution.
replModeOptional
booleanSetting 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.
allowUnsafeEvalBlockedByCSPOptional
booleanThe 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.
uniqueContextIdOptional
stringAn 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.
serializationOptionsOptional
Specifies the result serialization. If provided, overrides
generatePreview and returnByValue.
Return object
result Evaluation result.
exceptionDetailsOptional
Exception details.
Runtime.getProperties #
Returns properties of a given object. Object group of the result is inherited from the target object.
Handles Runtime.getProperties request @cdp Runtime.getProperties Allowed even if domain is not enabled.
Parameters
objectId Identifier of the object to return properties for.
ownPropertiesOptional
booleanIf true, returns properties belonging only to the element itself, not to its prototype chain.
accessorPropertiesOnlyOptional
booleanIf true, returns accessor properties (with getter/setter) only; internal properties are not returned either.
generatePreviewOptional
booleanWhether preview should be generated for the results.
nonIndexedPropertiesOnlyOptional
booleanIf true, returns non-indexed properties only.
Return object
result array[ PropertyDescriptor ]Object properties.
internalPropertiesOptional
array[ InternalPropertyDescriptor ]Internal object properties (only of the element itself).
privatePropertiesOptional
exceptionDetailsOptional
Exception details.
Runtime.globalLexicalScopeNames #
Returns all let, const and class variables from global scope.
Handles Runtime.globalLexicalScopeNames request @cdp Runtime.globalLexicalScopeNames Allowed even if domain is not enabled.
Parameters
executionContextIdOptional
Specifies in which execution context to lookup global scope variables.
Return object
names array[ string ]Runtime.releaseObject #
Releases remote object with given id.
Handles Runtime.releaseObject request @cdp Runtime.releaseObject Allowed even if domain is not enabled.
Parameters
objectId Identifier of the object to release.
Runtime.releaseObjectGroup #
Releases all remote objects that belong to a given group.
Handles Runtime.releaseObjectGroup request @cdp Runtime.releaseObjectGroup Allowed even if domain is not enabled.
Parameters
objectGroup stringSymbolic object group name.
Runtime.removeBinding #
This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
Runtime.addBinding and @cdp Runtime.removeBinding are explicitly supported at any time during a session, even while the JS runtime hasn't been created yet. For this reason they are handled by the HostAgent.
Runtime.removeBinding has no targeting by execution context. We interpret it to mean "unsubscribe, and stop installing the binding on all new contexts". This diverges slightly from V8, which continues to install the binding on new contexts after it's "removed", but only if the subscription is targeted by context name.
Parameters
name stringRuntime.getHeapUsage Experimental#
Returns the JavaScript heap usage. It is the total usage of the corresponding isolate not scoped to a particular Runtime.
Handles Runtime.getHeapUsage request @cdp Runtime.getHeapUsage Allowed even if domain is not enabled.
Return object
usedSize numberUsed JavaScript heap size in bytes.
totalSize numberAllocated JavaScript heap size in bytes.
embedderHeapUsedSize numberUsed size in bytes in the embedder's garbage-collected heap.
backingStorageSize numberSize in bytes of backing storage for array buffers and external strings.
Events
Runtime.consoleAPICalled #
Issued when console API was called.
We use the @cdp Runtime.consoleAPICalled context parameter to
mark synthetic messages generated by the backend, i.e. not
originating in a real console.* API call.
Parameters
type stringType of the call.
Allowed values: log, debug, info, error, warning, dir, dirxml, table, trace, clear, startGroup, startGroupCollapsed, endGroup, assert, profile, profileEnd, count, timeEnd
args array[ RemoteObject ]Call arguments.
executionContextId Identifier of the context where the call was made.
timestamp Call timestamp.
stackTraceOptional
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.
contextOptional
stringConsole 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.executionContextCreated #
Issued when new execution context is created.
Parameters
context A newly created execution context.
Runtime.executionContextDestroyed #
Issued when execution context is destroyed.
Parameters
executionContextId executionContextUniqueId stringUnique Id of the destroyed context
Runtime.bindingCalled Experimental#
Notification is issued every time when binding is called.
NOTE: When dispatching @cdp Runtime.bindingCalled notifications, we don't re-check whether the session is expecting notifications from the current context - only that it's subscribed to that binding name. Theoretically, this can result in over-sending notifications from contexts that the client no longer cares about, or never cared about to begin with (e.g. if the binding handler was installed by a previous session). // React Native intentionally replicates this behavior for the sake of bug-for-bug compatibility with Chrome, but clients should probably not rely on it.
Parameters
name stringpayload stringexecutionContextId Identifier of the context where the call was made.
Types
Runtime.CallFrame #
Stack entry for runtime errors and assertions.
Type: object
Properties
functionName stringJavaScript function name.
scriptId JavaScript script id.
url stringJavaScript script name or url.
lineNumber integerJavaScript script line number (0-based).
columnNumber integerJavaScript script column number (0-based).
Runtime.ExceptionDetails #
Detailed information about exception (or error) that was thrown during script compilation or execution.
Type: object
Properties
exceptionId integerException id.
text stringException text, which should be used together with exception object when available.
lineNumber integerLine number of the exception location (0-based).
columnNumber integerColumn number of the exception location (0-based).
scriptIdOptional
Script ID of the exception location.
urlOptional
stringURL of the exception location, to be used when the script was not reported.
stackTraceOptional
JavaScript stack trace if available.
exceptionOptional
Exception object if available.
executionContextIdOptional
Identifier of the context where exception happened.
exceptionMetaDataOptional
objectDictionary with entries of meta data that the client associated with this exception, such as information about associated network requests, etc.
Runtime.RemoteObject #
Mirror object referencing original JavaScript object.
Type: object
Runtime.RemoteObject's description property is a string, but in the case of functions, V8 populates it with the result of toString [1] and Chrome DevTools uses a series of regexes [2] to extract structured information about the function. [1] https://source.chromium.org/chromium/chromium/src/+/main:v8/src/debug/debug-interface.cc;l=138-174;drc=42debe0b0e6bf90175dd0d121eb0e7dc11a6d29c [2] https://github.com/facebookexperimental/rn-chrome-devtools-frontend/blob/9a23d4c7c4c2d1a3d9e913af38d6965f474c4284/front_end/ui/legacy/components/object_ui/ObjectPropertiesSection.ts#L311-L391
Properties
type stringObject type.
Allowed values: object, function, undefined, string, number, boolean, symbol, bigint
subtypeOptional
stringObject 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.
Allowed values: array, null, node, regexp, date, map, set, weakmap, weakset, iterator, generator, error, proxy, promise, typedarray, arraybuffer, dataview, webassemblymemory, wasmvalue, trustedtype
classNameOptional
stringObject class (constructor) name. Specified for object type values only.
valueOptional
anyRemote object value in case of primitive values or JSON values (if it was requested).
unserializableValueOptional
Primitive value which can not be JSON-stringified does not have value, but gets this
property.
descriptionOptional
stringString representation of the object.
deepSerializedValueOptional
objectIdOptional
Unique object identifier (for non-primitive values).
previewOptional
Preview containing abbreviated property values. Specified for object type values only.
customPreviewOptional
Runtime.StackTrace #
Call frames for assertions or error messages.
Type: object
Properties
descriptionOptional
stringString 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.
parentOptional
Asynchronous JavaScript stack trace that preceded this stack, if available.
parentIdOptional
Asynchronous JavaScript stack trace that preceded this stack, if available.
Runtime.StackTraceId 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.
Type: object
Properties
id stringdebuggerIdOptional