callFunctionOn method

Future<CallFunctionOnResult> callFunctionOn(
  1. String functionDeclaration, {
  2. RemoteObjectId? objectId,
  3. List<CallArgument>? arguments,
  4. bool? silent,
  5. bool? returnByValue,
  6. bool? generatePreview,
  7. bool? userGesture,
  8. bool? awaitPromise,
  9. ExecutionContextId? executionContextId,
  10. String? objectGroup,
  11. bool? throwOnSideEffect,
  12. String? uniqueContextId,
  13. SerializationOptions? serializationOptions,
})

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.

Implementation

Future<CallFunctionOnResult> 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}) async {
  var result = await _client.send('Runtime.callFunctionOn', {
    'functionDeclaration': functionDeclaration,
    if (objectId != null) 'objectId': objectId,
    if (arguments != null) 'arguments': [...arguments],
    if (silent != null) 'silent': silent,
    if (returnByValue != null) 'returnByValue': returnByValue,
    if (generatePreview != null) 'generatePreview': generatePreview,
    if (userGesture != null) 'userGesture': userGesture,
    if (awaitPromise != null) 'awaitPromise': awaitPromise,
    if (executionContextId != null) 'executionContextId': executionContextId,
    if (objectGroup != null) 'objectGroup': objectGroup,
    if (throwOnSideEffect != null) 'throwOnSideEffect': throwOnSideEffect,
    if (uniqueContextId != null) 'uniqueContextId': uniqueContextId,
    if (serializationOptions != null)
      'serializationOptions': serializationOptions,
  });
  return CallFunctionOnResult.fromJson(result);
}