Tungsten v0.1.0 Tungsten.CDP.Runtime View Source

Runtime

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.

Link to this section Summary

Functions

Link to this section Types

Link to this type

cdp_call_argument_type() View Source
cdp_call_argument_type() :: %{
  optional(:value) => any(),
  optional(:unserializable_value) => cdp_unserializable_value_type(),
  optional(:object_id) => cdp_remote_object_id_type()
}

Runtime.CallArgument

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

cdp_call_frame_type() View Source
cdp_call_frame_type() :: %{
  function_name: String.t(),
  script_id: cdp_script_id_type(),
  url: String.t(),
  line_number: integer(),
  column_number: integer()
}

Runtime.CallFrame

Stack entry for runtime errors and assertions.

Link to this type

cdp_custom_preview_type() View Source
cdp_custom_preview_type() :: %{
  :header => String.t(),
  optional(:body_getter_id) => cdp_remote_object_id_type()
}

Runtime.CustomPreview

This type has no documentation

Link to this type

cdp_entry_preview_type() View Source
cdp_entry_preview_type() :: %{
  optional(:key) => cdp_object_preview_type(),
  :value => cdp_object_preview_type()
}

Runtime.EntryPreview

This type has no documentation

Link to this type

cdp_exception_details_type() View Source
cdp_exception_details_type() :: %{
  :exception_id => integer(),
  :text => String.t(),
  :line_number => integer(),
  :column_number => integer(),
  optional(:script_id) => cdp_script_id_type(),
  optional(:url) => String.t(),
  optional(:stack_trace) => cdp_stack_trace_type(),
  optional(:exception) => cdp_remote_object_type(),
  optional(:execution_context_id) => cdp_execution_context_id_type()
}

Runtime.ExceptionDetails

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

Link to this type

cdp_execution_context_description_type() View Source
cdp_execution_context_description_type() :: %{
  :id => cdp_execution_context_id_type(),
  :origin => String.t(),
  :name => String.t(),
  optional(:aux_data) => map()
}

Runtime.ExecutionContextDescription

Description of an isolated world.

Link to this type

cdp_execution_context_id_type() View Source
cdp_execution_context_id_type() :: integer()

Runtime.ExecutionContextId

Id of an execution context.

Link to this type

cdp_internal_property_descriptor_type() View Source
cdp_internal_property_descriptor_type() :: %{
  :name => String.t(),
  optional(:value) => cdp_remote_object_type()
}

Runtime.InternalPropertyDescriptor

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

Link to this type

cdp_object_preview_type() View Source
cdp_object_preview_type() :: %{
  :type =>
    :bigint
    | :symbol
    | :boolean
    | :number
    | :string
    | :undefined
    | :function
    | :object,
  optional(:subtype) =>
    :error
    | :generator
    | :iterator
    | :weakset
    | :weakmap
    | :set
    | :map
    | :date
    | :regexp
    | :node
    | :null
    | :array,
  optional(:description) => String.t(),
  :overflow => boolean(),
  :properties => [cdp_property_preview_type()],
  optional(:entries) => [cdp_entry_preview_type()]
}

Runtime.ObjectPreview

Object containing abbreviated remote object value.

Link to this type

cdp_private_property_descriptor_type() View Source
cdp_private_property_descriptor_type() :: %{
  name: String.t(),
  value: cdp_remote_object_type()
}

Runtime.PrivatePropertyDescriptor

Object private field descriptor.

Link to this type

cdp_property_descriptor_type() View Source
cdp_property_descriptor_type() :: %{
  :name => String.t(),
  optional(:value) => cdp_remote_object_type(),
  optional(:writable) => boolean(),
  optional(:get) => cdp_remote_object_type(),
  optional(:set) => cdp_remote_object_type(),
  :configurable => boolean(),
  :enumerable => boolean(),
  optional(:was_thrown) => boolean(),
  optional(:is_own) => boolean(),
  optional(:symbol) => cdp_remote_object_type()
}

Runtime.PropertyDescriptor

Object property descriptor.

Link to this type

cdp_property_preview_type() View Source
cdp_property_preview_type() :: %{
  :name => String.t(),
  :type =>
    :bigint
    | :accessor
    | :symbol
    | :boolean
    | :number
    | :string
    | :undefined
    | :function
    | :object,
  optional(:value) => String.t(),
  optional(:value_preview) => cdp_object_preview_type(),
  optional(:subtype) =>
    :error
    | :generator
    | :iterator
    | :weakset
    | :weakmap
    | :set
    | :map
    | :date
    | :regexp
    | :node
    | :null
    | :array
}

Runtime.PropertyPreview

This type has no documentation

Link to this type

