Runtime

class Runtime(cdp: CDP) : 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.

Constructors

Link copied to clipboard
constructor(cdp: CDP)

Types

Link copied to clipboard
@Serializable
data class AddBindingParameter(val name: String, val executionContextId: Int? = null, val executionContextName: String? = null)
Link copied to clipboard
@Serializable
data class AwaitPromiseParameter(val promiseObjectId: String, val returnByValue: Boolean? = null, val generatePreview: Boolean? = null)
Link copied to clipboard
@Serializable
data class AwaitPromiseReturn(val result: Runtime.RemoteObject, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class BindingCalledParameter(val name: String, val payload: String, val executionContextId: Int)

Notification is issued every time when binding is called.

Link copied to clipboard
@Serializable
data class CallArgument(val value: JsonElement? = null, val unserializableValue: String? = null, val objectId: String? = null)

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

Link copied to clipboard
@Serializable
data class CallFrame(val functionName: String, val scriptId: String, val url: String, val lineNumber: Int, val columnNumber: Int)

Stack entry for runtime errors and assertions.

Link copied to clipboard
@Serializable
data class CallFunctionOnParameter(val functionDeclaration: String, val objectId: String? = null, val arguments: List<Runtime.CallArgument>? = null, val silent: Boolean? = null, val returnByValue: Boolean? = null, val generatePreview: Boolean? = null, val userGesture: Boolean? = null, val awaitPromise: Boolean? = null, val executionContextId: Int? = null, val objectGroup: String? = null, val throwOnSideEffect: Boolean? = null, val uniqueContextId: String? = null, val serializationOptions: Runtime.SerializationOptions? = null)
Link copied to clipboard
@Serializable
data class CallFunctionOnReturn(val result: Runtime.RemoteObject, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class CompileScriptParameter(val expression: String, val sourceURL: String, val persistScript: Boolean, val executionContextId: Int? = null)
Link copied to clipboard
@Serializable
data class CompileScriptReturn(val scriptId: String?, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class ConsoleAPICalledParameter(val type: String, val args: List<Runtime.RemoteObject>, val executionContextId: Int, val timestamp: Double, val stackTrace: Runtime.StackTrace? = null, val context: String? = null)

Issued when console API was called.

Link copied to clipboard
@Serializable
data class CustomPreview(val header: String, val bodyGetterId: String? = null)
Link copied to clipboard
@Serializable
data class DeepSerializedValue(val type: String, val value: JsonElement? = null, val objectId: String? = null, val weakLocalObjectReference: Int? = null)

Represents deep serialized value.

Link copied to clipboard
@Serializable
data class EntryPreview(val key: Runtime.ObjectPreview? = null, val value: Runtime.ObjectPreview)
Link copied to clipboard
@Serializable
data class EvaluateParameter(val expression: String, val objectGroup: String? = null, val includeCommandLineAPI: Boolean? = null, val silent: Boolean? = null, val contextId: Int? = null, val returnByValue: Boolean? = null, val generatePreview: Boolean? = null, val userGesture: Boolean? = null, val awaitPromise: Boolean? = null, val throwOnSideEffect: Boolean? = null, val timeout: Double? = null, val disableBreaks: Boolean? = null, val replMode: Boolean? = null, val allowUnsafeEvalBlockedByCSP: Boolean? = null, val uniqueContextId: String? = null, val serializationOptions: Runtime.SerializationOptions? = null)
Link copied to clipboard
@Serializable
data class EvaluateReturn(val result: Runtime.RemoteObject, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class ExceptionDetails(val exceptionId: Int, val text: String, val lineNumber: Int, val columnNumber: Int, val scriptId: String? = null, val url: String? = null, val stackTrace: Runtime.StackTrace? = null, val exception: Runtime.RemoteObject? = null, val executionContextId: Int? = null, val exceptionMetaData: Map<String, JsonElement>? = null)

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

Link copied to clipboard
@Serializable
data class ExceptionRevokedParameter(val reason: String, val exceptionId: Int)

Issued when unhandled exception was revoked.

Link copied to clipboard
@Serializable
data class ExceptionThrownParameter(val timestamp: Double, val exceptionDetails: Runtime.ExceptionDetails)

Issued when exception was thrown and unhandled.

Link copied to clipboard

Issued when new execution context is created.

Link copied to clipboard
@Serializable
data class ExecutionContextDescription(val id: Int, val origin: String, val name: String, val uniqueId: String, val auxData: Map<String, JsonElement>? = null)

Description of an isolated world.

Link copied to clipboard
@Serializable
data class ExecutionContextDestroyedParameter(val executionContextId: Int, val executionContextUniqueId: String)

Issued when execution context is destroyed.

Link copied to clipboard
@Serializable
data class GetExceptionDetailsParameter(val errorObjectId: String)
Link copied to clipboard
@Serializable
data class GetExceptionDetailsReturn(val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class GetHeapUsageReturn(val usedSize: Double, val totalSize: Double, val embedderHeapUsedSize: Double, val backingStorageSize: Double)
Link copied to clipboard
@Serializable
data class GetIsolateIdReturn(val id: String)
Link copied to clipboard
@Serializable
data class GetPropertiesParameter(val objectId: String, val ownProperties: Boolean? = null, val accessorPropertiesOnly: Boolean? = null, val generatePreview: Boolean? = null, val nonIndexedPropertiesOnly: Boolean? = null)
Link copied to clipboard
@Serializable
data class GetPropertiesReturn(val result: List<Runtime.PropertyDescriptor>, val internalProperties: List<Runtime.InternalPropertyDescriptor>?, val privateProperties: List<Runtime.PrivatePropertyDescriptor>?, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class GlobalLexicalScopeNamesParameter(val executionContextId: Int? = null)
Link copied to clipboard
@Serializable
data class GlobalLexicalScopeNamesReturn(val names: List<String>)
Link copied to clipboard
@Serializable
data class InspectRequestedParameter(val object: Runtime.RemoteObject, val hints: Map<String, JsonElement>, val executionContextId: Int? = null)

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

Link copied to clipboard
@Serializable
data class InternalPropertyDescriptor(val name: String, val value: Runtime.RemoteObject? = null)

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

Link copied to clipboard
@Serializable
data class ObjectPreview(val type: String, val subtype: String? = null, val description: String? = null, val overflow: Boolean, val properties: List<Runtime.PropertyPreview>, val entries: List<Runtime.EntryPreview>? = null)

Object containing abbreviated remote object value.

Link copied to clipboard
@Serializable
data class PrivatePropertyDescriptor(val name: String, val value: Runtime.RemoteObject? = null, val get: Runtime.RemoteObject? = null, val set: Runtime.RemoteObject? = null)

Object private field descriptor.

Link copied to clipboard
@Serializable
data class PropertyDescriptor(val name: String, val value: Runtime.RemoteObject? = null, val writable: Boolean? = null, val get: Runtime.RemoteObject? = null, val set: Runtime.RemoteObject? = null, val configurable: Boolean, val enumerable: Boolean, val wasThrown: Boolean? = null, val isOwn: Boolean? = null, val symbol: Runtime.RemoteObject? = null)

Object property descriptor.

Link copied to clipboard
@Serializable
data class PropertyPreview(val name: String, val type: String, val value: String? = null, val valuePreview: Runtime.ObjectPreview? = null, val subtype: String? = null)
Link copied to clipboard
@Serializable
data class QueryObjectsParameter(val prototypeObjectId: String, val objectGroup: String? = null)
Link copied to clipboard
@Serializable
data class QueryObjectsReturn(val objects: Runtime.RemoteObject)
Link copied to clipboard
@Serializable
data class ReleaseObjectGroupParameter(val objectGroup: String)
Link copied to clipboard
@Serializable
data class ReleaseObjectParameter(val objectId: String)
Link copied to clipboard
@Serializable
data class RemoteObject(val type: String, val subtype: String? = null, val className: String? = null, val value: JsonElement? = null, val unserializableValue: String? = null, val description: String? = null, val deepSerializedValue: Runtime.DeepSerializedValue? = null, val objectId: String? = null, val preview: Runtime.ObjectPreview? = null, val customPreview: Runtime.CustomPreview? = null)

Mirror object referencing original JavaScript object.

Link copied to clipboard
@Serializable
data class RemoveBindingParameter(val name: String)
Link copied to clipboard
@Serializable
data class RunScriptParameter(val scriptId: String, val executionContextId: Int? = null, val objectGroup: String? = null, val silent: Boolean? = null, val includeCommandLineAPI: Boolean? = null, val returnByValue: Boolean? = null, val generatePreview: Boolean? = null, val awaitPromise: Boolean? = null)
Link copied to clipboard
@Serializable
data class RunScriptReturn(val result: Runtime.RemoteObject, val exceptionDetails: Runtime.ExceptionDetails?)
Link copied to clipboard
@Serializable
data class SerializationOptions(val serialization: String, val maxDepth: Int? = null, val additionalParameters: Map<String, JsonElement>? = null)

Represents options for serialization. Overrides generatePreview and returnByValue.

Link copied to clipboard
@Serializable
data class SetAsyncCallStackDepthParameter(val maxDepth: Int)
Link copied to clipboard
@Serializable
data class SetCustomObjectFormatterEnabledParameter(val enabled: Boolean)
Link copied to clipboard
@Serializable
data class SetMaxCallStackSizeToCaptureParameter(val size: Int)
Link copied to clipboard
@Serializable
data class StackTrace(val description: String? = null, val callFrames: List<Runtime.CallFrame>, val parent: Runtime.StackTrace? = null, val parentId: Runtime.StackTraceId? = null)

Call frames for assertions or error messages.

Link copied to clipboard
@Serializable
data class StackTraceId(val id: String, val debuggerId: String? = null)

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

Link copied to clipboard

Notification is issued every time when binding is called.

Link copied to clipboard

Issued when console API was called.

Link copied to clipboard

Issued when unhandled exception was revoked.

Link copied to clipboard

Issued when exception was thrown and unhandled.

Link copied to clipboard

Issued when new execution context is created.

Link copied to clipboard

Issued when execution context is destroyed.

Link copied to clipboard

Issued when all executionContexts were cleared in browser

Link copied to clipboard

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

Functions

Link copied to clipboard
suspend fun addBinding(args: Runtime.AddBindingParameter, mode: CommandMode = CommandMode.DEFAULT)
suspend fun addBinding(name: String, executionContextId: Int? = null, executionContextName: String? = null)

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.

Link copied to clipboard
suspend fun awaitPromise(args: Runtime.AwaitPromiseParameter, mode: CommandMode = CommandMode.DEFAULT): Runtime.AwaitPromiseReturn
suspend fun awaitPromise(promiseObjectId: String, returnByValue: Boolean? = null, generatePreview: Boolean? = null): Runtime.AwaitPromiseReturn

Add handler to promise with given promise object id.

Link copied to clipboard
suspend fun callFunctionOn(functionDeclaration: String, objectId: String? = null, arguments: List<Runtime.CallArgument>? = null, silent: Boolean? = null, returnByValue: Boolean? = null, generatePreview: Boolean? = null, userGesture: Boolean? = null, awaitPromise: Boolean? = null, executionContextId: Int? = null, objectGroup: String? = null, throwOnSideEffect: Boolean? = null, uniqueContextId: String? = null, serializationOptions: Runtime.SerializationOptions? = null): Runtime.CallFunctionOnReturn

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

Link copied to clipboard
suspend fun compileScript(expression: String, sourceURL: String, persistScript: Boolean, executionContextId: Int? = null): Runtime.CompileScriptReturn

Compiles expression.

Link copied to clipboard
suspend fun disable(mode: CommandMode = CommandMode.DEFAULT)

Disables reporting of execution contexts creation.

Link copied to clipboard
suspend fun discardConsoleEntries(mode: CommandMode = CommandMode.DEFAULT)

Discards collected exceptions and console API calls.

Link copied to clipboard
suspend fun enable(mode: CommandMode = CommandMode.DEFAULT)

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.

Link copied to clipboard
suspend fun evaluate(args: Runtime.EvaluateParameter, mode: CommandMode = CommandMode.DEFAULT): Runtime.EvaluateReturn
suspend fun evaluate(expression: String, objectGroup: String? = null, includeCommandLineAPI: Boolean? = null, silent: Boolean? = null, contextId: Int? = null, returnByValue: Boolean? = null, generatePreview: Boolean? = null, userGesture: Boolean? = null, awaitPromise: Boolean? = null, throwOnSideEffect: Boolean? = null, timeout: Double? = null, disableBreaks: Boolean? = null, replMode: Boolean? = null, allowUnsafeEvalBlockedByCSP: Boolean? = null, uniqueContextId: String? = null, serializationOptions: Runtime.SerializationOptions? = null): Runtime.EvaluateReturn

Evaluates expression on global object.

Link copied to clipboard

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.

Link copied to clipboard
suspend fun getHeapUsage(mode: CommandMode = CommandMode.DEFAULT): Runtime.GetHeapUsageReturn

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

Link copied to clipboard
suspend fun getIsolateId(mode: CommandMode = CommandMode.DEFAULT): Runtime.GetIsolateIdReturn

Returns the isolate id.

Link copied to clipboard
suspend fun getProperties(objectId: String, ownProperties: Boolean? = null, accessorPropertiesOnly: Boolean? = null, generatePreview: Boolean? = null, nonIndexedPropertiesOnly: Boolean? = null): Runtime.GetPropertiesReturn

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

Link copied to clipboard
suspend fun globalLexicalScopeNames(executionContextId: Int? = null): Runtime.GlobalLexicalScopeNamesReturn

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

Link copied to clipboard
suspend fun queryObjects(args: Runtime.QueryObjectsParameter, mode: CommandMode = CommandMode.DEFAULT): Runtime.QueryObjectsReturn
suspend fun queryObjects(prototypeObjectId: String, objectGroup: String? = null): Runtime.QueryObjectsReturn
Link copied to clipboard
suspend fun releaseObject(objectId: String)
suspend fun releaseObject(args: Runtime.ReleaseObjectParameter, mode: CommandMode = CommandMode.DEFAULT)

Releases remote object with given id.

Link copied to clipboard
suspend fun releaseObjectGroup(objectGroup: String)
suspend fun releaseObjectGroup(args: Runtime.ReleaseObjectGroupParameter, mode: CommandMode = CommandMode.DEFAULT)

Releases all remote objects that belong to a given group.

Link copied to clipboard
suspend fun removeBinding(name: String)
suspend fun removeBinding(args: Runtime.RemoveBindingParameter, mode: CommandMode = CommandMode.DEFAULT)

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

Link copied to clipboard
suspend fun runIfWaitingForDebugger(mode: CommandMode = CommandMode.DEFAULT)

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

Link copied to clipboard
suspend fun runScript(args: Runtime.RunScriptParameter, mode: CommandMode = CommandMode.DEFAULT): Runtime.RunScriptReturn
suspend fun runScript(scriptId: String, executionContextId: Int? = null, objectGroup: String? = null, silent: Boolean? = null, includeCommandLineAPI: Boolean? = null, returnByValue: Boolean? = null, generatePreview: Boolean? = null, awaitPromise: Boolean? = null): Runtime.RunScriptReturn

Runs script with given id in a given context.

Link copied to clipboard
suspend fun setAsyncCallStackDepth(maxDepth: Int)
suspend fun setAsyncCallStackDepth(args: Runtime.SetAsyncCallStackDepthParameter, mode: CommandMode = CommandMode.DEFAULT)

Enables or disables async call stacks tracking.

Link copied to clipboard
Link copied to clipboard
suspend fun terminateExecution(mode: CommandMode = CommandMode.DEFAULT)

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