Tungsten v0.1.0 Tungsten.CDP.Debugger View Source

Debugger

Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.

Link to this section Summary

Functions

Link to this section Types

Link to this type

cdp_break_location_type() View Source
cdp_break_location_type() :: %{
  :script_id => Tungsten.CDP.Runtime.cdp_script_id_type(),
  :line_number => integer(),
  optional(:column_number) => integer(),
  optional(:type) => :return | :call | :debugger_statement
}

Debugger.BreakLocation

This type has no documentation

Link to this type

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

Debugger.BreakpointId

Breakpoint identifier.

Link to this type

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

Debugger.CallFrameId

Call frame identifier.

Link to this type

cdp_call_frame_type() View Source
cdp_call_frame_type() :: %{
  :call_frame_id => cdp_call_frame_id_type(),
  :function_name => String.t(),
  optional(:function_location) => cdp_location_type(),
  :location => cdp_location_type(),
  :url => String.t(),
  :scope_chain => [cdp_scope_type()],
  :this => Tungsten.CDP.Runtime.cdp_remote_object_type(),
  optional(:return_value) => Tungsten.CDP.Runtime.cdp_remote_object_type()
}

Debugger.CallFrame

JavaScript call frame. Array of call frames form the call stack.

Link to this type

cdp_location_type() View Source
cdp_location_type() :: %{
  :script_id => Tungsten.CDP.Runtime.cdp_script_id_type(),
  :line_number => integer(),
  optional(:column_number) => integer()
}

Debugger.Location

Location in the source code.

Link to this type

cdp_scope_type() View Source
cdp_scope_type() :: %{
  :type =>
    :module
    | :eval
    | :script
    | :block
    | :catch
    | :closure
    | :with
    | :local
    | :global,
  :object => Tungsten.CDP.Runtime.cdp_remote_object_type(),
  optional(:name) => String.t(),
  optional(:start_location) => cdp_location_type(),
  optional(:end_location) => cdp_location_type()
}

Debugger.Scope

Scope description.

Link to this type

cdp_script_position_type() View Source
cdp_script_position_type() :: %{
  line_number: integer(),
  column_number: integer()
}

Debugger.ScriptPosition

Location in the source code.

Link to this type

cdp_search_match_type() View Source
cdp_search_match_type() :: %{
  line_number: integer() | float(),
  line_content: String.t()
}

Debugger.SearchMatch

Search match for resource.

Link to this section Functions

Link to this function