cdp_remote_object_id_type() View Source
cdp_remote_object_id_type() :: String.t()

Runtime.RemoteObjectId

Unique object identifier.

Link to this type

cdp_remote_object_type() View Source
cdp_remote_object_type() :: %{
  :type =>
    :bigint
    | :symbol
    | :boolean
    | :number
    | :string
    | :undefined
    | :function
    | :object,
  optional(:subtype) =>
    :dataview
    | :arraybuffer
    | :typedarray
    | :promise
    | :proxy
    | :error
    | :generator
    | :iterator
    | :weakset
    | :weakmap
    | :set
    | :map
    | :date
    | :regexp
    | :node
    | :null
    | :array,
  optional(:class_name) => String.t(),
  optional(:value) => any(),
  optional(:unserializable_value) => cdp_unserializable_value_type(),
  optional(:description) => String.t(),
  optional(:object_id) => cdp_remote_object_id_type(),
  optional(:preview) => cdp_object_preview_type(),
  optional(:custom_preview) => cdp_custom_preview_type()
}

Runtime.RemoteObject

Mirror object referencing original JavaScript object.

Link to this type

cdp_script_id_type() View Source
cdp_script_id_type() :: String.t()

Runtime.ScriptId

Unique script identifier.

Link to this type

cdp_stack_trace_id_type() View Source
cdp_stack_trace_id_type() :: %{
  :id => String.t(),
  optional(:debugger_id) => cdp_unique_debugger_id_type()
}

Runtime.StackTraceId

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

cdp_stack_trace_type() View Source
cdp_stack_trace_type() :: %{
  optional(:description) => String.t(),
  :call_frames => [cdp_call_frame_type()],
  optional(:parent) => cdp_stack_trace_type(),
  optional(:parent_id) => cdp_stack_trace_id_type()
}

Runtime.StackTrace

Call frames for assertions or error messages.

Link to this type

cdp_time_delta_type() View Source
cdp_time_delta_type() :: integer() | float()

Runtime.TimeDelta

Number of milliseconds.

Link to this type

cdp_timestamp_type() View Source
cdp_timestamp_type() :: integer() | float()

Runtime.Timestamp

Number of milliseconds since epoch.

Link to this type

cdp_unique_debugger_id_type() View Source
cdp_unique_debugger_id_type() :: String.t()

Runtime.UniqueDebuggerId

Unique identifier of current debugger.

Link to this type

cdp_unserializable_value_type() View Source
cdp_unserializable_value_type() :: String.t()

Runtime.UnserializableValue

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

Link to this section Functions

Link to this function

add_binding(session, parameters, options \\ []) View Source
add_binding(
  GenServer.server(),
  %{
    :name => String.t(),
    optional(:execution_context_id) => cdp_execution_context_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.addBinding

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. If executionContextId is specified, adds binding only on global object of given execution context. 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 to this function

await_promise(session, parameters, options \\ []) View Source
await_promise(
  GenServer.server(),
  %{
    :promise_object_id => cdp_remote_object_id_type(),
    optional(:return_by_value) => boolean(),
    optional(:generate_preview) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => cdp_remote_object_type(),
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.awaitPromise

Add handler to promise with given promise object id.

Link to this function

call_function_on(session, parameters, options \\ []) View Source
call_function_on(
  GenServer.server(),
  %{
    :function_declaration => String.t(),
    optional(:object_id) => cdp_remote_object_id_type(),
    optional(:arguments) => [cdp_call_argument_type()],
    optional(:silent) => boolean(),
    optional(:return_by_value) => boolean(),
    optional(:generate_preview) => boolean(),
    optional(:user_gesture) => boolean(),
    optional(:await_promise) => boolean(),
    optional(:execution_context_id) => cdp_execution_context_id_type(),
    optional(:object_group) => String.t()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => cdp_remote_object_type(),
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.callFunctionOn

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

Link to this function

compile_script(session, parameters, options \\ []) View Source
compile_script(
  GenServer.server(),
  %{
    :expression => String.t(),
    :source_url => String.t(),
    :persist_script => boolean(),
    optional(:execution_context_id) => cdp_execution_context_id_type()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     optional(:script_id) => cdp_script_id_type(),
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.compileScript

Compiles expression.

Link to this function

disable(session, parameters \\ %{}, options \\ []) View Source
disable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Runtime.disable

Disables reporting of execution contexts creation.

Link to this function

discard_console_entries(session, parameters \\ %{}, options \\ []) View Source
discard_console_entries(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.discardConsoleEntries

Discards collected exceptions and console API calls.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, map()} | {:error, term()}

Runtime.enable

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(session, parameters, options \\ []) View Source
evaluate(
  GenServer.server(),
  %{
    :expression => String.t(),
    optional(:object_group) => String.t(),
    optional(:include_command_line_api) => boolean(),
    optional(:silent) => boolean(),
    optional(:context_id) => cdp_execution_context_id_type(),
    optional(:return_by_value) => boolean(),
    optional(:generate_preview) => boolean(),
    optional(:user_gesture) => boolean(),
    optional(:await_promise) => boolean(),
    optional(:throw_on_side_effect) => boolean(),
    optional(:timeout) => cdp_time_delta_type()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => cdp_remote_object_type(),
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.evaluate

Evaluates expression on global object.

Link to this function

get_heap_usage(session, parameters \\ %{}, options \\ []) View Source
get_heap_usage(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, %{used_size: integer() | float(), total_size: integer() | float()}}
  | {:error, term()}

Runtime.getHeapUsage

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(session, parameters \\ %{}, options \\ []) View Source
get_isolate_id(GenServer.server(), map(), Tungsten.Connection.exec_options()) ::
  {:ok, %{id: String.t()}} | {:error, term()}

Runtime.getIsolateId

Returns the isolate id.

Link to this function

get_properties(session, parameters, options \\ []) View Source
get_properties(
  GenServer.server(),
  %{
    :object_id => cdp_remote_object_id_type(),
    optional(:own_properties) => boolean(),
    optional(:accessor_properties_only) => boolean(),
    optional(:generate_preview) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => [cdp_property_descriptor_type()],
     optional(:internal_properties) => [cdp_internal_property_descriptor_type()],
     optional(:private_properties) => [cdp_private_property_descriptor_type()],
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.getProperties

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

Link to this function

global_lexical_scope_names(session, parameters \\ %{}, options \\ []) View Source
global_lexical_scope_names(
  GenServer.server(),
  %{optional(:execution_context_id) => cdp_execution_context_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{names: [String.t()]}} | {:error, term()}

Runtime.globalLexicalScopeNames

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

Link to this function

query_objects(session, parameters, options \\ []) View Source
query_objects(
  GenServer.server(),
  %{
    :prototype_object_id => cdp_remote_object_id_type(),
    optional(:object_group) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{objects: cdp_remote_object_type()}} | {:error, term()}

Runtime.queryObjects

This command has no documentation

Link to this function

release_object(session, parameters, options \\ []) View Source
release_object(
  GenServer.server(),
  %{object_id: cdp_remote_object_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.releaseObject

Releases remote object with given id.

Link to this function

release_object_group(session, parameters, options \\ []) View Source
release_object_group(
  GenServer.server(),
  %{object_group: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.releaseObjectGroup

Releases all remote objects that belong to a given group.

Link to this function

remove_binding(session, parameters, options \\ []) View Source
remove_binding(
  GenServer.server(),
  %{name: String.t()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.removeBinding

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

Link to this function

run_if_waiting_for_debugger(session, parameters \\ %{}, options \\ []) View Source
run_if_waiting_for_debugger(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.runIfWaitingForDebugger

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

Link to this function

run_script(session, parameters, options \\ []) View Source
run_script(
  GenServer.server(),
  %{
    :script_id => cdp_script_id_type(),
    optional(:execution_context_id) => cdp_execution_context_id_type(),
    optional(:object_group) => String.t(),
    optional(:silent) => boolean(),
    optional(:include_command_line_api) => boolean(),
    optional(:return_by_value) => boolean(),
    optional(:generate_preview) => boolean(),
    optional(:await_promise) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => cdp_remote_object_type(),
     optional(:exception_details) => cdp_exception_details_type()
   }}
  | {:error, term()}

Runtime.runScript

Runs script with given id in a given context.

Link to this function

set_async_call_stack_depth(session, parameters, options \\ []) View Source
set_async_call_stack_depth(
  GenServer.server(),
  %{max_depth: integer()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.setAsyncCallStackDepth

Enables or disables async call stacks tracking.

Link to this function

set_custom_object_formatter_enabled(session, parameters, options \\ []) View Source
set_custom_object_formatter_enabled(
  GenServer.server(),
  %{enabled: boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.setCustomObjectFormatterEnabled

This command has no documentation

Link to this function

set_max_call_stack_size_to_capture(session, parameters, options \\ []) View Source
set_max_call_stack_size_to_capture(
  GenServer.server(),
  %{size: integer()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.setMaxCallStackSizeToCapture

This command has no documentation

Link to this function

terminate_execution(session, parameters \\ %{}, options \\ []) View Source
terminate_execution(
  GenServer.server(),
  map(),
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Runtime.terminateExecution

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