CDPotion.Domain.Runtime (cdpotion v0.1.4)

Summary

Types

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

Stack entry for runtime errors and assertions.

description not provided :(

Represents deep serialized value.

description not provided :(

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

Description of an isolated world.

Id of an execution context.

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

Object containing abbreviated remote object value.

Object private field descriptor.

Object property descriptor.

description not provided :(

Mirror object referencing original JavaScript object.

Unique object identifier.

Unique script identifier.

Represents options for serialization. Overrides generatePreview, returnByValue and generateWebDriverValue.

Call frames for assertions or error messages.

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.

Number of milliseconds.

Number of milliseconds since epoch.

Unique identifier of current debugger.

Primitive value which cannot be JSON-stringified. Includes values -0, NaN, Infinity, -Infinity, and bigint literals.

Functions

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.

Add handler to promise with given promise object id.

Disables reporting of execution contexts creation.

Discards collected exceptions and console API calls.

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.

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.

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

Returns the isolate id.

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

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

Parameters:

  • (Required) prototype_object_id: Identifier of the prototype to return objects for.
  • (Optional) object_group: Symbolic group name that can be used to release the results.

Releases remote object with given id.

Releases all remote objects that belong to a given group.

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

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

Enables or disables async call stacks tracking.

Parameters:

  • (Required) enabled: description not provided :(

Parameters:

  • (Required) size: description not provided :(

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

Types

Link to this type

call_argument()

@type call_argument() :: %{
  objectId: remote_object_id() | nil,
  unserializableValue: unserializable_value() | nil,
  value: any() | nil
}

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

Link to this type

call_frame()

@type call_frame() :: %{
  columnNumber: integer(),
  functionName: String.t(),
  lineNumber: integer(),
  scriptId: script_id(),
  url: String.t()
}

Stack entry for runtime errors and assertions.

Link to this type

custom_preview()

@type custom_preview() :: %{
  bodyGetterId: remote_object_id() | nil,
  header: String.t()
}

description not provided :(

Link to this type

deep_serialized_value()

@type deep_serialized_value() :: %{
  objectId: String.t() | nil,
  type:
    :undefined
    | :null
    | :string
    | :number
    | :boolean
    | :bigint
    | :regexp
    | :date
    | :symbol
    | :array
    | :object
    | :function
    | :map
    | :set
    | :weakmap
    | :weakset
    | :error
    | :proxy
    | :promise
    | :typedarray
    | :arraybuffer
    | :node
    | :window,
  value: any() | nil,
  weakLocalObjectReference: integer() | nil
}

Represents deep serialized value.

Link to this type

entry_preview()

@type entry_preview() :: %{key: object_preview() | nil, value: object_preview()}

description not provided :(

Link to this type

exception_details()

@type exception_details() :: %{
  columnNumber: integer(),
  exception: remote_object() | nil,
  exceptionId: integer(),
  exceptionMetaData: map() | nil,
  executionContextId: execution_context_id() | nil,
  lineNumber: integer(),
  scriptId: script_id() | nil,
  stackTrace: stack_trace() | nil,
  text: String.t(),
  url: String.t() | nil
}

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

Link to this type

execution_context_description()

@type execution_context_description() :: %{
  auxData: map() | nil,
  id: execution_context_id(),
  name: String.t(),
  origin: String.t(),
  uniqueId: String.t()
}

Description of an isolated world.

Link to this type

execution_context_id()

@type execution_context_id() :: integer()

Id of an execution context.

Link to this type

internal_property_descriptor()

@type internal_property_descriptor() :: %{
  name: String.t(),
  value: remote_object() | nil
}

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

Link to this type

object_preview()

@type object_preview() :: %{
  description: String.t() | nil,
  entries: [entry_preview()] | nil,
  overflow: boolean(),
  properties: [property_preview()],
  subtype:
    :array
    | :null
    | :node
    | :regexp
    | :date
    | :map
    | :set
    | :weakmap
    | :weakset
    | :iterator
    | :generator
    | :error
    | :proxy
    | :promise
    | :typedarray
    | :arraybuffer
    | :dataview
    | :webassemblymemory
    | :wasmvalue
    | nil,
  type:
    :object
    | :function
    | :undefined
    | :string
    | :number
    | :boolean
    | :symbol
    | :bigint
}

Object containing abbreviated remote object value.

Link to this type

private_property_descriptor()

@type private_property_descriptor() :: %{
  get: remote_object() | nil,
  name: String.t(),
  set: remote_object() | nil,
  value: remote_object() | nil
}

Object private field descriptor.

Link to this type

property_descriptor()

@type property_descriptor() :: %{
  configurable: boolean(),
  enumerable: boolean(),
  get: remote_object() | nil,
  isOwn: boolean() | nil,
  name: String.t(),
  set: remote_object() | nil,
  symbol: remote_object() | nil,
  value: remote_object() | nil,
  wasThrown: boolean() | nil,
  writable: boolean() | nil
}

Object property descriptor.

Link to this type

property_preview()

@type property_preview() :: %{
  name: String.t(),
  subtype:
    :array
    | :null
    | :node
    | :regexp
    | :date
    | :map
    | :set
    | :weakmap
    | :weakset
    | :iterator
    | :generator
    | :error
    | :proxy
    | :promise
    | :typedarray
    | :arraybuffer
    | :dataview
    | :webassemblymemory
    | :wasmvalue
    | nil,
  type:
    :object
    | :function
    | :undefined
    | :string
    | :number
    | :boolean
    | :symbol
    | :accessor
    | :bigint,
  value: String.t() | nil,
  valuePreview: object_preview() | nil
}

description not provided :(

Link to this type

remote_object()

@type remote_object() :: %{
  className: String.t() | nil,
  customPreview: custom_preview() | nil,
  deepSerializedValue: deep_serialized_value() | nil,
  description: String.t() | nil,
  objectId: remote_object_id() | nil,
  preview: object_preview() | nil,
  subtype:
    :array
    | :null
    | :node
    | :regexp
    | :date
    | :map
    | :set
    | :weakmap
    | :weakset
    | :iterator
    | :generator
    | :error
    | :proxy
    | :promise
    | :typedarray
    | :arraybuffer
    | :dataview
    | :webassemblymemory
    | :wasmvalue
    | nil,
  type:
    :object
    | :function
    | :undefined
    | :string
    | :number
    | :boolean
    | :symbol
    | :bigint,
  unserializableValue: unserializable_value() | nil,
  value: any() | nil,
  webDriverValue: deep_serialized_value() | nil
}

Mirror object referencing original JavaScript object.

Link to this type

remote_object_id()

@type remote_object_id() :: String.t()

Unique object identifier.

@type script_id() :: String.t()

Unique script identifier.

Link to this type

serialization_options()

@type serialization_options() :: %{
  additionalParameters: map() | nil,
  maxDepth: integer() | nil,
  serialization: :deep | :json | :idOnly
}

Represents options for serialization. Overrides generatePreview, returnByValue and generateWebDriverValue.

Link to this type

stack_trace()

@type stack_trace() :: %{
  callFrames: [call_frame()],
  description: String.t() | nil,
  parent: stack_trace() | nil,
  parentId: stack_trace_id() | nil
}

Call frames for assertions or error messages.

Link to this type

stack_trace_id()

@type stack_trace_id() :: %{debuggerId: unique_debugger_id() | nil, id: String.t()}

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.

Link to this type

time_delta()

@type time_delta() :: number()

Number of milliseconds.

@type timestamp() :: number()

Number of milliseconds since epoch.

Link to this type

unique_debugger_id()

@type unique_debugger_id() :: String.t()

Unique identifier of current debugger.

Link to this type

unserializable_value()

@type unserializable_value() :: String.t()

Primitive value which cannot be JSON-stringified. Includes values -0, NaN, Infinity, -Infinity, and bigint literals.

Functions

Link to this function

add_binding(name, execution_context_id \\ nil, execution_context_name \\ nil)

@spec add_binding(String.t(), execution_context_id(), String.t()) ::
  {String.t(), map()}

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.

Parameters:

  • (Required) name: description not provided :(
  • (Optional) execution_context_id: 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.
  • (Optional) execution_context_name: 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.
Link to this function

await_promise(promise_object_id, return_by_value \\ nil, generate_preview \\ nil)

@spec await_promise(remote_object_id(), boolean(), boolean()) :: {String.t(), map()}

Add handler to promise with given promise object id.

Parameters:

  • (Required) promise_object_id: Identifier of the promise.
  • (Optional) return_by_value: Whether the result is expected to be a JSON object that should be sent by value.
  • (Optional) generate_preview: Whether preview should be generated for the result.
Link to this function

call_function_on(function_declaration, object_id \\ nil, arguments \\ nil, silent \\ nil, return_by_value \\ nil, generate_preview \\ nil, user_gesture \\ nil, await_promise \\ nil, execution_context_id \\ nil, object_group \\ nil, throw_on_side_effect \\ nil, unique_context_id \\ nil, generate_web_driver_value \\ nil, serialization_options \\ nil)

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

Parameters:

  • (Required) function_declaration: Declaration of the function to call.
  • (Optional) object_id: Identifier of the object to call function on. Either objectId or executionContextId should be specified.
  • (Optional) arguments: Call arguments. All call arguments must belong to the same JavaScript world as the target object.
  • (Optional) silent: In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  • (Optional) return_by_value: Whether the result is expected to be a JSON object which should be sent by value. Can be overriden by serializationOptions.
  • (Optional) generate_preview: Whether preview should be generated for the result.
  • (Optional) user_gesture: Whether execution should be treated as initiated by user in the UI.
  • (Optional) await_promise: Whether execution should await for resulting value and return once awaited promise is resolved.
  • (Optional) execution_context_id: Specifies execution context which global object will be used to call function on. Either executionContextId or objectId should be specified.
  • (Optional) object_group: 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.
  • (Optional) throw_on_side_effect: Whether to throw an exception if side effect cannot be ruled out during evaluation.
  • (Optional) unique_context_id: 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.
  • (Optional) generate_web_driver_value: Deprecated. Use serializationOptions: {serialization:"deep"} instead. Whether the result should contain webDriverValue, serialized according to https://w3c.github.io/webdriver-bidi. This is mutually exclusive with returnByValue, but resulting objectId is still provided.
  • (Optional) serialization_options: Specifies the result serialization. If provided, overrides generatePreview, returnByValue and generateWebDriverValue.
Link to this function

compile_script(expression, source_url, persist_script, execution_context_id \\ nil)

@spec compile_script(
  String.t(),
  String.t(),
  boolean(),
  execution_context_id()
) :: {String.t(), map()}

Compiles expression.

Parameters:

  • (Required) expression: Expression to compile.
  • (Required) source_url: Source url to be set for the script.
  • (Required) persist_script: Specifies whether the compiled script should be persisted.
  • (Optional) execution_context_id: 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.
@spec disable() :: {String.t(), map()}

Disables reporting of execution contexts creation.

Link to this function

discard_console_entries()

@spec discard_console_entries() :: {String.t(), map()}

Discards collected exceptions and console API calls.

@spec enable() :: {String.t(), map()}

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 to this function

evaluate(expression, object_group \\ nil, include_command_line_api \\ nil, silent \\ nil, context_id \\ nil, return_by_value \\ nil, generate_preview \\ nil, user_gesture \\ nil, await_promise \\ nil, throw_on_side_effect \\ nil, timeout \\ nil, disable_breaks \\ nil, repl_mode \\ nil, allow_unsafe_eval_blocked_by_csp \\ nil, unique_context_id \\ nil, generate_web_driver_value \\ nil, serialization_options \\ nil)

Evaluates expression on global object.

Parameters:

  • (Required) expression: Expression to evaluate.
  • (Optional) object_group: Symbolic group name that can be used to release multiple objects.
  • (Optional) include_command_line_api: Determines whether Command Line API should be available during the evaluation.
  • (Optional) silent: In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  • (Optional) context_id: 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.
  • (Optional) return_by_value: Whether the result is expected to be a JSON object that should be sent by value.
  • (Optional) generate_preview: Whether preview should be generated for the result.
  • (Optional) user_gesture: Whether execution should be treated as initiated by user in the UI.
  • (Optional) await_promise: Whether execution should await for resulting value and return once awaited promise is resolved.
  • (Optional) throw_on_side_effect: Whether to throw an exception if side effect cannot be ruled out during evaluation. This implies disableBreaks below.
  • (Optional) timeout: Terminate execution after timing out (number of milliseconds).
  • (Optional) disable_breaks: Disable breakpoints during execution.
  • (Optional) repl_mode: 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.
  • (Optional) allow_unsafe_eval_blocked_by_csp: 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.
  • (Optional) unique_context_id: 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.
  • (Optional) generate_web_driver_value: Deprecated. Use serializationOptions: {serialization:"deep"} instead. Whether the result should contain webDriverValue, serialized according to https://w3c.github.io/webdriver-bidi. This is mutually exclusive with returnByValue, but resulting objectId is still provided.
  • (Optional) serialization_options: Specifies the result serialization. If provided, overrides generatePreview, returnByValue and generateWebDriverValue.
Link to this function

get_exception_details(error_object_id)

@spec get_exception_details(remote_object_id()) :: {String.t(), map()}

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.

Parameters:

  • (Required) error_object_id: The error object for which to resolve the exception details.
Link to this function

get_heap_usage()

@spec get_heap_usage() :: {String.t(), map()}

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

Link to this function

get_isolate_id()

@spec get_isolate_id() :: {String.t(), map()}

Returns the isolate id.

Link to this function

get_properties(object_id, own_properties \\ nil, accessor_properties_only \\ nil, generate_preview \\ nil, non_indexed_properties_only \\ nil)

@spec get_properties(
  remote_object_id(),
  boolean(),
  boolean(),
  boolean(),
  boolean()
) :: {String.t(), map()}

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

Parameters:

  • (Required) object_id: Identifier of the object to return properties for.
  • (Optional) own_properties: If true, returns properties belonging only to the element itself, not to its prototype chain.
  • (Optional) accessor_properties_only: If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.
  • (Optional) generate_preview: Whether preview should be generated for the results.
  • (Optional) non_indexed_properties_only: If true, returns non-indexed properties only.
Link to this function

global_lexical_scope_names(execution_context_id \\ nil)

@spec global_lexical_scope_names(execution_context_id()) :: {String.t(), map()}

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

Parameters:

  • (Optional) execution_context_id: Specifies in which execution context to lookup global scope variables.
Link to this function

query_objects(prototype_object_id, object_group \\ nil)

@spec query_objects(remote_object_id(), String.t()) :: {String.t(), map()}

Parameters:

  • (Required) prototype_object_id: Identifier of the prototype to return objects for.
  • (Optional) object_group: Symbolic group name that can be used to release the results.
Link to this function

release_object(object_id)

@spec release_object(remote_object_id()) :: {String.t(), map()}

Releases remote object with given id.

Parameters:

  • (Required) object_id: Identifier of the object to release.
Link to this function

release_object_group(object_group)

@spec release_object_group(String.t()) :: {String.t(), map()}

Releases all remote objects that belong to a given group.

Parameters:

  • (Required) object_group: Symbolic object group name.
Link to this function

remove_binding(name)

@spec remove_binding(String.t()) :: {String.t(), map()}

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

Parameters:

  • (Required) name: description not provided :(
Link to this function

run_if_waiting_for_debugger()

@spec run_if_waiting_for_debugger() :: {String.t(), map()}

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

Link to this function

run_script(script_id, execution_context_id \\ nil, object_group \\ nil, silent \\ nil, include_command_line_api \\ nil, return_by_value \\ nil, generate_preview \\ nil, await_promise \\ nil)

@spec run_script(
  script_id(),
  execution_context_id(),
  String.t(),
  boolean(),
  boolean(),
  boolean(),
  boolean(),
  boolean()
) :: {String.t(), map()}

Runs script with given id in a given context.

Parameters:

  • (Required) script_id: Id of the script to run.
  • (Optional) execution_context_id: 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.
  • (Optional) object_group: Symbolic group name that can be used to release multiple objects.
  • (Optional) silent: In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException state.
  • (Optional) include_command_line_api: Determines whether Command Line API should be available during the evaluation.
  • (Optional) return_by_value: Whether the result is expected to be a JSON object which should be sent by value.
  • (Optional) generate_preview: Whether preview should be generated for the result.
  • (Optional) await_promise: Whether execution should await for resulting value and return once awaited promise is resolved.
Link to this function

set_async_call_stack_depth(max_depth)

@spec set_async_call_stack_depth(integer()) :: {String.t(), map()}

Enables or disables async call stacks tracking.

Parameters:

  • (Required) max_depth: Maximum depth of async call stacks. Setting to 0 will effectively disable collecting async call stacks (default).
Link to this function

set_custom_object_formatter_enabled(enabled)

@spec set_custom_object_formatter_enabled(boolean()) :: {String.t(), map()}

Parameters:

  • (Required) enabled: description not provided :(
Link to this function

set_max_call_stack_size_to_capture(size)

@spec set_max_call_stack_size_to_capture(integer()) :: {String.t(), map()}

Parameters:

  • (Required) size: description not provided :(
Link to this function

terminate_execution()

@spec terminate_execution() :: {String.t(), map()}

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