continue_to_location(session, parameters, options \\ []) View Source
continue_to_location(
  GenServer.server(),
  %{
    :location => cdp_location_type(),
    optional(:target_call_frames) => :current | :any
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Debugger.continueToLocation

Continues execution until specific location is reached.

Link to this function

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

Debugger.disable

Disables debugger for given page.

Link to this function

enable(session, parameters \\ %{}, options \\ []) View Source
enable(
  GenServer.server(),
  %{optional(:max_scripts_cache_size) => integer() | float()},
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{debugger_id: Tungsten.CDP.Runtime.cdp_unique_debugger_id_type()}}
  | {:error, term()}

Debugger.enable

Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.

Link to this function

evaluate_on_call_frame(session, parameters, options \\ []) View Source
evaluate_on_call_frame(
  GenServer.server(),
  %{
    :call_frame_id => cdp_call_frame_id_type(),
    :expression => String.t(),
    optional(:object_group) => String.t(),
    optional(:include_command_line_api) => boolean(),
    optional(:silent) => boolean(),
    optional(:return_by_value) => boolean(),
    optional(:generate_preview) => boolean(),
    optional(:throw_on_side_effect) => boolean(),
    optional(:timeout) => Tungsten.CDP.Runtime.cdp_time_delta_type()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :result => Tungsten.CDP.Runtime.cdp_remote_object_type(),
     optional(:exception_details) =>
       Tungsten.CDP.Runtime.cdp_exception_details_type()
   }}
  | {:error, term()}

Debugger.evaluateOnCallFrame

Evaluates expression on a given call frame.

Link to this function

get_possible_breakpoints(session, parameters, options \\ []) View Source
get_possible_breakpoints(
  GenServer.server(),
  %{
    :start => cdp_location_type(),
    optional(:end) => cdp_location_type(),
    optional(:restrict_to_function) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{locations: [cdp_break_location_type()]}} | {:error, term()}

Debugger.getPossibleBreakpoints

Returns possible locations for breakpoint. scriptId in start and end range locations should be the same.

Link to this function

get_script_source(session, parameters, options \\ []) View Source
get_script_source(
  GenServer.server(),
  %{script_id: Tungsten.CDP.Runtime.cdp_script_id_type()},
  Tungsten.Connection.exec_options()
) :: {:ok, %{script_source: String.t()}} | {:error, term()}

Debugger.getScriptSource

Returns source for the script with given id.

Link to this function

get_stack_trace(session, parameters, options \\ []) View Source
get_stack_trace(
  GenServer.server(),
  %{stack_trace_id: Tungsten.CDP.Runtime.cdp_stack_trace_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok, %{stack_trace: Tungsten.CDP.Runtime.cdp_stack_trace_type()}}
  | {:error, term()}

Debugger.getStackTrace

Returns stack trace with given stackTraceId.

Link to this function

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

Debugger.pause

Stops on the next JavaScript statement.

Link to this function

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

Debugger.pauseOnAsyncCall

This command has no documentation

Link to this function

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

Debugger.removeBreakpoint

Removes JavaScript breakpoint.

Link to this function

restart_frame(session, parameters, options \\ []) View Source
restart_frame(
  GenServer.server(),
  %{call_frame_id: cdp_call_frame_id_type()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     :call_frames => [cdp_call_frame_type()],
     optional(:async_stack_trace) =>
       Tungsten.CDP.Runtime.cdp_stack_trace_type(),
     optional(:async_stack_trace_id) =>
       Tungsten.CDP.Runtime.cdp_stack_trace_id_type()
   }}
  | {:error, term()}

Debugger.restartFrame

Restarts particular call frame from the beginning.

Link to this function

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

Debugger.resume

Resumes JavaScript execution.

Link to this function

search_in_content(session, parameters, options \\ []) View Source
search_in_content(
  GenServer.server(),
  %{
    :script_id => Tungsten.CDP.Runtime.cdp_script_id_type(),
    :query => String.t(),
    optional(:case_sensitive) => boolean(),
    optional(:is_regex) => boolean()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{result: [cdp_search_match_type()]}} | {:error, term()}

Debugger.searchInContent

Searches for given string in script content.

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()}

Debugger.setAsyncCallStackDepth

Enables or disables async call stacks tracking.

Link to this function

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

Debugger.setBlackboxPatterns

Replace previous blackbox patterns with passed ones. Forces backend to skip stepping/pausing in scripts with url matching one of the patterns. VM will try to leave blackboxed script by performing 'step in' several times, finally resorting to 'step out' if unsuccessful.

Link to this function

set_blackboxed_ranges(session, parameters, options \\ []) View Source
set_blackboxed_ranges(
  GenServer.server(),
  %{
    script_id: Tungsten.CDP.Runtime.cdp_script_id_type(),
    positions: [cdp_script_position_type()]
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Debugger.setBlackboxedRanges

Makes backend skip steps in the script in blackboxed ranges. VM will try leave blacklisted scripts by performing 'step in' several times, finally resorting to 'step out' if unsuccessful. Positions array contains positions where blackbox state is changed. First interval isn't blackboxed. Array should be sorted.

Link to this function

set_breakpoint(session, parameters, options \\ []) View Source
set_breakpoint(
  GenServer.server(),
  %{:location => cdp_location_type(), optional(:condition) => String.t()},
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     breakpoint_id: cdp_breakpoint_id_type(),
     actual_location: cdp_location_type()
   }}
  | {:error, term()}

Debugger.setBreakpoint

Sets JavaScript breakpoint at a given location.

Link to this function

set_breakpoint_by_url(session, parameters, options \\ []) View Source
set_breakpoint_by_url(
  GenServer.server(),
  %{
    :line_number => integer(),
    optional(:url) => String.t(),
    optional(:url_regex) => String.t(),
    optional(:script_hash) => String.t(),
    optional(:column_number) => integer(),
    optional(:condition) => String.t()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{breakpoint_id: cdp_breakpoint_id_type(), locations: [cdp_location_type()]}}
  | {:error, term()}

Debugger.setBreakpointByUrl

Sets JavaScript breakpoint at given location specified either by URL or URL regex. Once this command is issued, all existing parsed scripts will have breakpoints resolved and returned in locations property. Further matching script parsing will result in subsequent breakpointResolved events issued. This logical breakpoint will survive page reloads.

Link to this function

set_breakpoint_on_function_call(session, parameters, options \\ []) View Source
set_breakpoint_on_function_call(
  GenServer.server(),
  %{
    :object_id => Tungsten.CDP.Runtime.cdp_remote_object_id_type(),
    optional(:condition) => String.t()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, %{breakpoint_id: cdp_breakpoint_id_type()}} | {:error, term()}

Debugger.setBreakpointOnFunctionCall

Sets JavaScript breakpoint before each call to the given function. If another function was created from the same source as a given one, calling it will also trigger the breakpoint.

Link to this function

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

Debugger.setBreakpointsActive

Activates / deactivates all breakpoints on the page.

Link to this function

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

Debugger.setPauseOnExceptions

Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. Initial pause on exceptions state is none.

Link to this function

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

Debugger.setReturnValue

Changes return value in top frame. Available only at return break position.

Link to this function

set_script_source(session, parameters, options \\ []) View Source
set_script_source(
  GenServer.server(),
  %{
    :script_id => Tungsten.CDP.Runtime.cdp_script_id_type(),
    :script_source => String.t(),
    optional(:dry_run) => boolean()
  },
  Tungsten.Connection.exec_options()
) ::
  {:ok,
   %{
     optional(:call_frames) => [cdp_call_frame_type()],
     optional(:stack_changed) => boolean(),
     optional(:async_stack_trace) =>
       Tungsten.CDP.Runtime.cdp_stack_trace_type(),
     optional(:async_stack_trace_id) =>
       Tungsten.CDP.Runtime.cdp_stack_trace_id_type(),
     optional(:exception_details) =>
       Tungsten.CDP.Runtime.cdp_exception_details_type()
   }}
  | {:error, term()}

Debugger.setScriptSource

Edits JavaScript source live.

Link to this function

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

Debugger.setSkipAllPauses

Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc).

Link to this function

set_variable_value(session, parameters, options \\ []) View Source
set_variable_value(
  GenServer.server(),
  %{
    scope_number: integer(),
    variable_name: String.t(),
    new_value: Tungsten.CDP.Runtime.cdp_call_argument_type(),
    call_frame_id: cdp_call_frame_id_type()
  },
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Debugger.setVariableValue

Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually.

Link to this function

step_into(session, parameters \\ %{}, options \\ []) View Source
step_into(
  GenServer.server(),
  %{optional(:break_on_async_call) => boolean()},
  Tungsten.Connection.exec_options()
) :: {:ok, map()} | {:error, term()}

Debugger.stepInto

Steps into the function call.

Link to this function

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

Debugger.stepOut

Steps out of the function call.

Link to this function

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

Debugger.stepOver

Steps over the statement.