RuntimeApi class

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

RuntimeApi(Client _client)

Properties

hashCode int
The hash code for this object.
no setterinherited
onBindingCalled Stream<BindingCalledEvent>
Notification is issued every time when binding is called.
no setter
onConsoleAPICalled Stream<ConsoleAPICalledEvent>
Issued when console API was called.
no setter
onExceptionRevoked Stream<ExceptionRevokedEvent>
Issued when unhandled exception was revoked.
no setter
onExceptionThrown Stream<ExceptionThrownEvent>
Issued when exception was thrown and unhandled.
no setter
onExecutionContextCreated Stream<ExecutionContextDescription>
Issued when new execution context is created.
no setter
onExecutionContextDestroyed Stream<ExecutionContextDestroyedEvent>
Issued when execution context is destroyed.
no setter
onExecutionContextsCleared Stream<void>
Issued when all executionContexts were cleared in browser
no setter
onInspectRequested Stream<InspectRequestedEvent>
Issued when object should be inspected (for example, as a result of inspect() command line API call).
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBinding(String name, {ExecutionContextId? executionContextId, String? executionContextName}) Future<void>
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. executionContextName 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.
awaitPromise(RemoteObjectId promiseObjectId, {bool? returnByValue, bool? generatePreview}) Future<AwaitPromiseResult>
Add handler to promise with given promise object id. promiseObjectId Identifier of the promise. returnByValue Whether the result is expected to be a JSON object that should be sent by value. generatePreview Whether preview should be generated for the result.
callFunctionOn(String functionDeclaration, {RemoteObjectId? objectId, List<CallArgument>? arguments, bool? silent, bool? returnByValue, bool? generatePreview, bool? userGesture, bool? awaitPromise, ExecutionContextId? executionContextId, String? objectGroup, bool? throwOnSideEffect, String? uniqueContextId, SerializationOptions? serializationOptions}) Future<CallFunctionOnResult>
Calls function with given declaration on the given object. Object group of the result is inherited from the target object. functionDeclaration Declaration of the function to call. objectId Identifier of the object to call function on. Either objectId or executionContextId should be specified. arguments Call arguments. All call arguments must belong to the same JavaScript world as the target object. silent In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. returnByValue Whether the result is expected to be a JSON object which should be sent by value. Can be overriden by serializationOptions. generatePreview Whether preview should be generated for the result. userGesture Whether execution should be treated as initiated by user in the UI. awaitPromise Whether execution should await for resulting value and return once awaited promise is resolved. executionContextId Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified. objectGroup 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 Whether to throw an exception if side effect cannot be ruled out during evaluation. uniqueContextId 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 Specifies the result serialization. If provided, overrides generatePreview and returnByValue.
compileScript(String expression, String sourceURL, bool persistScript, {ExecutionContextId? executionContextId}) Future<CompileScriptResult>
Compiles expression. expression Expression to compile. sourceURL Source url to be set for the script. persistScript Specifies whether the compiled script should be persisted. 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.
disable() Future<void>
Disables reporting of execution contexts creation.
discardConsoleEntries() Future<void>
Discards collected exceptions and console API calls.
enable() Future<void>
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.
evaluate(String expression, {String? objectGroup, bool? includeCommandLineAPI, bool? silent, ExecutionContextId? contextId, bool? returnByValue, bool? generatePreview, bool? userGesture, bool? awaitPromise, bool? throwOnSideEffect, TimeDelta? timeout, bool? disableBreaks, bool? replMode, bool? allowUnsafeEvalBlockedByCSP, String? uniqueContextId, SerializationOptions? serializationOptions}) Future<EvaluateResult>
Evaluates expression on global object. expression Expression to evaluate. objectGroup Symbolic group name that can be used to release multiple objects. includeCommandLineAPI Determines whether Command Line API should be available during the evaluation. silent In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. contextId 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 Whether the result is expected to be a JSON object that should be sent by value. generatePreview Whether preview should be generated for the result. userGesture Whether execution should be treated as initiated by user in the UI. awaitPromise Whether execution should await for resulting value and return once awaited promise is resolved. throwOnSideEffect Whether to throw an exception if side effect cannot be ruled out during evaluation. This implies disableBreaks below. timeout Terminate execution after timing out (number of milliseconds). disableBreaks Disable breakpoints during execution. replMode 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 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 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 Specifies the result serialization. If provided, overrides generatePreview and returnByValue.
getExceptionDetails(RemoteObjectId errorObjectId) Future<ExceptionDetails>
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. errorObjectId The error object for which to resolve the exception details.
getHeapUsage() Future<GetHeapUsageResult>
Returns the JavaScript heap usage. It is the total usage of the corresponding isolate not scoped to a particular Runtime.
getIsolateId() Future<String>
Returns the isolate id. Returns: The isolate id.
getProperties(RemoteObjectId objectId, {bool? ownProperties, bool? accessorPropertiesOnly, bool? generatePreview, bool? nonIndexedPropertiesOnly}) Future<GetPropertiesResult>
Returns properties of a given object. Object group of the result is inherited from the target object. objectId Identifier of the object to return properties for. ownProperties If true, returns properties belonging only to the element itself, not to its prototype chain. accessorPropertiesOnly If true, returns accessor properties (with getter/setter) only; internal properties are not returned either. generatePreview Whether preview should be generated for the results. nonIndexedPropertiesOnly If true, returns non-indexed properties only.
globalLexicalScopeNames({ExecutionContextId? executionContextId}) Future<List<String>>
Returns all let, const and class variables from global scope. executionContextId Specifies in which execution context to lookup global scope variables.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
queryObjects(RemoteObjectId prototypeObjectId, {String? objectGroup}) Future<RemoteObject>
prototypeObjectId Identifier of the prototype to return objects for. objectGroup Symbolic group name that can be used to release the results. Returns: Array with objects.
releaseObject(RemoteObjectId objectId) Future<void>
Releases remote object with given id. objectId Identifier of the object to release.
releaseObjectGroup(String objectGroup) Future<void>
Releases all remote objects that belong to a given group. objectGroup Symbolic object group name.
removeBinding(String name) Future<void>
This method does not remove binding function from global object but unsubscribes current runtime agent from Runtime.bindingCalled notifications.
runIfWaitingForDebugger() Future<void>
Tells inspected instance to run if it was waiting for debugger to attach.
runScript(ScriptId scriptId, {ExecutionContextId? executionContextId, String? objectGroup, bool? silent, bool? includeCommandLineAPI, bool? returnByValue, bool? generatePreview, bool? awaitPromise}) Future<RunScriptResult>
Runs script with given id in a given context. scriptId Id of the script to run. 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 Symbolic group name that can be used to release multiple objects. silent In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state. includeCommandLineAPI Determines whether Command Line API should be available during the evaluation. returnByValue Whether the result is expected to be a JSON object which should be sent by value. generatePreview Whether preview should be generated for the result. awaitPromise Whether execution should await for resulting value and return once awaited promise is resolved.
setAsyncCallStackDepth(int maxDepth) Future<void>
Enables or disables async call stacks tracking. maxDepth Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default).
setCustomObjectFormatterEnabled(bool enabled) Future<void>
setMaxCallStackSizeToCapture(int size) Future<void>
terminateExecution() Future<void>
Terminate current or next JavaScript execution. Will cancel the termination when the outer-most script execution ends.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited