RuntimeDomain

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.

Official doc

Functions

Link copied to clipboard
inline suspend fun addBinding(name: String, optionalArgs: AddBindingRequest.Builder.() -> Unit = {}): AddBindingResponse

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
inline suspend fun awaitPromise(promiseObjectId: RemoteObjectId, optionalArgs: AwaitPromiseRequest.Builder.() -> Unit = {}): AwaitPromiseResponse

Add handler to promise with given promise object id.

Link copied to clipboard
Link copied to clipboard

Notification is issued every time when binding is called.

Link copied to clipboard
inline suspend fun callFunctionOn(functionDeclaration: String, optionalArgs: CallFunctionOnRequest.Builder.() -> Unit = {}): CallFunctionOnResponse

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

Link copied to clipboard
inline suspend fun compileScript(expression: String, sourceURL: String, persistScript: Boolean, optionalArgs: CompileScriptRequest.Builder.() -> Unit = {}): CompileScriptResponse

Compiles expression.

Link copied to clipboard
Link copied to clipboard

Issued when console API was called.

Link copied to clipboard
suspend fun disable(): DisableResponse

Disables reporting of execution contexts creation.

Link copied to clipboard

Discards collected exceptions and console API calls.

Link copied to clipboard
suspend fun enable(): EnableResponse

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
inline suspend fun evaluate(expression: String, optionalArgs: EvaluateRequest.Builder.() -> Unit = {}): EvaluateResponse

Evaluates expression on global object.

Link copied to clipboard
inline suspend fun <T> RuntimeDomain.evaluateJs(js: String): T?

Evaluates the given js expression, and returns the result as a value of type T.

suspend fun <T> RuntimeDomain.evaluateJs(js: String, deserializer: DeserializationStrategy<T>): T?

Evaluates the given js expression, and returns the result as a value of type T using the provided deserializer.

Link copied to clipboard
fun events(): Flow<RuntimeEvent>

Subscribes to all events related to this domain.

Link copied to clipboard
Link copied to clipboard

Issued when unhandled exception was revoked.

Link copied to clipboard
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

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

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

Link copied to clipboard

Returns the isolate id.

Link copied to clipboard
inline suspend fun getProperties(objectId: RemoteObjectId, optionalArgs: GetPropertiesRequest.Builder.() -> Unit = {}): GetPropertiesResponse

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

Link copied to clipboard

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

Link copied to clipboard
Link copied to clipboard

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

Link copied to clipboard
inline suspend fun queryObjects(prototypeObjectId: RemoteObjectId, optionalArgs: QueryObjectsRequest.Builder.() -> Unit = {}): QueryObjectsResponse

(undocumented in the protocol definition)

Link copied to clipboard

Releases remote object with given id.

Link copied to clipboard

Releases all remote objects that belong to a given group.

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard
inline suspend fun runScript(scriptId: ScriptId, optionalArgs: RunScriptRequest.Builder.() -> Unit = {}): RunScriptResponse

Runs script with given id in a given context.

Link copied to clipboard

Enables or disables async call stacks tracking.

Link copied to clipboard

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