├── .circleci
└── config.yml
├── .gitignore
├── CHANGELOG.md
├── README.md
├── config
└── config.exs
├── lib
├── chrome_remote_interface.ex
├── http.ex
├── mix
│ └── tasks
│ │ └── fetch_cdp_protocol.ex
├── page_session.ex
├── server.ex
├── session.ex
└── websocket.ex
├── mix.exs
├── mix.lock
├── priv
├── 1-2
│ └── protocol.json
├── 1-3
│ └── protocol.json
└── tot
│ └── protocol.json
└── test
├── page_session_test.exs
└── test_helper.exs
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Elixir CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-elixir/ for more details
4 | version: 2
5 | jobs:
6 | build:
7 | docker:
8 | - image: circleci/elixir:1.5
9 |
10 | working_directory: ~/repo
11 | steps:
12 | - checkout
13 | - run: mix local.rebar --force
14 | - run: mix local.hex --force
15 | - run: mix deps.get
16 | - run: mix test
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # The directory Mix will write compiled artifacts to.
2 | /_build/
3 |
4 | # If you run "mix test --cover", coverage assets end up here.
5 | /cover/
6 |
7 | # The directory Mix downloads your dependencies sources to.
8 | /deps/
9 |
10 | # Where 3rd-party dependencies like ExDoc output generated docs.
11 | /doc/
12 |
13 | # Ignore .fetch files in case you like to edit your project deps locally.
14 | /.fetch
15 |
16 | # If the VM crashes, it generates a dump, let's ignore it too.
17 | erl_crash.dump
18 |
19 | # Also ignore archive artifacts (built via "mix archive.build").
20 | *.ez
21 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # v0.4.1
2 |
3 | ### Enhancements
4 |
5 | * [Dependencies] Switch from `Poison` -> `Jason`.
6 | * [Internal] Adds a `mix fetch_cdp_protocol` which updates all protocol files.
7 | * [Protocol] Update `1-3` and `tot` protocols as of `2019-08-03`
8 |
9 | ### Bug Fixes
10 |
11 | * [README] Fix `list_page` -> `list_pages` in README.md (#23)
12 |
13 | ### Deprecations
14 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Chrome Remote Interface
2 |
3 | [](https://circleci.com/gh/andrewvy/chrome-remote-interface)
4 |
5 | This library provides an Elixir Client to the [Chrome Debugging Protocol](https://chromedevtools.github.io/devtools-protocol/) with
6 | a small layer of abstraction for handling and subscribing to domain events.
7 |
8 | Note: This is a super minimal client wrapper around the Chrome Debugging Protocol.
9 |
10 | ## Installation
11 |
12 | Add `:chrome_remote_interface` to your `mix.exs` file!
13 |
14 | ```elixir
15 | def deps do
16 | [
17 | {:chrome_remote_interface, "~> 0.4.1"}
18 | ]
19 | end
20 | ```
21 |
22 | ### Chrome DevTools Protocol Selection
23 |
24 | Chrome Remote Interface generated its API at compile time from the protocol
25 | definition released by the Chrome DevTools Team.
26 | For more info see: [https://chromedevtools.github.io/devtools-protocol/](https://chromedevtools.github.io/devtools-protocol/)
27 |
28 | This can be overridden by setting `CRI_PROTOCOL_VERSION` environment variable
29 | to:
30 | * 1-2
31 | * 1-3 * default
32 | * tot
33 |
34 | Example:
35 | ```
36 | CRI_PROTOCOL_VERSION=1-2 mix compile
37 | CRI_PROTOCOL_VERSION=1-3 mix compile
38 | CRI_PROTOCOL_VERSION=tot mix compile
39 | ```
40 |
41 | ## Usage
42 |
43 | > Note: In these examples, it assumes you're already running chrome headless with remote debugging enabled.
44 |
45 | ```bash
46 | chrome --headless --disable-gpu --remote-debugging-port=9222
47 | ```
48 |
49 | > Basic API
50 |
51 | ```elixir
52 | # ChromeRemoteInterface works off by creating a Session to the remote debugging port.
53 | # By default, connects to 'localhost:9222
54 | iex(1)> server = ChromeRemoteInterface.Session.new()
55 | %ChromeRemoteInterface.Server{host: "localhost", port: 9222}
56 |
57 | iex(2)> {:ok, pages} = ChromeRemoteInterface.Session.list_pages(server)
58 | {:ok,
59 | [%{"description" => "",
60 | "devtoolsFrontendUrl" => "/devtools/inspector.html?ws=localhost:9222/devtools/page/d4357ff1-47e8-4e53-8289-fc54089da33e",
61 | "id" => "d4357ff1-47e8-4e53-8289-fc54089da33e", "title" => "Google",
62 | "type" => "page", "url" => "https://www.google.com/?gws_rd=ssl",
63 | "webSocketDebuggerUrl" => "ws://localhost:9222/devtools/page/d4357ff1-47e8-4e53-8289-fc54089da33e"}]}
64 |
65 | # Now that we have a list of pages, we can connect to any page by using their 'webSocketDebuggerUrl'
66 | iex(3)> first_page = pages |> List.first()
67 | iex(4)> {:ok, page_pid} = ChromeRemoteInterface.PageSession.start_link(first_page)
68 |
69 | # Any methods from https://chromedevtools.github.io/devtools-protocol/1-2/ should be available
70 | # to execute on that Page.
71 |
72 | # 'Page.navigate'
73 | iex(5)> ChromeRemoteInterface.RPC.Page.navigate(page_pid, %{url: "https://google.com"})
74 | %{"id" => 1, "result" => %{"frameId" => "95446.1"}}
75 |
76 | # 'Page.printToPDF'
77 | iex(6)> ChromeRemoteInterface.RPC.Page.printToPDF(page_pid, %{})
78 | {:ok, %{"id" => 2, "result" => %{"data" => "JVBERi0xLj..."}}}
79 | ```
80 |
--------------------------------------------------------------------------------
/config/config.exs:
--------------------------------------------------------------------------------
1 | use Mix.Config
2 |
--------------------------------------------------------------------------------
/lib/chrome_remote_interface.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface do
2 | @moduledoc """
3 | Documentation for ChromeRemoteInterface.
4 | """
5 |
6 | alias ChromeRemoteInterface.PageSession
7 |
8 | @protocol_env_key "CRI_PROTOCOL_VERSION"
9 | @protocol_versions ["1-2", "1-3", "tot"]
10 | @protocol_version (if (vsn = System.get_env(@protocol_env_key)) in @protocol_versions do
11 | vsn
12 | else
13 | "1-3"
14 | end)
15 | IO.puts(
16 | "Compiling ChromeRemoteInterface with Chrome DevTools Protocol version: '#{@protocol_version}'"
17 | )
18 |
19 | @doc """
20 | Gets the current version of the Chrome Debugger Protocol
21 | """
22 | def protocol_version() do
23 | @protocol_version
24 | end
25 |
26 | protocol =
27 | File.read!("priv/#{@protocol_version}/protocol.json")
28 | |> Jason.decode!()
29 |
30 | # Generate ChromeRemoteInterface.RPC Modules
31 |
32 | Enum.each(protocol["domains"], fn domain ->
33 | defmodule Module.concat(ChromeRemoteInterface.RPC, domain["domain"]) do
34 | @domain domain
35 | @moduledoc domain["description"]
36 |
37 | def experimental?(), do: @domain["experimental"]
38 |
39 | for command <- @domain["commands"] do
40 | name = command["name"]
41 | description = command["description"]
42 |
43 | arg_doc =
44 | command["parameters"]
45 | |> List.wrap()
46 | |> Enum.map(fn param ->
47 | "#{param["name"]} - <#{param["$ref"] || param["type"]}> - #{param["description"]}"
48 | end)
49 |
50 | @doc """
51 | #{description}
52 |
53 | Parameters:
54 | #{arg_doc}
55 | """
56 | def unquote(:"#{name}")(page_pid) do
57 | page_pid
58 | |> PageSession.execute_command(
59 | unquote("#{domain["domain"]}.#{name}"),
60 | %{},
61 | []
62 | )
63 | end
64 |
65 | def unquote(:"#{name}")(page_pid, parameters) do
66 | page_pid
67 | |> PageSession.execute_command(
68 | unquote("#{domain["domain"]}.#{name}"),
69 | parameters,
70 | []
71 | )
72 | end
73 |
74 | def unquote(:"#{name}")(page_pid, parameters, opts) when is_list(opts) do
75 | page_pid
76 | |> PageSession.execute_command(
77 | unquote("#{domain["domain"]}.#{name}"),
78 | parameters,
79 | opts
80 | )
81 | end
82 | end
83 | end
84 | end)
85 | end
86 |
--------------------------------------------------------------------------------
/lib/http.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.HTTP do
2 | @moduledoc """
3 | This module handles communicating with the DevTools HTTP JSON API.
4 | """
5 |
6 | @type success_http_response :: {:ok, Map.t()}
7 | @type error_http_response :: {:error, any()}
8 |
9 | @spec call(ChromeRemoteInterface.Server.t(), String.t()) ::
10 | success_http_response | error_http_response
11 | def call(server, path) do
12 | server
13 | |> execute_request(path)
14 | |> handle_response()
15 | end
16 |
17 | # ---
18 | # Private
19 | # ---
20 |
21 | defp http_url(server, path) do
22 | "http://#{server.host}:#{server.port}#{path}"
23 | end
24 |
25 | defp execute_request(server, path) do
26 | :hackney.request(:get, http_url(server, path), [], <<>>, path_encode_fun: & &1)
27 | end
28 |
29 | defp handle_response({:ok, status_code, _response_headers, client_ref}) do
30 | with true <- status_code >= 200 && status_code < 300,
31 | {:ok, body} <- :hackney.body(client_ref),
32 | {:ok, formatted_body} <- format_body(body),
33 | {:ok, json} <- decode(formatted_body) do
34 | {:ok, json}
35 | else
36 | error -> error
37 | end
38 | end
39 |
40 | defp handle_response({:error, {:closed, _}}) do
41 | {:error, :unexpected_close}
42 | end
43 |
44 | defp handle_response({:error, reason}) do
45 | {:error, reason}
46 | end
47 |
48 | defp format_body(""), do: format_body("{}")
49 | defp format_body(body), do: {:ok, body}
50 |
51 | defp decode(body) do
52 | case Jason.decode(body) do
53 | {:ok, json} -> {:ok, json}
54 | {:error, _reason} -> {:ok, body}
55 | end
56 | end
57 | end
58 |
--------------------------------------------------------------------------------
/lib/mix/tasks/fetch_cdp_protocol.ex:
--------------------------------------------------------------------------------
1 | defmodule Mix.Tasks.FetchCdpProtocol do
2 | @moduledoc """
3 | Fetches up-to-date versions of all the Chrome Debugger Protocol files.
4 |
5 | These protocol files are stored in the private storage of this library.
6 | """
7 |
8 | use Mix.Task
9 |
10 | @shortdoc "Fetches up-to-date versions of all the Chrome Debugger Protocol files."
11 |
12 | @protocol_sources %{
13 | "1-2" => %{
14 | url:
15 | "https://raw.githubusercontent.com/ChromeDevTools/debugger-protocol-viewer/master/_data/1-2/protocol.json",
16 | output: "priv/1-2/protocol.json"
17 | },
18 | "1-3" => %{
19 | url:
20 | "https://raw.githubusercontent.com/ChromeDevTools/debugger-protocol-viewer/master/_data/1-3/protocol.json",
21 | output: "priv/1-3/protocol.json"
22 | },
23 | "tot" => %{
24 | url:
25 | "https://raw.githubusercontent.com/ChromeDevTools/debugger-protocol-viewer/master/_data/tot/protocol.json",
26 | output: "priv/tot/protocol.json"
27 | }
28 | }
29 |
30 | @temporary_file "protocol.json"
31 |
32 | @impl true
33 | def run(_) do
34 | Map.keys(@protocol_sources)
35 | |> Enum.each(&fetch_protocol/1)
36 | end
37 |
38 | def fetch_protocol(version) do
39 | protocol_source = Map.fetch!(@protocol_sources, version)
40 |
41 | cmd!("wget #{protocol_source.url}")
42 | File.rename(@temporary_file, protocol_source.output)
43 | end
44 |
45 | defp cmd!(cmd) do
46 | Mix.shell().info([:magenta, "Running: #{cmd}"])
47 |
48 | exit_status = Mix.shell().cmd(cmd)
49 |
50 | if exit_status != 0 do
51 | Mix.raise("Non-zero result (#{exit_status}) from command: #{cmd}")
52 | end
53 | end
54 | end
55 |
--------------------------------------------------------------------------------
/lib/page_session.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.PageSession do
2 | @moduledoc """
3 | This module is responsible for all things connected to a Page.
4 |
5 | - Spawning a process that manages the websocket connection
6 | - Handling request/response for RPC calls by maintaining unique message IDs
7 | - Forwarding Domain events to subscribers.
8 | """
9 |
10 | use GenServer
11 |
12 | defstruct url: "",
13 | socket: nil,
14 | callbacks: [],
15 | event_subscribers: %{},
16 | ref_id: 1
17 |
18 | # ---
19 | # Public API
20 | # ---
21 |
22 | @doc """
23 | Connect to a Page's 'webSocketDebuggerUrl'.
24 | """
25 | def start_link(%{"webSocketDebuggerUrl" => url}), do: start_link(url)
26 |
27 | def start_link(url) do
28 | GenServer.start_link(__MODULE__, url)
29 | end
30 |
31 | @doc """
32 | Stop the websocket connection to the page.
33 | """
34 | def stop(page_pid) do
35 | GenServer.stop(page_pid)
36 | end
37 |
38 | @doc """
39 | Subscribe to an event.
40 |
41 | Events that get fired will be returned to the subscribed process under the following format:
42 |
43 | ```
44 | {:chrome_remote_interface, event_name, response}
45 | ```
46 |
47 | Please note that you must also enable events for that domain!
48 |
49 | Example:
50 |
51 | ```
52 | iex> ChromeRemoteInterface.RPC.Page.enable(page_pid)
53 | iex> ChromeRemoteInterface.PageSession.subscribe(page_pid, "Page.loadEventFired")
54 | iex> ChromeRemoteInterface.RPC.Page.navigate(page_pid, %{url: "https://google.com"})
55 | iex> flush()
56 | {:chrome_remote_interface, "Page.loadEventFirst", %{"method" => "Page.loadEventFired",
57 | "params" => %{"timestamp" => 1012329.888558}}}
58 | ```
59 | """
60 | @spec subscribe(pid(), String.t(), pid()) :: any()
61 | def subscribe(pid, event, subscriber_pid \\ self()) do
62 | GenServer.call(pid, {:subscribe, event, subscriber_pid})
63 | end
64 |
65 | @doc """
66 | Unsubscribes from an event.
67 | """
68 | @spec unsubscribe(pid(), String.t(), pid()) :: any()
69 | def unsubscribe(pid, event, subscriber_pid \\ self()) do
70 | GenServer.call(pid, {:unsubscribe, event, subscriber_pid})
71 | end
72 |
73 | @doc """
74 | Unsubcribes to all events.
75 | """
76 | def unsubscribe_all(pid, subscriber_pid \\ self()) do
77 | GenServer.call(pid, {:unsubscribe_all, subscriber_pid})
78 | end
79 |
80 | @doc """
81 | Executes an RPC command with the given options.
82 |
83 | Options:
84 | `:async` -
85 | If a boolean, sends the response as a message to the current process.
86 | Else, if provided with a PID, it will send the response to that process instead.
87 |
88 | `:timeout` -
89 | This sets the timeout for the blocking call, defaults to 5 seconds.
90 | """
91 | def execute_command(pid, method, params, opts) do
92 | async = Keyword.get(opts, :async, false)
93 | timeout = Keyword.get(opts, :timeout, 5_000)
94 |
95 | case async do
96 | false -> call(pid, method, params, timeout)
97 | true -> cast(pid, method, params, self())
98 | from when is_pid(from) -> cast(pid, method, params, from)
99 | end
100 | end
101 |
102 | @doc """
103 | Executes a raw JSON RPC command through Websockets.
104 | """
105 | def call(pid, method, params, timeout) do
106 | GenServer.call(pid, {:call_command, method, params}, timeout)
107 | end
108 |
109 | @doc """
110 | Executes a raw JSON RPC command through Websockets, but sends the
111 | response as a message to the requesting process.
112 | """
113 | def cast(pid, method, params, from \\ self()) do
114 | GenServer.cast(pid, {:cast_command, method, params, from})
115 | end
116 |
117 | # ---
118 | # Callbacks
119 | # ---
120 |
121 | def init(url) do
122 | {:ok, socket} = ChromeRemoteInterface.Websocket.start_link(url)
123 |
124 | state = %__MODULE__{
125 | url: url,
126 | socket: socket
127 | }
128 |
129 | {:ok, state}
130 | end
131 |
132 | def handle_cast({:cast_command, method, params, from}, state) do
133 | send(self(), {:send_rpc_request, state.ref_id, state.socket, method, params})
134 |
135 | new_state =
136 | state
137 | |> add_callback({:cast, method, from})
138 | |> increment_ref_id()
139 |
140 | {:noreply, new_state}
141 | end
142 |
143 | def handle_call({:call_command, method, params}, from, state) do
144 | send(self(), {:send_rpc_request, state.ref_id, state.socket, method, params})
145 |
146 | new_state =
147 | state
148 | |> add_callback({:call, from})
149 | |> increment_ref_id()
150 |
151 | {:noreply, new_state}
152 | end
153 |
154 | # @todo(vy): Subscriber pids that die should be removed from being subscribed
155 | def handle_call({:subscribe, event, subscriber_pid}, _from, state) do
156 | new_event_subscribers =
157 | state
158 | |> Map.get(:event_subscribers, %{})
159 | |> Map.update(event, [subscriber_pid], fn subscriber_pids ->
160 | [subscriber_pid | subscriber_pids]
161 | end)
162 |
163 | new_state = %{state | event_subscribers: new_event_subscribers}
164 |
165 | {:reply, :ok, new_state}
166 | end
167 |
168 | def handle_call({:unsubscribe, event, subscriber_pid}, _from, state) do
169 | new_event_subscribers =
170 | state
171 | |> Map.get(:event_subscribers, %{})
172 | |> Map.update(event, [], fn subscriber_pids ->
173 | List.delete(subscriber_pids, subscriber_pid)
174 | end)
175 |
176 | new_state = %{state | event_subscribers: new_event_subscribers}
177 |
178 | {:reply, :ok, new_state}
179 | end
180 |
181 | def handle_call({:unsubscribe_all, subscriber_pid}, _from, state) do
182 | new_event_subscribers =
183 | state
184 | |> Map.get(:event_subscribers, %{})
185 | |> Enum.map(fn {key, subscriber_pids} ->
186 | {key, List.delete(subscriber_pids, subscriber_pid)}
187 | end)
188 | |> Enum.into(%{})
189 |
190 | new_state = %{state | event_subscribers: new_event_subscribers}
191 |
192 | {:reply, :ok, new_state}
193 | end
194 |
195 | # This handles websocket frames coming from the websocket connection.
196 | #
197 | # If a frame has an ID:
198 | # - That means it's for an RPC call, so we will reply to the caller with the response.
199 | #
200 | # If the frame is an event:
201 | # - Forward the event to any subscribers.
202 | def handle_info({:message, frame_data}, state) do
203 | json = Jason.decode!(frame_data)
204 | id = json["id"]
205 | method = json["method"]
206 |
207 | # Message is an RPC response
208 | callbacks =
209 | if id do
210 | send_rpc_response(state.callbacks, id, json)
211 | else
212 | state.callbacks
213 | end
214 |
215 | # Message is an Domain event
216 | if method do
217 | send_event(state.event_subscribers, method, json)
218 | end
219 |
220 | {:noreply, %{state | callbacks: callbacks}}
221 | end
222 |
223 | def handle_info({:send_rpc_request, ref_id, socket, method, params}, state) do
224 | message = %{
225 | "id" => ref_id,
226 | "method" => method,
227 | "params" => params
228 | }
229 |
230 | json = Jason.encode!(message)
231 | WebSockex.send_frame(socket, {:text, json})
232 | {:noreply, state}
233 | end
234 |
235 | defp add_callback(state, from) do
236 | state
237 | |> Map.update(:callbacks, [{state.ref_id, from}], fn callbacks ->
238 | [{state.ref_id, from} | callbacks]
239 | end)
240 | end
241 |
242 | defp remove_callback(callbacks, from) do
243 | callbacks
244 | |> Enum.reject(&(&1 == from))
245 | end
246 |
247 | defp increment_ref_id(state) do
248 | state
249 | |> Map.update(:ref_id, 1, &(&1 + 1))
250 | end
251 |
252 | defp send_rpc_response(callbacks, id, json) do
253 | error = json["error"]
254 |
255 | Enum.find(callbacks, fn {ref_id, _from} ->
256 | ref_id == id
257 | end)
258 | |> case do
259 | {_ref_id, {:cast, method, from}} = callback ->
260 | event = {:chrome_remote_interface, method, json}
261 | send(from, event)
262 | remove_callback(callbacks, callback)
263 |
264 | {_ref_id, {:call, from}} = callback ->
265 | status = if error, do: :error, else: :ok
266 | GenServer.reply(from, {status, json})
267 | remove_callback(callbacks, callback)
268 |
269 | _ ->
270 | callbacks
271 | end
272 | end
273 |
274 | defp send_event(event_subscribers, event_name, json) do
275 | event = {:chrome_remote_interface, event_name, json}
276 |
277 | pids_subscribed_to_event =
278 | event_subscribers
279 | |> Map.get(event_name, [])
280 |
281 | pids_subscribed_to_event
282 | |> Enum.each(&send(&1, event))
283 | end
284 |
285 | def terminate(_reason, state) do
286 | Process.exit(state.socket, :kill)
287 | :stop
288 | end
289 | end
290 |
--------------------------------------------------------------------------------
/lib/server.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.Server do
2 | defstruct [
3 | :host,
4 | :port
5 | ]
6 |
7 | @type t :: %__MODULE__{
8 | host: String.t(),
9 | port: non_neg_integer() | String.t()
10 | }
11 | end
12 |
--------------------------------------------------------------------------------
/lib/session.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.Session do
2 | @moduledoc """
3 | This module provides an API to the DevTools HTTP API.
4 | """
5 |
6 | alias ChromeRemoteInterface.{
7 | HTTP,
8 | Server
9 | }
10 |
11 | @default_opts [
12 | host: "localhost",
13 | port: 9222
14 | ]
15 |
16 | @doc """
17 | Create a new ChromeRemoteInterface.Server to perform HTTP requests to.
18 | """
19 | @spec new(keyword()) :: Server.t()
20 | def new(opts \\ []) do
21 | merged_opts = Keyword.merge(@default_opts, opts)
22 |
23 | %ChromeRemoteInterface.Server{
24 | host: Keyword.get(merged_opts, :host),
25 | port: Keyword.get(merged_opts, :port)
26 | }
27 | end
28 |
29 | @doc """
30 | List all Pages.
31 |
32 | Calls `/json/list`.
33 | """
34 | @spec list_pages(Server.t()) :: HTTP.success_http_response() | HTTP.error_http_response()
35 | def list_pages(server) do
36 | server
37 | |> HTTP.call("/json/list")
38 | end
39 |
40 | @doc """
41 | Creates a new Page.
42 |
43 | Calls `/json/new`.
44 | """
45 | @spec new_page(Server.t()) :: HTTP.success_http_response() | HTTP.error_http_response()
46 | def new_page(server) do
47 | server
48 | |> HTTP.call("/json/new")
49 | end
50 |
51 | @doc """
52 | documentation needed!
53 |
54 | Calls `/json/activate/:id`.
55 | """
56 | @spec activate_page(Server.t(), String.t()) ::
57 | HTTP.success_http_response() | HTTP.error_http_response()
58 | def activate_page(server, id) do
59 | server
60 | |> HTTP.call("/json/activate/#{id}")
61 | end
62 |
63 | @doc """
64 | Closes a Page.
65 |
66 | Calls `/json/close/:id`.
67 | """
68 | @spec close_page(Server.t(), String.t()) ::
69 | HTTP.success_http_response() | HTTP.error_http_response()
70 | def close_page(server, id) do
71 | server
72 | |> HTTP.call("/json/close/#{id}")
73 | end
74 |
75 | @doc """
76 | Gets the version of Chrome.
77 |
78 | Calls `/json/version`.
79 | """
80 | @spec version(Server.t()) :: HTTP.success_http_response() | HTTP.error_http_response()
81 | def version(server) do
82 | server
83 | |> HTTP.call("/json/version")
84 | end
85 | end
86 |
--------------------------------------------------------------------------------
/lib/websocket.ex:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.Websocket do
2 | require Logger
3 |
4 | use WebSockex
5 |
6 | def start_link(url) do
7 | WebSockex.start_link(url, __MODULE__, self())
8 | end
9 |
10 | def handle_frame({:text, frame_data}, state) do
11 | send(state, {:message, frame_data})
12 | {:ok, state}
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/mix.exs:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.Mixfile do
2 | use Mix.Project
3 |
4 | def project do
5 | [
6 | app: :chrome_remote_interface,
7 | version: "0.4.1",
8 | elixir: "~> 1.5",
9 | start_permanent: Mix.env() == :prod,
10 | deps: deps(),
11 | name: "Chrome Remote Interface",
12 | source_url: "https://github.com/andrewvy/chrome-remote-interface",
13 | description: description(),
14 | package: package()
15 | ]
16 | end
17 |
18 | # Run "mix help compile.app" to learn about applications.
19 | def application do
20 | [
21 | extra_applications: [:logger]
22 | ]
23 | end
24 |
25 | # Run "mix help deps" to learn about dependencies.
26 | defp deps do
27 | [
28 | {:jason, "~> 1.1"},
29 | {:hackney, "~> 1.8 or ~> 1.7 or ~> 1.6"},
30 | {:websockex, "~> 0.4.0"},
31 | {:ex_doc, "~> 0.19", only: :dev, runtime: false}
32 | ]
33 | end
34 |
35 | defp description do
36 | "Chrome Debugging Protocol client for Elixir"
37 | end
38 |
39 | defp package do
40 | [
41 | maintainers: ["andrew@andrewvy.com"],
42 | licenses: ["MIT"],
43 | links: %{
44 | "Github" => "https://github.com/andrewvy/chrome-remote-interface"
45 | }
46 | ]
47 | end
48 | end
49 |
--------------------------------------------------------------------------------
/mix.lock:
--------------------------------------------------------------------------------
1 | %{
2 | "certifi": {:hex, :certifi, "2.0.0", "a0c0e475107135f76b8c1d5bc7efb33cd3815cb3cf3dea7aefdd174dabead064", [:rebar3], []},
3 | "earmark": {:hex, :earmark, "1.3.2", "b840562ea3d67795ffbb5bd88940b1bed0ed9fa32834915125ea7d02e35888a5", [:mix], [], "hexpm"},
4 | "ex_doc": {:hex, :ex_doc, "0.20.2", "1bd0dfb0304bade58beb77f20f21ee3558cc3c753743ae0ddbb0fd7ba2912331", [:mix], [{:earmark, "~> 1.3", [hex: :earmark, repo: "hexpm", optional: false]}, {:makeup_elixir, "~> 0.10", [hex: :makeup_elixir, repo: "hexpm", optional: false]}], "hexpm"},
5 | "hackney": {:hex, :hackney, "1.9.0", "51c506afc0a365868469dcfc79a9d0b94d896ec741cfd5bd338f49a5ec515bfe", [:rebar3], [{:certifi, "2.0.0", [hex: :certifi, optional: false]}, {:idna, "5.1.0", [hex: :idna, optional: false]}, {:metrics, "1.0.1", [hex: :metrics, optional: false]}, {:mimerl, "1.0.2", [hex: :mimerl, optional: false]}, {:ssl_verify_fun, "1.1.1", [hex: :ssl_verify_fun, optional: false]}]},
6 | "httpipe": {:hex, :httpipe, "0.9.0", "4db66493b0ec2a86d142ea959a62e221d6ddb23ab48a676b691be3a16c38a415", [:mix], []},
7 | "httpipe_adapters_hackney": {:hex, :httpipe_adapters_hackney, "0.11.0", "35c31b96fd6fea117f9ba6ca70467ada111dffb9f2fa7fca0bfc7e12bb166e8e", [:mix], [{:hackney, "~> 1.8 or ~> 1.7 or ~> 1.6", [hex: :hackney, optional: false]}, {:httpipe, "~> 0.9.0", [hex: :httpipe, optional: false]}]},
8 | "idna": {:hex, :idna, "5.1.0", "d72b4effeb324ad5da3cab1767cb16b17939004e789d8c0ad5b70f3cea20c89a", [:rebar3], [{:unicode_util_compat, "0.3.1", [hex: :unicode_util_compat, optional: false]}]},
9 | "jason": {:hex, :jason, "1.1.2", "b03dedea67a99223a2eaf9f1264ce37154564de899fd3d8b9a21b1a6fd64afe7", [:mix], [{:decimal, "~> 1.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm"},
10 | "makeup": {:hex, :makeup, "0.8.0", "9cf32aea71c7fe0a4b2e9246c2c4978f9070257e5c9ce6d4a28ec450a839b55f", [:mix], [{:nimble_parsec, "~> 0.5.0", [hex: :nimble_parsec, repo: "hexpm", optional: false]}], "hexpm"},
11 | "makeup_elixir": {:hex, :makeup_elixir, "0.13.0", "be7a477997dcac2e48a9d695ec730b2d22418292675c75aa2d34ba0909dcdeda", [:mix], [{:makeup, "~> 0.8", [hex: :makeup, repo: "hexpm", optional: false]}], "hexpm"},
12 | "metrics": {:hex, :metrics, "1.0.1", "25f094dea2cda98213cecc3aeff09e940299d950904393b2a29d191c346a8486", [:rebar3], []},
13 | "mimerl": {:hex, :mimerl, "1.0.2", "993f9b0e084083405ed8252b99460c4f0563e41729ab42d9074fd5e52439be88", [:rebar3], []},
14 | "nimble_parsec": {:hex, :nimble_parsec, "0.5.0", "90e2eca3d0266e5c53f8fbe0079694740b9c91b6747f2b7e3c5d21966bba8300", [:mix], [], "hexpm"},
15 | "poison": {:hex, :poison, "3.1.0", "d9eb636610e096f86f25d9a46f35a9facac35609a7591b3be3326e99a0484665", [:mix], []},
16 | "ssl_verify_fun": {:hex, :ssl_verify_fun, "1.1.1", "28a4d65b7f59893bc2c7de786dec1e1555bd742d336043fe644ae956c3497fbe", [:make, :rebar], []},
17 | "unicode_util_compat": {:hex, :unicode_util_compat, "0.3.1", "a1f612a7b512638634a603c8f401892afbf99b8ce93a45041f8aaca99cadb85e", [:rebar3], []},
18 | "websockex": {:hex, :websockex, "0.4.0", "72096b1257baffc52c5f15c7366fb468e373b3c6173a6fee45311bfdb8ee1256", [:mix], []},
19 | }
20 |
--------------------------------------------------------------------------------
/priv/1-2/protocol.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": { "major": "1", "minor": "2" },
3 | "domains": [
4 | {
5 | "domain": "Page",
6 | "description": "Actions and events related to the inspected page belong to the page domain.",
7 | "dependencies": [
8 | "Debugger",
9 | "DOM"
10 | ],
11 | "types": [
12 | {
13 | "id": "ResourceType",
14 | "type": "string",
15 | "enum": [
16 | "Document",
17 | "Stylesheet",
18 | "Image",
19 | "Media",
20 | "Font",
21 | "Script",
22 | "TextTrack",
23 | "XHR",
24 | "Fetch",
25 | "EventSource",
26 | "WebSocket",
27 | "Manifest",
28 | "Other"
29 | ],
30 | "description": "Resource type as it was perceived by the rendering engine."
31 | },
32 | {
33 | "id": "FrameId",
34 | "type": "string",
35 | "description": "Unique frame identifier."
36 | },
37 | {
38 | "id": "Frame",
39 | "type": "object",
40 | "description": "Information about the Frame on the page.",
41 | "properties": [
42 | {
43 | "name": "id",
44 | "type": "string",
45 | "description": "Frame unique identifier."
46 | },
47 | {
48 | "name": "parentId",
49 | "type": "string",
50 | "optional": true,
51 | "description": "Parent frame identifier."
52 | },
53 | {
54 | "name": "loaderId",
55 | "$ref": "Network.LoaderId",
56 | "description": "Identifier of the loader associated with this frame."
57 | },
58 | {
59 | "name": "name",
60 | "type": "string",
61 | "optional": true,
62 | "description": "Frame's name as specified in the tag."
63 | },
64 | {
65 | "name": "url",
66 | "type": "string",
67 | "description": "Frame document's URL."
68 | },
69 | {
70 | "name": "securityOrigin",
71 | "type": "string",
72 | "description": "Frame document's security origin."
73 | },
74 | {
75 | "name": "mimeType",
76 | "type": "string",
77 | "description": "Frame document's mimeType as determined by the browser."
78 | }
79 | ]
80 | }
81 | ],
82 | "commands": [
83 | {
84 | "name": "enable",
85 | "description": "Enables page domain notifications.",
86 | "handlers": [
87 | "browser",
88 | "renderer"
89 | ]
90 | },
91 | {
92 | "name": "disable",
93 | "description": "Disables page domain notifications.",
94 | "handlers": [
95 | "browser",
96 | "renderer"
97 | ]
98 | },
99 | {
100 | "name": "reload",
101 | "parameters": [
102 | {
103 | "name": "ignoreCache",
104 | "type": "boolean",
105 | "optional": true,
106 | "description": "If true, browser cache is ignored (as if the user pressed Shift+refresh)."
107 | },
108 | {
109 | "name": "scriptToEvaluateOnLoad",
110 | "type": "string",
111 | "optional": true,
112 | "description": "If set, the script will be injected into all frames of the inspected page after reload."
113 | }
114 | ],
115 | "description": "Reloads given page optionally ignoring the cache.",
116 | "handlers": [
117 | "browser",
118 | "renderer"
119 | ]
120 | },
121 | {
122 | "name": "navigate",
123 | "parameters": [
124 | {
125 | "name": "url",
126 | "type": "string",
127 | "description": "URL to navigate the page to."
128 | }
129 | ],
130 | "returns": [
131 | {
132 | "name": "frameId",
133 | "$ref": "FrameId",
134 | "experimental": true,
135 | "description": "Frame id that will be navigated."
136 | }
137 | ],
138 | "description": "Navigates current page to the given URL.",
139 | "handlers": [
140 | "browser",
141 | "renderer"
142 | ]
143 | },
144 | {
145 | "name": "setGeolocationOverride",
146 | "description": "Overrides the Geolocation Position or Error. Omitting any of the parameters emulates position unavailable.",
147 | "parameters": [
148 | {
149 | "name": "latitude",
150 | "type": "number",
151 | "optional": true,
152 | "description": "Mock latitude"
153 | },
154 | {
155 | "name": "longitude",
156 | "type": "number",
157 | "optional": true,
158 | "description": "Mock longitude"
159 | },
160 | {
161 | "name": "accuracy",
162 | "type": "number",
163 | "optional": true,
164 | "description": "Mock accuracy"
165 | }
166 | ],
167 | "redirect": "Emulation",
168 | "handlers": [
169 | "browser"
170 | ]
171 | },
172 | {
173 | "name": "clearGeolocationOverride",
174 | "description": "Clears the overriden Geolocation Position and Error.",
175 | "redirect": "Emulation",
176 | "handlers": [
177 | "browser"
178 | ]
179 | },
180 | {
181 | "name": "handleJavaScriptDialog",
182 | "description": "Accepts or dismisses a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload).",
183 | "parameters": [
184 | {
185 | "name": "accept",
186 | "type": "boolean",
187 | "description": "Whether to accept or dismiss the dialog."
188 | },
189 | {
190 | "name": "promptText",
191 | "type": "string",
192 | "optional": true,
193 | "description": "The text to enter into the dialog prompt before accepting. Used only if this is a prompt dialog."
194 | }
195 | ],
196 | "handlers": [
197 | "browser"
198 | ]
199 | }
200 | ],
201 | "events": [
202 | {
203 | "name": "domContentEventFired",
204 | "parameters": [
205 | {
206 | "name": "timestamp",
207 | "type": "number"
208 | }
209 | ]
210 | },
211 | {
212 | "name": "loadEventFired",
213 | "parameters": [
214 | {
215 | "name": "timestamp",
216 | "type": "number"
217 | }
218 | ]
219 | },
220 | {
221 | "name": "frameAttached",
222 | "description": "Fired when frame has been attached to its parent.",
223 | "parameters": [
224 | {
225 | "name": "frameId",
226 | "$ref": "FrameId",
227 | "description": "Id of the frame that has been attached."
228 | },
229 | {
230 | "name": "parentFrameId",
231 | "$ref": "FrameId",
232 | "description": "Parent frame identifier."
233 | }
234 | ]
235 | },
236 | {
237 | "name": "frameNavigated",
238 | "description": "Fired once navigation of the frame has completed. Frame is now associated with the new loader.",
239 | "parameters": [
240 | {
241 | "name": "frame",
242 | "$ref": "Frame",
243 | "description": "Frame object."
244 | }
245 | ]
246 | },
247 | {
248 | "name": "frameDetached",
249 | "description": "Fired when frame has been detached from its parent.",
250 | "parameters": [
251 | {
252 | "name": "frameId",
253 | "$ref": "FrameId",
254 | "description": "Id of the frame that has been detached."
255 | }
256 | ]
257 | },
258 | {
259 | "name": "javascriptDialogOpening",
260 | "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) is about to open.",
261 | "parameters": [
262 | {
263 | "name": "message",
264 | "type": "string",
265 | "description": "Message that will be displayed by the dialog."
266 | },
267 | {
268 | "name": "type",
269 | "$ref": "DialogType",
270 | "description": "Dialog type."
271 | }
272 | ]
273 | },
274 | {
275 | "name": "javascriptDialogClosed",
276 | "description": "Fired when a JavaScript initiated dialog (alert, confirm, prompt, or onbeforeunload) has been closed.",
277 | "parameters": [
278 | {
279 | "name": "result",
280 | "type": "boolean",
281 | "description": "Whether dialog was confirmed."
282 | }
283 | ]
284 | },
285 | {
286 | "name": "interstitialShown",
287 | "description": "Fired when interstitial page was shown",
288 | "handlers": [
289 | "browser"
290 | ]
291 | },
292 | {
293 | "name": "interstitialHidden",
294 | "description": "Fired when interstitial page was hidden",
295 | "handlers": [
296 | "browser"
297 | ]
298 | },
299 | {
300 | "name": "navigationRequested",
301 | "description": "Fired when a navigation is started if navigation throttles are enabled. The navigation will be deferred until processNavigation is called.",
302 | "parameters": [
303 | {
304 | "name": "isInMainFrame",
305 | "type": "boolean",
306 | "description": "Whether the navigation is taking place in the main frame or in a subframe."
307 | },
308 | {
309 | "name": "isRedirect",
310 | "type": "boolean",
311 | "description": "Whether the navigation has encountered a server redirect or not."
312 | },
313 | {
314 | "name": "navigationId",
315 | "type": "integer"
316 | },
317 | {
318 | "name": "url",
319 | "type": "string",
320 | "description": "URL of requested navigation."
321 | }
322 | ],
323 | "handlers": [
324 | "browser"
325 | ]
326 | }
327 | ]
328 | },
329 | {
330 | "domain": "Emulation",
331 | "description": "This domain emulates different environments for the page.",
332 | "types": [
333 | {
334 | "id": "ScreenOrientation",
335 | "type": "object",
336 | "description": "Screen orientation.",
337 | "properties": [
338 | {
339 | "name": "type",
340 | "type": "string",
341 | "enum": [
342 | "portraitPrimary",
343 | "portraitSecondary",
344 | "landscapePrimary",
345 | "landscapeSecondary"
346 | ],
347 | "description": "Orientation type."
348 | },
349 | {
350 | "name": "angle",
351 | "type": "integer",
352 | "description": "Orientation angle."
353 | }
354 | ]
355 | }
356 | ],
357 | "commands": [
358 | {
359 | "name": "setDeviceMetricsOverride",
360 | "description": "Overrides the values of device screen dimensions (window.screen.width, window.screen.height, window.innerWidth, window.innerHeight, and \"device-width\"/\"device-height\"-related CSS media query results).",
361 | "parameters": [
362 | {
363 | "name": "width",
364 | "type": "integer",
365 | "description": "Overriding width value in pixels (minimum 0, maximum 10000000). 0 disables the override."
366 | },
367 | {
368 | "name": "height",
369 | "type": "integer",
370 | "description": "Overriding height value in pixels (minimum 0, maximum 10000000). 0 disables the override."
371 | },
372 | {
373 | "name": "deviceScaleFactor",
374 | "type": "number",
375 | "description": "Overriding device scale factor value. 0 disables the override."
376 | },
377 | {
378 | "name": "mobile",
379 | "type": "boolean",
380 | "description": "Whether to emulate mobile device. This includes viewport meta tag, overlay scrollbars, text autosizing and more."
381 | },
382 | {
383 | "name": "fitWindow",
384 | "type": "boolean",
385 | "description": "Whether a view that exceeds the available browser window area should be scaled down to fit."
386 | },
387 | {
388 | "name": "scale",
389 | "type": "number",
390 | "optional": true,
391 | "experimental": true,
392 | "description": "Scale to apply to resulting view image. Ignored in |fitWindow| mode."
393 | },
394 | {
395 | "name": "offsetX",
396 | "type": "number",
397 | "optional": true,
398 | "deprecated": true,
399 | "experimental": true,
400 | "description": "Not used."
401 | },
402 | {
403 | "name": "offsetY",
404 | "type": "number",
405 | "optional": true,
406 | "deprecated": true,
407 | "experimental": true,
408 | "description": "Not used."
409 | },
410 | {
411 | "name": "screenWidth",
412 | "type": "integer",
413 | "optional": true,
414 | "experimental": true,
415 | "description": "Overriding screen width value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|."
416 | },
417 | {
418 | "name": "screenHeight",
419 | "type": "integer",
420 | "optional": true,
421 | "experimental": true,
422 | "description": "Overriding screen height value in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|."
423 | },
424 | {
425 | "name": "positionX",
426 | "type": "integer",
427 | "optional": true,
428 | "experimental": true,
429 | "description": "Overriding view X position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|."
430 | },
431 | {
432 | "name": "positionY",
433 | "type": "integer",
434 | "optional": true,
435 | "experimental": true,
436 | "description": "Overriding view Y position on screen in pixels (minimum 0, maximum 10000000). Only used for |mobile==true|."
437 | },
438 | {
439 | "name": "screenOrientation",
440 | "$ref": "ScreenOrientation",
441 | "optional": true,
442 | "description": "Screen orientation override."
443 | }
444 | ],
445 | "handlers": [
446 | "browser"
447 | ]
448 | },
449 | {
450 | "name": "clearDeviceMetricsOverride",
451 | "description": "Clears the overriden device metrics.",
452 | "handlers": [
453 | "browser"
454 | ]
455 | },
456 | {
457 | "name": "setTouchEmulationEnabled",
458 | "parameters": [
459 | {
460 | "name": "enabled",
461 | "type": "boolean",
462 | "description": "Whether the touch event emulation should be enabled."
463 | },
464 | {
465 | "name": "configuration",
466 | "type": "string",
467 | "enum": [
468 | "mobile",
469 | "desktop"
470 | ],
471 | "optional": true,
472 | "description": "Touch/gesture events configuration. Default: current platform."
473 | }
474 | ],
475 | "description": "Toggles mouse event-based touch event emulation.",
476 | "handlers": [
477 | "browser",
478 | "renderer"
479 | ]
480 | },
481 | {
482 | "name": "setEmulatedMedia",
483 | "parameters": [
484 | {
485 | "name": "media",
486 | "type": "string",
487 | "description": "Media type to emulate. Empty string disables the override."
488 | }
489 | ],
490 | "description": "Emulates the given media for CSS media queries."
491 | }
492 | ],
493 | "events": []
494 | },
495 | {
496 | "domain": "Network",
497 | "description": "Network domain allows tracking network activities of the page. It exposes information about http, file, data and other requests and responses, their headers, bodies, timing, etc.",
498 | "dependencies": [
499 | "Runtime",
500 | "Security"
501 | ],
502 | "types": [
503 | {
504 | "id": "LoaderId",
505 | "type": "string",
506 | "description": "Unique loader identifier."
507 | },
508 | {
509 | "id": "RequestId",
510 | "type": "string",
511 | "description": "Unique request identifier."
512 | },
513 | {
514 | "id": "Timestamp",
515 | "type": "number",
516 | "description": "Number of seconds since epoch."
517 | },
518 | {
519 | "id": "Headers",
520 | "type": "object",
521 | "description": "Request / response headers as keys / values of JSON object."
522 | },
523 | {
524 | "id": "ConnectionType",
525 | "type": "string",
526 | "enum": [
527 | "none",
528 | "cellular2g",
529 | "cellular3g",
530 | "cellular4g",
531 | "bluetooth",
532 | "ethernet",
533 | "wifi",
534 | "wimax",
535 | "other"
536 | ],
537 | "description": "Loading priority of a resource request."
538 | },
539 | {
540 | "id": "CookieSameSite",
541 | "type": "string",
542 | "enum": [
543 | "Strict",
544 | "Lax"
545 | ],
546 | "description": "Represents the cookie's 'SameSite' status: https://tools.ietf.org/html/draft-west-first-party-cookies"
547 | },
548 | {
549 | "id": "ResourceTiming",
550 | "type": "object",
551 | "description": "Timing information for the request.",
552 | "properties": [
553 | {
554 | "name": "requestTime",
555 | "type": "number",
556 | "description": "Timing's requestTime is a baseline in seconds, while the other numbers are ticks in milliseconds relatively to this requestTime."
557 | },
558 | {
559 | "name": "proxyStart",
560 | "type": "number",
561 | "description": "Started resolving proxy."
562 | },
563 | {
564 | "name": "proxyEnd",
565 | "type": "number",
566 | "description": "Finished resolving proxy."
567 | },
568 | {
569 | "name": "dnsStart",
570 | "type": "number",
571 | "description": "Started DNS address resolve."
572 | },
573 | {
574 | "name": "dnsEnd",
575 | "type": "number",
576 | "description": "Finished DNS address resolve."
577 | },
578 | {
579 | "name": "connectStart",
580 | "type": "number",
581 | "description": "Started connecting to the remote host."
582 | },
583 | {
584 | "name": "connectEnd",
585 | "type": "number",
586 | "description": "Connected to the remote host."
587 | },
588 | {
589 | "name": "sslStart",
590 | "type": "number",
591 | "description": "Started SSL handshake."
592 | },
593 | {
594 | "name": "sslEnd",
595 | "type": "number",
596 | "description": "Finished SSL handshake."
597 | },
598 | {
599 | "name": "workerStart",
600 | "type": "number",
601 | "description": "Started running ServiceWorker.",
602 | "experimental": true
603 | },
604 | {
605 | "name": "workerReady",
606 | "type": "number",
607 | "description": "Finished Starting ServiceWorker.",
608 | "experimental": true
609 | },
610 | {
611 | "name": "sendStart",
612 | "type": "number",
613 | "description": "Started sending request."
614 | },
615 | {
616 | "name": "sendEnd",
617 | "type": "number",
618 | "description": "Finished sending request."
619 | },
620 | {
621 | "name": "pushStart",
622 | "type": "number",
623 | "description": "Time the server started pushing request.",
624 | "experimental": true
625 | },
626 | {
627 | "name": "pushEnd",
628 | "type": "number",
629 | "description": "Time the server finished pushing request.",
630 | "experimental": true
631 | },
632 | {
633 | "name": "receiveHeadersEnd",
634 | "type": "number",
635 | "description": "Finished receiving response headers."
636 | }
637 | ]
638 | },
639 | {
640 | "id": "ResourcePriority",
641 | "type": "string",
642 | "enum": [
643 | "VeryLow",
644 | "Low",
645 | "Medium",
646 | "High",
647 | "VeryHigh"
648 | ],
649 | "description": "Loading priority of a resource request."
650 | },
651 | {
652 | "id": "Request",
653 | "type": "object",
654 | "description": "HTTP request data.",
655 | "properties": [
656 | {
657 | "name": "url",
658 | "type": "string",
659 | "description": "Request URL."
660 | },
661 | {
662 | "name": "method",
663 | "type": "string",
664 | "description": "HTTP request method."
665 | },
666 | {
667 | "name": "headers",
668 | "$ref": "Headers",
669 | "description": "HTTP request headers."
670 | },
671 | {
672 | "name": "postData",
673 | "type": "string",
674 | "optional": true,
675 | "description": "HTTP POST request data."
676 | },
677 | {
678 | "name": "mixedContentType",
679 | "optional": true,
680 | "type": "string",
681 | "enum": [
682 | "blockable",
683 | "optionally-blockable",
684 | "none"
685 | ],
686 | "description": "The mixed content status of the request, as defined in http://www.w3.org/TR/mixed-content/"
687 | },
688 | {
689 | "name": "initialPriority",
690 | "$ref": "ResourcePriority",
691 | "description": "Priority of the resource request at the time request is sent."
692 | }
693 | ]
694 | },
695 | {
696 | "id": "SignedCertificateTimestamp",
697 | "type": "object",
698 | "description": "Details of a signed certificate timestamp (SCT).",
699 | "properties": [
700 | {
701 | "name": "status",
702 | "type": "string",
703 | "description": "Validation status."
704 | },
705 | {
706 | "name": "origin",
707 | "type": "string",
708 | "description": "Origin."
709 | },
710 | {
711 | "name": "logDescription",
712 | "type": "string",
713 | "description": "Log name / description."
714 | },
715 | {
716 | "name": "logId",
717 | "type": "string",
718 | "description": "Log ID."
719 | },
720 | {
721 | "name": "timestamp",
722 | "$ref": "Timestamp",
723 | "description": "Issuance date."
724 | },
725 | {
726 | "name": "hashAlgorithm",
727 | "type": "string",
728 | "description": "Hash algorithm."
729 | },
730 | {
731 | "name": "signatureAlgorithm",
732 | "type": "string",
733 | "description": "Signature algorithm."
734 | },
735 | {
736 | "name": "signatureData",
737 | "type": "string",
738 | "description": "Signature data."
739 | }
740 | ]
741 | },
742 | {
743 | "id": "SecurityDetails",
744 | "type": "object",
745 | "description": "Security details about a request.",
746 | "properties": [
747 | {
748 | "name": "protocol",
749 | "type": "string",
750 | "description": "Protocol name (e.g. \"TLS 1.2\" or \"QUIC\")."
751 | },
752 | {
753 | "name": "keyExchange",
754 | "type": "string",
755 | "description": "Key Exchange used by the connection."
756 | },
757 | {
758 | "name": "keyExchangeGroup",
759 | "type": "string",
760 | "optional": true,
761 | "description": "(EC)DH group used by the connection, if applicable."
762 | },
763 | {
764 | "name": "cipher",
765 | "type": "string",
766 | "description": "Cipher name."
767 | },
768 | {
769 | "name": "mac",
770 | "type": "string",
771 | "optional": true,
772 | "description": "TLS MAC. Note that AEAD ciphers do not have separate MACs."
773 | },
774 | {
775 | "name": "certificateId",
776 | "$ref": "Security.CertificateId",
777 | "description": "Certificate ID value."
778 | },
779 | {
780 | "name": "subjectName",
781 | "type": "string",
782 | "description": "Certificate subject name."
783 | },
784 | {
785 | "name": "sanList",
786 | "type": "array",
787 | "items": {
788 | "type": "string"
789 | },
790 | "description": "Subject Alternative Name (SAN) DNS names and IP addresses."
791 | },
792 | {
793 | "name": "issuer",
794 | "type": "string",
795 | "description": "Name of the issuing CA."
796 | },
797 | {
798 | "name": "validFrom",
799 | "$ref": "Timestamp",
800 | "description": "Certificate valid from date."
801 | },
802 | {
803 | "name": "validTo",
804 | "$ref": "Timestamp",
805 | "description": "Certificate valid to (expiration) date"
806 | },
807 | {
808 | "name": "signedCertificateTimestampList",
809 | "type": "array",
810 | "items": {
811 | "$ref": "SignedCertificateTimestamp"
812 | },
813 | "description": "List of signed certificate timestamps (SCTs)."
814 | }
815 | ]
816 | },
817 | {
818 | "id": "Response",
819 | "type": "object",
820 | "description": "HTTP response data.",
821 | "properties": [
822 | {
823 | "name": "url",
824 | "type": "string",
825 | "description": "Response URL. This URL can be different from CachedResource.url in case of redirect."
826 | },
827 | {
828 | "name": "status",
829 | "type": "number",
830 | "description": "HTTP response status code."
831 | },
832 | {
833 | "name": "statusText",
834 | "type": "string",
835 | "description": "HTTP response status text."
836 | },
837 | {
838 | "name": "headers",
839 | "$ref": "Headers",
840 | "description": "HTTP response headers."
841 | },
842 | {
843 | "name": "headersText",
844 | "type": "string",
845 | "optional": true,
846 | "description": "HTTP response headers text."
847 | },
848 | {
849 | "name": "mimeType",
850 | "type": "string",
851 | "description": "Resource mimeType as determined by the browser."
852 | },
853 | {
854 | "name": "requestHeaders",
855 | "$ref": "Headers",
856 | "optional": true,
857 | "description": "Refined HTTP request headers that were actually transmitted over the network."
858 | },
859 | {
860 | "name": "requestHeadersText",
861 | "type": "string",
862 | "optional": true,
863 | "description": "HTTP request headers text."
864 | },
865 | {
866 | "name": "connectionReused",
867 | "type": "boolean",
868 | "description": "Specifies whether physical connection was actually reused for this request."
869 | },
870 | {
871 | "name": "connectionId",
872 | "type": "number",
873 | "description": "Physical connection id that was actually used for this request."
874 | },
875 | {
876 | "name": "remoteIPAddress",
877 | "type": "string",
878 | "optional": true,
879 | "experimental": true,
880 | "description": "Remote IP address."
881 | },
882 | {
883 | "name": "remotePort",
884 | "type": "integer",
885 | "optional": true,
886 | "experimental": true,
887 | "description": "Remote port."
888 | },
889 | {
890 | "name": "fromDiskCache",
891 | "type": "boolean",
892 | "optional": true,
893 | "description": "Specifies that the request was served from the disk cache."
894 | },
895 | {
896 | "name": "fromServiceWorker",
897 | "type": "boolean",
898 | "optional": true,
899 | "description": "Specifies that the request was served from the ServiceWorker."
900 | },
901 | {
902 | "name": "encodedDataLength",
903 | "type": "number",
904 | "optional": false,
905 | "description": "Total number of bytes received for this request so far."
906 | },
907 | {
908 | "name": "timing",
909 | "$ref": "ResourceTiming",
910 | "optional": true,
911 | "description": "Timing information for the given request."
912 | },
913 | {
914 | "name": "protocol",
915 | "type": "string",
916 | "optional": true,
917 | "description": "Protocol used to fetch this request."
918 | },
919 | {
920 | "name": "securityState",
921 | "$ref": "Security.SecurityState",
922 | "description": "Security state of the request resource."
923 | },
924 | {
925 | "name": "securityDetails",
926 | "$ref": "SecurityDetails",
927 | "optional": true,
928 | "description": "Security details for the request."
929 | }
930 | ]
931 | },
932 | {
933 | "id": "CachedResource",
934 | "type": "object",
935 | "description": "Information about the cached resource.",
936 | "properties": [
937 | {
938 | "name": "url",
939 | "type": "string",
940 | "description": "Resource URL. This is the url of the original network request."
941 | },
942 | {
943 | "name": "type",
944 | "$ref": "Page.ResourceType",
945 | "description": "Type of this resource."
946 | },
947 | {
948 | "name": "response",
949 | "$ref": "Response",
950 | "optional": true,
951 | "description": "Cached response data."
952 | },
953 | {
954 | "name": "bodySize",
955 | "type": "number",
956 | "description": "Cached response body size."
957 | }
958 | ]
959 | },
960 | {
961 | "id": "Initiator",
962 | "type": "object",
963 | "description": "Information about the request initiator.",
964 | "properties": [
965 | {
966 | "name": "type",
967 | "type": "string",
968 | "enum": [
969 | "parser",
970 | "script",
971 | "other"
972 | ],
973 | "description": "Type of this initiator."
974 | },
975 | {
976 | "name": "stack",
977 | "$ref": "Runtime.StackTrace",
978 | "optional": true,
979 | "description": "Initiator JavaScript stack trace, set for Script only."
980 | },
981 | {
982 | "name": "url",
983 | "type": "string",
984 | "optional": true,
985 | "description": "Initiator URL, set for Parser type only."
986 | },
987 | {
988 | "name": "lineNumber",
989 | "type": "number",
990 | "optional": true,
991 | "description": "Initiator line number, set for Parser type only (0-based)."
992 | }
993 | ]
994 | }
995 | ],
996 | "commands": [
997 | {
998 | "name": "enable",
999 | "description": "Enables network tracking, network events will now be delivered to the client.",
1000 | "parameters": [
1001 | {
1002 | "name": "maxTotalBufferSize",
1003 | "type": "integer",
1004 | "optional": true,
1005 | "experimental": true,
1006 | "description": "Buffer size in bytes to use when preserving network payloads (XHRs, etc)."
1007 | },
1008 | {
1009 | "name": "maxResourceBufferSize",
1010 | "type": "integer",
1011 | "optional": true,
1012 | "experimental": true,
1013 | "description": "Per-resource buffer size in bytes to use when preserving network payloads (XHRs, etc)."
1014 | }
1015 | ]
1016 | },
1017 | {
1018 | "name": "disable",
1019 | "description": "Disables network tracking, prevents network events from being sent to the client."
1020 | },
1021 | {
1022 | "name": "setUserAgentOverride",
1023 | "description": "Allows overriding user agent with the given string.",
1024 | "parameters": [
1025 | {
1026 | "name": "userAgent",
1027 | "type": "string",
1028 | "description": "User agent to use."
1029 | }
1030 | ]
1031 | },
1032 | {
1033 | "name": "setExtraHTTPHeaders",
1034 | "description": "Specifies whether to always send extra HTTP headers with the requests from this page.",
1035 | "parameters": [
1036 | {
1037 | "name": "headers",
1038 | "$ref": "Headers",
1039 | "description": "Map with extra HTTP headers."
1040 | }
1041 | ]
1042 | },
1043 | {
1044 | "name": "getResponseBody",
1045 | "async": true,
1046 | "description": "Returns content served for the given request.",
1047 | "parameters": [
1048 | {
1049 | "name": "requestId",
1050 | "$ref": "RequestId",
1051 | "description": "Identifier of the network request to get content for."
1052 | }
1053 | ],
1054 | "returns": [
1055 | {
1056 | "name": "body",
1057 | "type": "string",
1058 | "description": "Response body."
1059 | },
1060 | {
1061 | "name": "base64Encoded",
1062 | "type": "boolean",
1063 | "description": "True, if content was sent as base64."
1064 | }
1065 | ]
1066 | },
1067 | {
1068 | "name": "canClearBrowserCache",
1069 | "description": "Tells whether clearing browser cache is supported.",
1070 | "returns": [
1071 | {
1072 | "name": "result",
1073 | "type": "boolean",
1074 | "description": "True if browser cache can be cleared."
1075 | }
1076 | ]
1077 | },
1078 | {
1079 | "name": "clearBrowserCache",
1080 | "description": "Clears browser cache.",
1081 | "handlers": [
1082 | "browser"
1083 | ]
1084 | },
1085 | {
1086 | "name": "canClearBrowserCookies",
1087 | "description": "Tells whether clearing browser cookies is supported.",
1088 | "returns": [
1089 | {
1090 | "name": "result",
1091 | "type": "boolean",
1092 | "description": "True if browser cookies can be cleared."
1093 | }
1094 | ]
1095 | },
1096 | {
1097 | "name": "clearBrowserCookies",
1098 | "description": "Clears browser cookies.",
1099 | "handlers": [
1100 | "browser"
1101 | ]
1102 | },
1103 | {
1104 | "name": "emulateNetworkConditions",
1105 | "description": "Activates emulation of network conditions.",
1106 | "parameters": [
1107 | {
1108 | "name": "offline",
1109 | "type": "boolean",
1110 | "description": "True to emulate internet disconnection."
1111 | },
1112 | {
1113 | "name": "latency",
1114 | "type": "number",
1115 | "description": "Additional latency (ms)."
1116 | },
1117 | {
1118 | "name": "downloadThroughput",
1119 | "type": "number",
1120 | "description": "Maximal aggregated download throughput."
1121 | },
1122 | {
1123 | "name": "uploadThroughput",
1124 | "type": "number",
1125 | "description": "Maximal aggregated upload throughput."
1126 | },
1127 | {
1128 | "name": "connectionType",
1129 | "$ref": "ConnectionType",
1130 | "optional": true,
1131 | "description": "Connection type if known."
1132 | }
1133 | ],
1134 | "handlers": [
1135 | "browser",
1136 | "renderer"
1137 | ]
1138 | },
1139 | {
1140 | "name": "setCacheDisabled",
1141 | "parameters": [
1142 | {
1143 | "name": "cacheDisabled",
1144 | "type": "boolean",
1145 | "description": "Cache disabled state."
1146 | }
1147 | ],
1148 | "description": "Toggles ignoring cache for each request. If true
, cache will not be used."
1149 | }
1150 | ],
1151 | "events": [
1152 | {
1153 | "name": "requestWillBeSent",
1154 | "description": "Fired when page is about to send HTTP request.",
1155 | "parameters": [
1156 | {
1157 | "name": "requestId",
1158 | "$ref": "RequestId",
1159 | "description": "Request identifier."
1160 | },
1161 | {
1162 | "name": "frameId",
1163 | "$ref": "Page.FrameId",
1164 | "description": "Frame identifier.",
1165 | "experimental": true
1166 | },
1167 | {
1168 | "name": "loaderId",
1169 | "$ref": "LoaderId",
1170 | "description": "Loader identifier."
1171 | },
1172 | {
1173 | "name": "documentURL",
1174 | "type": "string",
1175 | "description": "URL of the document this request is loaded for."
1176 | },
1177 | {
1178 | "name": "request",
1179 | "$ref": "Request",
1180 | "description": "Request data."
1181 | },
1182 | {
1183 | "name": "timestamp",
1184 | "$ref": "Timestamp",
1185 | "description": "Timestamp."
1186 | },
1187 | {
1188 | "name": "wallTime",
1189 | "$ref": "Timestamp",
1190 | "experimental": true,
1191 | "description": "UTC Timestamp."
1192 | },
1193 | {
1194 | "name": "initiator",
1195 | "$ref": "Initiator",
1196 | "description": "Request initiator."
1197 | },
1198 | {
1199 | "name": "redirectResponse",
1200 | "optional": true,
1201 | "$ref": "Response",
1202 | "description": "Redirect response data."
1203 | },
1204 | {
1205 | "name": "type",
1206 | "$ref": "Page.ResourceType",
1207 | "optional": true,
1208 | "experimental": true,
1209 | "description": "Type of this resource."
1210 | }
1211 | ]
1212 | },
1213 | {
1214 | "name": "requestServedFromCache",
1215 | "description": "Fired if request ended up loading from cache.",
1216 | "parameters": [
1217 | {
1218 | "name": "requestId",
1219 | "$ref": "RequestId",
1220 | "description": "Request identifier."
1221 | }
1222 | ]
1223 | },
1224 | {
1225 | "name": "responseReceived",
1226 | "description": "Fired when HTTP response is available.",
1227 | "parameters": [
1228 | {
1229 | "name": "requestId",
1230 | "$ref": "RequestId",
1231 | "description": "Request identifier."
1232 | },
1233 | {
1234 | "name": "frameId",
1235 | "$ref": "Page.FrameId",
1236 | "description": "Frame identifier.",
1237 | "experimental": true
1238 | },
1239 | {
1240 | "name": "loaderId",
1241 | "$ref": "LoaderId",
1242 | "description": "Loader identifier."
1243 | },
1244 | {
1245 | "name": "timestamp",
1246 | "$ref": "Timestamp",
1247 | "description": "Timestamp."
1248 | },
1249 | {
1250 | "name": "type",
1251 | "$ref": "Page.ResourceType",
1252 | "description": "Resource type."
1253 | },
1254 | {
1255 | "name": "response",
1256 | "$ref": "Response",
1257 | "description": "Response data."
1258 | }
1259 | ]
1260 | },
1261 | {
1262 | "name": "dataReceived",
1263 | "description": "Fired when data chunk was received over the network.",
1264 | "parameters": [
1265 | {
1266 | "name": "requestId",
1267 | "$ref": "RequestId",
1268 | "description": "Request identifier."
1269 | },
1270 | {
1271 | "name": "timestamp",
1272 | "$ref": "Timestamp",
1273 | "description": "Timestamp."
1274 | },
1275 | {
1276 | "name": "dataLength",
1277 | "type": "integer",
1278 | "description": "Data chunk length."
1279 | },
1280 | {
1281 | "name": "encodedDataLength",
1282 | "type": "integer",
1283 | "description": "Actual bytes received (might be less than dataLength for compressed encodings)."
1284 | }
1285 | ]
1286 | },
1287 | {
1288 | "name": "loadingFinished",
1289 | "description": "Fired when HTTP request has finished loading.",
1290 | "parameters": [
1291 | {
1292 | "name": "requestId",
1293 | "$ref": "RequestId",
1294 | "description": "Request identifier."
1295 | },
1296 | {
1297 | "name": "timestamp",
1298 | "$ref": "Timestamp",
1299 | "description": "Timestamp."
1300 | },
1301 | {
1302 | "name": "encodedDataLength",
1303 | "type": "number",
1304 | "description": "Total number of bytes received for this request."
1305 | }
1306 | ]
1307 | },
1308 | {
1309 | "name": "loadingFailed",
1310 | "description": "Fired when HTTP request has failed to load.",
1311 | "parameters": [
1312 | {
1313 | "name": "requestId",
1314 | "$ref": "RequestId",
1315 | "description": "Request identifier."
1316 | },
1317 | {
1318 | "name": "timestamp",
1319 | "$ref": "Timestamp",
1320 | "description": "Timestamp."
1321 | },
1322 | {
1323 | "name": "type",
1324 | "$ref": "Page.ResourceType",
1325 | "description": "Resource type."
1326 | },
1327 | {
1328 | "name": "errorText",
1329 | "type": "string",
1330 | "description": "User friendly error message."
1331 | },
1332 | {
1333 | "name": "canceled",
1334 | "type": "boolean",
1335 | "optional": true,
1336 | "description": "True if loading was canceled."
1337 | },
1338 | {
1339 | "name": "blockedReason",
1340 | "$ref": "BlockedReason",
1341 | "optional": true,
1342 | "description": "The reason why loading was blocked, if any.",
1343 | "experimental": true
1344 | }
1345 | ]
1346 | }
1347 | ]
1348 | },
1349 | {
1350 | "domain": "DOM",
1351 | "description": "This domain exposes DOM read/write operations. Each DOM Node is represented with its mirror object that has an id
. This id
can be used to get additional information on the Node, resolve it into the JavaScript object wrapper, etc. It is important that client receives DOM events only for the nodes that are known to the client. Backend keeps track of the nodes that were sent to the client and never sends the same node twice. It is client's responsibility to collect information about the nodes that were sent to the client.
Note that iframe
owner elements will return corresponding document elements as their child nodes.
nodeId
. Backend will only push node with given id
once. It is aware of all requested nodes and will only fire DOM events for nodes known to the client."
1401 | },
1402 | {
1403 | "name": "nodeType",
1404 | "type": "integer",
1405 | "description": "Node
's nodeType."
1406 | },
1407 | {
1408 | "name": "nodeName",
1409 | "type": "string",
1410 | "description": "Node
's nodeName."
1411 | },
1412 | {
1413 | "name": "localName",
1414 | "type": "string",
1415 | "description": "Node
's localName."
1416 | },
1417 | {
1418 | "name": "nodeValue",
1419 | "type": "string",
1420 | "description": "Node
's nodeValue."
1421 | },
1422 | {
1423 | "name": "childNodeCount",
1424 | "type": "integer",
1425 | "optional": true,
1426 | "description": "Child count for Container
nodes."
1427 | },
1428 | {
1429 | "name": "children",
1430 | "type": "array",
1431 | "optional": true,
1432 | "items": {
1433 | "$ref": "Node"
1434 | },
1435 | "description": "Child nodes of this node when requested with children."
1436 | },
1437 | {
1438 | "name": "attributes",
1439 | "type": "array",
1440 | "optional": true,
1441 | "items": {
1442 | "type": "string"
1443 | },
1444 | "description": "Attributes of the Element
node in the form of flat array [name1, value1, name2, value2]
."
1445 | },
1446 | {
1447 | "name": "documentURL",
1448 | "type": "string",
1449 | "optional": true,
1450 | "description": "Document URL that Document
or FrameOwner
node points to."
1451 | },
1452 | {
1453 | "name": "baseURL",
1454 | "type": "string",
1455 | "optional": true,
1456 | "description": "Base URL that Document
or FrameOwner
node uses for URL completion.",
1457 | "experimental": true
1458 | },
1459 | {
1460 | "name": "publicId",
1461 | "type": "string",
1462 | "optional": true,
1463 | "description": "DocumentType
's publicId."
1464 | },
1465 | {
1466 | "name": "systemId",
1467 | "type": "string",
1468 | "optional": true,
1469 | "description": "DocumentType
's systemId."
1470 | },
1471 | {
1472 | "name": "internalSubset",
1473 | "type": "string",
1474 | "optional": true,
1475 | "description": "DocumentType
's internalSubset."
1476 | },
1477 | {
1478 | "name": "xmlVersion",
1479 | "type": "string",
1480 | "optional": true,
1481 | "description": "Document
's XML version in case of XML documents."
1482 | },
1483 | {
1484 | "name": "name",
1485 | "type": "string",
1486 | "optional": true,
1487 | "description": "Attr
's name."
1488 | },
1489 | {
1490 | "name": "value",
1491 | "type": "string",
1492 | "optional": true,
1493 | "description": "Attr
's value."
1494 | },
1495 | {
1496 | "name": "pseudoType",
1497 | "$ref": "PseudoType",
1498 | "optional": true,
1499 | "description": "Pseudo element type for this node."
1500 | },
1501 | {
1502 | "name": "shadowRootType",
1503 | "$ref": "ShadowRootType",
1504 | "optional": true,
1505 | "description": "Shadow root type."
1506 | },
1507 | {
1508 | "name": "frameId",
1509 | "$ref": "Page.FrameId",
1510 | "optional": true,
1511 | "description": "Frame ID for frame owner elements.",
1512 | "experimental": true
1513 | },
1514 | {
1515 | "name": "contentDocument",
1516 | "$ref": "Node",
1517 | "optional": true,
1518 | "description": "Content document for frame owner elements."
1519 | },
1520 | {
1521 | "name": "shadowRoots",
1522 | "type": "array",
1523 | "optional": true,
1524 | "items": {
1525 | "$ref": "Node"
1526 | },
1527 | "description": "Shadow root list for given element host.",
1528 | "experimental": true
1529 | },
1530 | {
1531 | "name": "templateContent",
1532 | "$ref": "Node",
1533 | "optional": true,
1534 | "description": "Content document fragment for template elements.",
1535 | "experimental": true
1536 | },
1537 | {
1538 | "name": "pseudoElements",
1539 | "type": "array",
1540 | "items": {
1541 | "$ref": "Node"
1542 | },
1543 | "optional": true,
1544 | "description": "Pseudo elements associated with this node.",
1545 | "experimental": true
1546 | },
1547 | {
1548 | "name": "importedDocument",
1549 | "$ref": "Node",
1550 | "optional": true,
1551 | "description": "Import document for the HTMLImport links."
1552 | },
1553 | {
1554 | "name": "distributedNodes",
1555 | "type": "array",
1556 | "items": {
1557 | "$ref": "BackendNode"
1558 | },
1559 | "optional": true,
1560 | "description": "Distributed nodes for given insertion point.",
1561 | "experimental": true
1562 | }
1563 | ],
1564 | "description": "DOM interaction is implemented in terms of mirror objects that represent the actual DOM nodes. DOMNode is a base node mirror type."
1565 | },
1566 | {
1567 | "id": "RGBA",
1568 | "type": "object",
1569 | "properties": [
1570 | {
1571 | "name": "r",
1572 | "type": "integer",
1573 | "description": "The red component, in the [0-255] range."
1574 | },
1575 | {
1576 | "name": "g",
1577 | "type": "integer",
1578 | "description": "The green component, in the [0-255] range."
1579 | },
1580 | {
1581 | "name": "b",
1582 | "type": "integer",
1583 | "description": "The blue component, in the [0-255] range."
1584 | },
1585 | {
1586 | "name": "a",
1587 | "type": "number",
1588 | "optional": true,
1589 | "description": "The alpha component, in the [0-1] range (default: 1)."
1590 | }
1591 | ],
1592 | "description": "A structure holding an RGBA color."
1593 | },
1594 | {
1595 | "id": "HighlightConfig",
1596 | "type": "object",
1597 | "properties": [
1598 | {
1599 | "name": "showInfo",
1600 | "type": "boolean",
1601 | "optional": true,
1602 | "description": "Whether the node info tooltip should be shown (default: false)."
1603 | },
1604 | {
1605 | "name": "showRulers",
1606 | "type": "boolean",
1607 | "optional": true,
1608 | "description": "Whether the rulers should be shown (default: false)."
1609 | },
1610 | {
1611 | "name": "showExtensionLines",
1612 | "type": "boolean",
1613 | "optional": true,
1614 | "description": "Whether the extension lines from node to the rulers should be shown (default: false)."
1615 | },
1616 | {
1617 | "name": "displayAsMaterial",
1618 | "type": "boolean",
1619 | "optional": true,
1620 | "experimental": true
1621 | },
1622 | {
1623 | "name": "contentColor",
1624 | "$ref": "RGBA",
1625 | "optional": true,
1626 | "description": "The content box highlight fill color (default: transparent)."
1627 | },
1628 | {
1629 | "name": "paddingColor",
1630 | "$ref": "RGBA",
1631 | "optional": true,
1632 | "description": "The padding highlight fill color (default: transparent)."
1633 | },
1634 | {
1635 | "name": "borderColor",
1636 | "$ref": "RGBA",
1637 | "optional": true,
1638 | "description": "The border highlight fill color (default: transparent)."
1639 | },
1640 | {
1641 | "name": "marginColor",
1642 | "$ref": "RGBA",
1643 | "optional": true,
1644 | "description": "The margin highlight fill color (default: transparent)."
1645 | },
1646 | {
1647 | "name": "eventTargetColor",
1648 | "$ref": "RGBA",
1649 | "optional": true,
1650 | "experimental": true,
1651 | "description": "The event target element highlight fill color (default: transparent)."
1652 | },
1653 | {
1654 | "name": "shapeColor",
1655 | "$ref": "RGBA",
1656 | "optional": true,
1657 | "experimental": true,
1658 | "description": "The shape outside fill color (default: transparent)."
1659 | },
1660 | {
1661 | "name": "shapeMarginColor",
1662 | "$ref": "RGBA",
1663 | "optional": true,
1664 | "experimental": true,
1665 | "description": "The shape margin fill color (default: transparent)."
1666 | },
1667 | {
1668 | "name": "selectorList",
1669 | "type": "string",
1670 | "optional": true,
1671 | "description": "Selectors to highlight relevant nodes."
1672 | }
1673 | ],
1674 | "description": "Configuration data for the highlighting of page elements."
1675 | }
1676 | ],
1677 | "commands": [
1678 | {
1679 | "name": "enable",
1680 | "description": "Enables DOM agent for the given page."
1681 | },
1682 | {
1683 | "name": "disable",
1684 | "description": "Disables DOM agent for the given page."
1685 | },
1686 | {
1687 | "name": "getDocument",
1688 | "returns": [
1689 | {
1690 | "name": "root",
1691 | "$ref": "Node",
1692 | "description": "Resulting node."
1693 | }
1694 | ],
1695 | "description": "Returns the root DOM node to the caller."
1696 | },
1697 | {
1698 | "name": "requestChildNodes",
1699 | "parameters": [
1700 | {
1701 | "name": "nodeId",
1702 | "$ref": "NodeId",
1703 | "description": "Id of the node to get children for."
1704 | },
1705 | {
1706 | "name": "depth",
1707 | "type": "integer",
1708 | "optional": true,
1709 | "description": "The maximum depth at which children should be retrieved, defaults to 1. Use -1 for the entire subtree or provide an integer larger than 0.",
1710 | "experimental": true
1711 | }
1712 | ],
1713 | "description": "Requests that children of the node with given id are returned to the caller in form of setChildNodes
events where not only immediate children are retrieved, but all children down to the specified depth."
1714 | },
1715 | {
1716 | "name": "querySelector",
1717 | "parameters": [
1718 | {
1719 | "name": "nodeId",
1720 | "$ref": "NodeId",
1721 | "description": "Id of the node to query upon."
1722 | },
1723 | {
1724 | "name": "selector",
1725 | "type": "string",
1726 | "description": "Selector string."
1727 | }
1728 | ],
1729 | "returns": [
1730 | {
1731 | "name": "nodeId",
1732 | "$ref": "NodeId",
1733 | "description": "Query selector result."
1734 | }
1735 | ],
1736 | "description": "Executes querySelector
on a given node."
1737 | },
1738 | {
1739 | "name": "querySelectorAll",
1740 | "parameters": [
1741 | {
1742 | "name": "nodeId",
1743 | "$ref": "NodeId",
1744 | "description": "Id of the node to query upon."
1745 | },
1746 | {
1747 | "name": "selector",
1748 | "type": "string",
1749 | "description": "Selector string."
1750 | }
1751 | ],
1752 | "returns": [
1753 | {
1754 | "name": "nodeIds",
1755 | "type": "array",
1756 | "items": {
1757 | "$ref": "NodeId"
1758 | },
1759 | "description": "Query selector result."
1760 | }
1761 | ],
1762 | "description": "Executes querySelectorAll
on a given node."
1763 | },
1764 | {
1765 | "name": "setNodeName",
1766 | "parameters": [
1767 | {
1768 | "name": "nodeId",
1769 | "$ref": "NodeId",
1770 | "description": "Id of the node to set name for."
1771 | },
1772 | {
1773 | "name": "name",
1774 | "type": "string",
1775 | "description": "New node's name."
1776 | }
1777 | ],
1778 | "returns": [
1779 | {
1780 | "name": "nodeId",
1781 | "$ref": "NodeId",
1782 | "description": "New node's id."
1783 | }
1784 | ],
1785 | "description": "Sets node name for a node with given id."
1786 | },
1787 | {
1788 | "name": "setNodeValue",
1789 | "parameters": [
1790 | {
1791 | "name": "nodeId",
1792 | "$ref": "NodeId",
1793 | "description": "Id of the node to set value for."
1794 | },
1795 | {
1796 | "name": "value",
1797 | "type": "string",
1798 | "description": "New node's value."
1799 | }
1800 | ],
1801 | "description": "Sets node value for a node with given id."
1802 | },
1803 | {
1804 | "name": "removeNode",
1805 | "parameters": [
1806 | {
1807 | "name": "nodeId",
1808 | "$ref": "NodeId",
1809 | "description": "Id of the node to remove."
1810 | }
1811 | ],
1812 | "description": "Removes node with given id."
1813 | },
1814 | {
1815 | "name": "setAttributeValue",
1816 | "parameters": [
1817 | {
1818 | "name": "nodeId",
1819 | "$ref": "NodeId",
1820 | "description": "Id of the element to set attribute for."
1821 | },
1822 | {
1823 | "name": "name",
1824 | "type": "string",
1825 | "description": "Attribute name."
1826 | },
1827 | {
1828 | "name": "value",
1829 | "type": "string",
1830 | "description": "Attribute value."
1831 | }
1832 | ],
1833 | "description": "Sets attribute for an element with given id."
1834 | },
1835 | {
1836 | "name": "setAttributesAsText",
1837 | "parameters": [
1838 | {
1839 | "name": "nodeId",
1840 | "$ref": "NodeId",
1841 | "description": "Id of the element to set attributes for."
1842 | },
1843 | {
1844 | "name": "text",
1845 | "type": "string",
1846 | "description": "Text with a number of attributes. Will parse this text using HTML parser."
1847 | },
1848 | {
1849 | "name": "name",
1850 | "type": "string",
1851 | "optional": true,
1852 | "description": "Attribute name to replace with new attributes derived from text in case text parsed successfully."
1853 | }
1854 | ],
1855 | "description": "Sets attributes on element with given id. This method is useful when user edits some existing attribute value and types in several attribute name/value pairs."
1856 | },
1857 | {
1858 | "name": "removeAttribute",
1859 | "parameters": [
1860 | {
1861 | "name": "nodeId",
1862 | "$ref": "NodeId",
1863 | "description": "Id of the element to remove attribute from."
1864 | },
1865 | {
1866 | "name": "name",
1867 | "type": "string",
1868 | "description": "Name of the attribute to remove."
1869 | }
1870 | ],
1871 | "description": "Removes attribute with given name from an element with given id."
1872 | },
1873 | {
1874 | "name": "getOuterHTML",
1875 | "parameters": [
1876 | {
1877 | "name": "nodeId",
1878 | "$ref": "NodeId",
1879 | "description": "Id of the node to get markup for."
1880 | }
1881 | ],
1882 | "returns": [
1883 | {
1884 | "name": "outerHTML",
1885 | "type": "string",
1886 | "description": "Outer HTML markup."
1887 | }
1888 | ],
1889 | "description": "Returns node's HTML markup."
1890 | },
1891 | {
1892 | "name": "setOuterHTML",
1893 | "parameters": [
1894 | {
1895 | "name": "nodeId",
1896 | "$ref": "NodeId",
1897 | "description": "Id of the node to set markup for."
1898 | },
1899 | {
1900 | "name": "outerHTML",
1901 | "type": "string",
1902 | "description": "Outer HTML markup to set."
1903 | }
1904 | ],
1905 | "description": "Sets node HTML markup, returns new node id."
1906 | },
1907 | {
1908 | "name": "requestNode",
1909 | "parameters": [
1910 | {
1911 | "name": "objectId",
1912 | "$ref": "Runtime.RemoteObjectId",
1913 | "description": "JavaScript object id to convert into node."
1914 | }
1915 | ],
1916 | "returns": [
1917 | {
1918 | "name": "nodeId",
1919 | "$ref": "NodeId",
1920 | "description": "Node id for given object."
1921 | }
1922 | ],
1923 | "description": "Requests that the node is sent to the caller given the JavaScript node object reference. All nodes that form the path from the node to the root are also sent to the client as a series of setChildNodes
notifications."
1924 | },
1925 | {
1926 | "name": "highlightRect",
1927 | "parameters": [
1928 | {
1929 | "name": "x",
1930 | "type": "integer",
1931 | "description": "X coordinate"
1932 | },
1933 | {
1934 | "name": "y",
1935 | "type": "integer",
1936 | "description": "Y coordinate"
1937 | },
1938 | {
1939 | "name": "width",
1940 | "type": "integer",
1941 | "description": "Rectangle width"
1942 | },
1943 | {
1944 | "name": "height",
1945 | "type": "integer",
1946 | "description": "Rectangle height"
1947 | },
1948 | {
1949 | "name": "color",
1950 | "$ref": "RGBA",
1951 | "optional": true,
1952 | "description": "The highlight fill color (default: transparent)."
1953 | },
1954 | {
1955 | "name": "outlineColor",
1956 | "$ref": "RGBA",
1957 | "optional": true,
1958 | "description": "The highlight outline color (default: transparent)."
1959 | }
1960 | ],
1961 | "description": "Highlights given rectangle. Coordinates are absolute with respect to the main frame viewport."
1962 | },
1963 | {
1964 | "name": "highlightNode",
1965 | "parameters": [
1966 | {
1967 | "name": "highlightConfig",
1968 | "$ref": "HighlightConfig",
1969 | "description": "A descriptor for the highlight appearance."
1970 | },
1971 | {
1972 | "name": "nodeId",
1973 | "$ref": "NodeId",
1974 | "optional": true,
1975 | "description": "Identifier of the node to highlight."
1976 | },
1977 | {
1978 | "name": "backendNodeId",
1979 | "$ref": "BackendNodeId",
1980 | "optional": true,
1981 | "description": "Identifier of the backend node to highlight."
1982 | },
1983 | {
1984 | "name": "objectId",
1985 | "$ref": "Runtime.RemoteObjectId",
1986 | "optional": true,
1987 | "description": "JavaScript object id of the node to be highlighted.",
1988 | "experimental": true
1989 | }
1990 | ],
1991 | "description": "Highlights DOM node with given id or with the given JavaScript object wrapper. Either nodeId or objectId must be specified."
1992 | },
1993 | {
1994 | "name": "hideHighlight",
1995 | "description": "Hides DOM node highlight."
1996 | },
1997 | {
1998 | "name": "resolveNode",
1999 | "parameters": [
2000 | {
2001 | "name": "nodeId",
2002 | "$ref": "NodeId",
2003 | "description": "Id of the node to resolve."
2004 | },
2005 | {
2006 | "name": "objectGroup",
2007 | "type": "string",
2008 | "optional": true,
2009 | "description": "Symbolic group name that can be used to release multiple objects."
2010 | }
2011 | ],
2012 | "returns": [
2013 | {
2014 | "name": "object",
2015 | "$ref": "Runtime.RemoteObject",
2016 | "description": "JavaScript object wrapper for given node."
2017 | }
2018 | ],
2019 | "description": "Resolves JavaScript node object for given node id."
2020 | },
2021 | {
2022 | "name": "getAttributes",
2023 | "parameters": [
2024 | {
2025 | "name": "nodeId",
2026 | "$ref": "NodeId",
2027 | "description": "Id of the node to retrieve attibutes for."
2028 | }
2029 | ],
2030 | "returns": [
2031 | {
2032 | "name": "attributes",
2033 | "type": "array",
2034 | "items": {
2035 | "type": "string"
2036 | },
2037 | "description": "An interleaved array of node attribute names and values."
2038 | }
2039 | ],
2040 | "description": "Returns attributes for the specified node."
2041 | },
2042 | {
2043 | "name": "moveTo",
2044 | "parameters": [
2045 | {
2046 | "name": "nodeId",
2047 | "$ref": "NodeId",
2048 | "description": "Id of the node to move."
2049 | },
2050 | {
2051 | "name": "targetNodeId",
2052 | "$ref": "NodeId",
2053 | "description": "Id of the element to drop the moved node into."
2054 | },
2055 | {
2056 | "name": "insertBeforeNodeId",
2057 | "$ref": "NodeId",
2058 | "optional": true,
2059 | "description": "Drop node before this one (if absent, the moved node becomes the last child of targetNodeId
)."
2060 | }
2061 | ],
2062 | "returns": [
2063 | {
2064 | "name": "nodeId",
2065 | "$ref": "NodeId",
2066 | "description": "New id of the moved node."
2067 | }
2068 | ],
2069 | "description": "Moves node into the new container, places it before the given anchor."
2070 | }
2071 | ],
2072 | "events": [
2073 | {
2074 | "name": "documentUpdated",
2075 | "description": "Fired when Document
has been totally updated. Node ids are no longer valid."
2076 | },
2077 | {
2078 | "name": "setChildNodes",
2079 | "parameters": [
2080 | {
2081 | "name": "parentId",
2082 | "$ref": "NodeId",
2083 | "description": "Parent node id to populate with children."
2084 | },
2085 | {
2086 | "name": "nodes",
2087 | "type": "array",
2088 | "items": {
2089 | "$ref": "Node"
2090 | },
2091 | "description": "Child nodes array."
2092 | }
2093 | ],
2094 | "description": "Fired when backend wants to provide client with the missing DOM structure. This happens upon most of the calls requesting node ids."
2095 | },
2096 | {
2097 | "name": "attributeModified",
2098 | "parameters": [
2099 | {
2100 | "name": "nodeId",
2101 | "$ref": "NodeId",
2102 | "description": "Id of the node that has changed."
2103 | },
2104 | {
2105 | "name": "name",
2106 | "type": "string",
2107 | "description": "Attribute name."
2108 | },
2109 | {
2110 | "name": "value",
2111 | "type": "string",
2112 | "description": "Attribute value."
2113 | }
2114 | ],
2115 | "description": "Fired when Element
's attribute is modified."
2116 | },
2117 | {
2118 | "name": "attributeRemoved",
2119 | "parameters": [
2120 | {
2121 | "name": "nodeId",
2122 | "$ref": "NodeId",
2123 | "description": "Id of the node that has changed."
2124 | },
2125 | {
2126 | "name": "name",
2127 | "type": "string",
2128 | "description": "A ttribute name."
2129 | }
2130 | ],
2131 | "description": "Fired when Element
's attribute is removed."
2132 | },
2133 | {
2134 | "name": "characterDataModified",
2135 | "parameters": [
2136 | {
2137 | "name": "nodeId",
2138 | "$ref": "NodeId",
2139 | "description": "Id of the node that has changed."
2140 | },
2141 | {
2142 | "name": "characterData",
2143 | "type": "string",
2144 | "description": "New text value."
2145 | }
2146 | ],
2147 | "description": "Mirrors DOMCharacterDataModified
event."
2148 | },
2149 | {
2150 | "name": "childNodeCountUpdated",
2151 | "parameters": [
2152 | {
2153 | "name": "nodeId",
2154 | "$ref": "NodeId",
2155 | "description": "Id of the node that has changed."
2156 | },
2157 | {
2158 | "name": "childNodeCount",
2159 | "type": "integer",
2160 | "description": "New node count."
2161 | }
2162 | ],
2163 | "description": "Fired when Container
's child node count has changed."
2164 | },
2165 | {
2166 | "name": "childNodeInserted",
2167 | "parameters": [
2168 | {
2169 | "name": "parentNodeId",
2170 | "$ref": "NodeId",
2171 | "description": "Id of the node that has changed."
2172 | },
2173 | {
2174 | "name": "previousNodeId",
2175 | "$ref": "NodeId",
2176 | "description": "If of the previous siblint."
2177 | },
2178 | {
2179 | "name": "node",
2180 | "$ref": "Node",
2181 | "description": "Inserted node data."
2182 | }
2183 | ],
2184 | "description": "Mirrors DOMNodeInserted
event."
2185 | },
2186 | {
2187 | "name": "childNodeRemoved",
2188 | "parameters": [
2189 | {
2190 | "name": "parentNodeId",
2191 | "$ref": "NodeId",
2192 | "description": "Parent id."
2193 | },
2194 | {
2195 | "name": "nodeId",
2196 | "$ref": "NodeId",
2197 | "description": "Id of the node that has been removed."
2198 | }
2199 | ],
2200 | "description": "Mirrors DOMNodeRemoved
event."
2201 | }
2202 | ]
2203 | },
2204 | {
2205 | "domain": "DOMDebugger",
2206 | "description": "DOM debugging allows setting breakpoints on particular DOM operations and events. JavaScript execution will stop on these operations as if there was a regular breakpoint set.",
2207 | "dependencies": [
2208 | "DOM",
2209 | "Debugger"
2210 | ],
2211 | "types": [
2212 | {
2213 | "id": "DOMBreakpointType",
2214 | "type": "string",
2215 | "enum": [
2216 | "subtree-modified",
2217 | "attribute-modified",
2218 | "node-removed"
2219 | ],
2220 | "description": "DOM breakpoint type."
2221 | }
2222 | ],
2223 | "commands": [
2224 | {
2225 | "name": "setDOMBreakpoint",
2226 | "parameters": [
2227 | {
2228 | "name": "nodeId",
2229 | "$ref": "DOM.NodeId",
2230 | "description": "Identifier of the node to set breakpoint on."
2231 | },
2232 | {
2233 | "name": "type",
2234 | "$ref": "DOMBreakpointType",
2235 | "description": "Type of the operation to stop upon."
2236 | }
2237 | ],
2238 | "description": "Sets breakpoint on particular operation with DOM."
2239 | },
2240 | {
2241 | "name": "removeDOMBreakpoint",
2242 | "parameters": [
2243 | {
2244 | "name": "nodeId",
2245 | "$ref": "DOM.NodeId",
2246 | "description": "Identifier of the node to remove breakpoint from."
2247 | },
2248 | {
2249 | "name": "type",
2250 | "$ref": "DOMBreakpointType",
2251 | "description": "Type of the breakpoint to remove."
2252 | }
2253 | ],
2254 | "description": "Removes DOM breakpoint that was set using setDOMBreakpoint
."
2255 | },
2256 | {
2257 | "name": "setEventListenerBreakpoint",
2258 | "parameters": [
2259 | {
2260 | "name": "eventName",
2261 | "type": "string",
2262 | "description": "DOM Event name to stop on (any DOM event will do)."
2263 | },
2264 | {
2265 | "name": "targetName",
2266 | "type": "string",
2267 | "optional": true,
2268 | "description": "EventTarget interface name to stop on. If equal to \"*\"
or not provided, will stop on any EventTarget.",
2269 | "experimental": true
2270 | }
2271 | ],
2272 | "description": "Sets breakpoint on particular DOM event."
2273 | },
2274 | {
2275 | "name": "removeEventListenerBreakpoint",
2276 | "parameters": [
2277 | {
2278 | "name": "eventName",
2279 | "type": "string",
2280 | "description": "Event name."
2281 | },
2282 | {
2283 | "name": "targetName",
2284 | "type": "string",
2285 | "optional": true,
2286 | "description": "EventTarget interface name.",
2287 | "experimental": true
2288 | }
2289 | ],
2290 | "description": "Removes breakpoint on particular DOM event."
2291 | },
2292 | {
2293 | "name": "setXHRBreakpoint",
2294 | "parameters": [
2295 | {
2296 | "name": "url",
2297 | "type": "string",
2298 | "description": "Resource URL substring. All XHRs having this substring in the URL will get stopped upon."
2299 | }
2300 | ],
2301 | "description": "Sets breakpoint on XMLHttpRequest."
2302 | },
2303 | {
2304 | "name": "removeXHRBreakpoint",
2305 | "parameters": [
2306 | {
2307 | "name": "url",
2308 | "type": "string",
2309 | "description": "Resource URL substring."
2310 | }
2311 | ],
2312 | "description": "Removes breakpoint from XMLHttpRequest."
2313 | }
2314 | ]
2315 | },
2316 | {
2317 | "domain": "Input",
2318 | "types": [],
2319 | "commands": [
2320 | {
2321 | "name": "dispatchKeyEvent",
2322 | "parameters": [
2323 | {
2324 | "name": "type",
2325 | "type": "string",
2326 | "enum": [
2327 | "keyDown",
2328 | "keyUp",
2329 | "rawKeyDown",
2330 | "char"
2331 | ],
2332 | "description": "Type of the key event."
2333 | },
2334 | {
2335 | "name": "modifiers",
2336 | "type": "integer",
2337 | "optional": true,
2338 | "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0)."
2339 | },
2340 | {
2341 | "name": "timestamp",
2342 | "type": "number",
2343 | "optional": true,
2344 | "description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)."
2345 | },
2346 | {
2347 | "name": "text",
2348 | "type": "string",
2349 | "optional": true,
2350 | "description": "Text as generated by processing a virtual key code with a keyboard layout. Not needed for for keyUp
and rawKeyDown
events (default: \"\")"
2351 | },
2352 | {
2353 | "name": "unmodifiedText",
2354 | "type": "string",
2355 | "optional": true,
2356 | "description": "Text that would have been generated by the keyboard if no modifiers were pressed (except for shift). Useful for shortcut (accelerator) key handling (default: \"\")."
2357 | },
2358 | {
2359 | "name": "keyIdentifier",
2360 | "type": "string",
2361 | "optional": true,
2362 | "description": "Unique key identifier (e.g., 'U+0041') (default: \"\")."
2363 | },
2364 | {
2365 | "name": "code",
2366 | "type": "string",
2367 | "optional": true,
2368 | "description": "Unique DOM defined string value for each physical key (e.g., 'KeyA') (default: \"\")."
2369 | },
2370 | {
2371 | "name": "key",
2372 | "type": "string",
2373 | "optional": true,
2374 | "description": "Unique DOM defined string value describing the meaning of the key in the context of active modifiers, keyboard layout, etc (e.g., 'AltGr') (default: \"\")."
2375 | },
2376 | {
2377 | "name": "windowsVirtualKeyCode",
2378 | "type": "integer",
2379 | "optional": true,
2380 | "description": "Windows virtual key code (default: 0)."
2381 | },
2382 | {
2383 | "name": "nativeVirtualKeyCode",
2384 | "type": "integer",
2385 | "optional": true,
2386 | "description": "Native virtual key code (default: 0)."
2387 | },
2388 | {
2389 | "name": "autoRepeat",
2390 | "type": "boolean",
2391 | "optional": true,
2392 | "description": "Whether the event was generated from auto repeat (default: false)."
2393 | },
2394 | {
2395 | "name": "isKeypad",
2396 | "type": "boolean",
2397 | "optional": true,
2398 | "description": "Whether the event was generated from the keypad (default: false)."
2399 | },
2400 | {
2401 | "name": "isSystemKey",
2402 | "type": "boolean",
2403 | "optional": true,
2404 | "description": "Whether the event was a system key event (default: false)."
2405 | }
2406 | ],
2407 | "description": "Dispatches a key event to the page.",
2408 | "handlers": [
2409 | "browser"
2410 | ]
2411 | },
2412 | {
2413 | "name": "dispatchMouseEvent",
2414 | "parameters": [
2415 | {
2416 | "name": "type",
2417 | "type": "string",
2418 | "enum": [
2419 | "mousePressed",
2420 | "mouseReleased",
2421 | "mouseMoved"
2422 | ],
2423 | "description": "Type of the mouse event."
2424 | },
2425 | {
2426 | "name": "x",
2427 | "type": "integer",
2428 | "description": "X coordinate of the event relative to the main frame's viewport."
2429 | },
2430 | {
2431 | "name": "y",
2432 | "type": "integer",
2433 | "description": "Y coordinate of the event relative to the main frame's viewport. 0 refers to the top of the viewport and Y increases as it proceeds towards the bottom of the viewport."
2434 | },
2435 | {
2436 | "name": "modifiers",
2437 | "type": "integer",
2438 | "optional": true,
2439 | "description": "Bit field representing pressed modifier keys. Alt=1, Ctrl=2, Meta/Command=4, Shift=8 (default: 0)."
2440 | },
2441 | {
2442 | "name": "timestamp",
2443 | "type": "number",
2444 | "optional": true,
2445 | "description": "Time at which the event occurred. Measured in UTC time in seconds since January 1, 1970 (default: current time)."
2446 | },
2447 | {
2448 | "name": "button",
2449 | "type": "string",
2450 | "enum": [
2451 | "none",
2452 | "left",
2453 | "middle",
2454 | "right"
2455 | ],
2456 | "optional": true,
2457 | "description": "Mouse button (default: \"none\")."
2458 | },
2459 | {
2460 | "name": "clickCount",
2461 | "type": "integer",
2462 | "optional": true,
2463 | "description": "Number of times the mouse button was clicked (default: 0)."
2464 | }
2465 | ],
2466 | "description": "Dispatches a mouse event to the page.",
2467 | "handlers": [
2468 | "browser"
2469 | ]
2470 | }
2471 | ],
2472 | "events": []
2473 | },
2474 | {
2475 | "domain": "Schema",
2476 | "description": "Provides information about the protocol schema.",
2477 | "types": [
2478 | {
2479 | "id": "Domain",
2480 | "type": "object",
2481 | "description": "Description of the protocol domain.",
2482 | "exported": true,
2483 | "properties": [
2484 | {
2485 | "name": "name",
2486 | "type": "string",
2487 | "description": "Domain name."
2488 | },
2489 | {
2490 | "name": "version",
2491 | "type": "string",
2492 | "description": "Domain version."
2493 | }
2494 | ]
2495 | }
2496 | ],
2497 | "commands": [
2498 | {
2499 | "name": "getDomains",
2500 | "description": "Returns supported domains.",
2501 | "handlers": [
2502 | "browser",
2503 | "renderer"
2504 | ],
2505 | "returns": [
2506 | {
2507 | "name": "domains",
2508 | "type": "array",
2509 | "items": {
2510 | "$ref": "Domain"
2511 | },
2512 | "description": "List of supported domains."
2513 | }
2514 | ]
2515 | }
2516 | ]
2517 | },
2518 | {
2519 | "domain": "Runtime",
2520 | "description": "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.",
2521 | "types": [
2522 | {
2523 | "id": "ScriptId",
2524 | "type": "string",
2525 | "description": "Unique script identifier."
2526 | },
2527 | {
2528 | "id": "RemoteObjectId",
2529 | "type": "string",
2530 | "description": "Unique object identifier."
2531 | },
2532 | {
2533 | "id": "UnserializableValue",
2534 | "type": "string",
2535 | "enum": [
2536 | "Infinity",
2537 | "NaN",
2538 | "-Infinity",
2539 | "-0"
2540 | ],
2541 | "description": "Primitive value which cannot be JSON-stringified."
2542 | },
2543 | {
2544 | "id": "RemoteObject",
2545 | "type": "object",
2546 | "description": "Mirror object referencing original JavaScript object.",
2547 | "exported": true,
2548 | "properties": [
2549 | {
2550 | "name": "type",
2551 | "type": "string",
2552 | "enum": [
2553 | "object",
2554 | "function",
2555 | "undefined",
2556 | "string",
2557 | "number",
2558 | "boolean",
2559 | "symbol"
2560 | ],
2561 | "description": "Object type."
2562 | },
2563 | {
2564 | "name": "subtype",
2565 | "type": "string",
2566 | "optional": true,
2567 | "enum": [
2568 | "array",
2569 | "null",
2570 | "node",
2571 | "regexp",
2572 | "date",
2573 | "map",
2574 | "set",
2575 | "iterator",
2576 | "generator",
2577 | "error",
2578 | "proxy",
2579 | "promise",
2580 | "typedarray"
2581 | ],
2582 | "description": "Object subtype hint. Specified for object
type values only."
2583 | },
2584 | {
2585 | "name": "className",
2586 | "type": "string",
2587 | "optional": true,
2588 | "description": "Object class (constructor) name. Specified for object
type values only."
2589 | },
2590 | {
2591 | "name": "value",
2592 | "type": "any",
2593 | "optional": true,
2594 | "description": "Remote object value in case of primitive values or JSON values (if it was requested)."
2595 | },
2596 | {
2597 | "name": "unserializableValue",
2598 | "$ref": "UnserializableValue",
2599 | "optional": true,
2600 | "description": "Primitive value which can not be JSON-stringified does not have value
, but gets this property."
2601 | },
2602 | {
2603 | "name": "description",
2604 | "type": "string",
2605 | "optional": true,
2606 | "description": "String representation of the object."
2607 | },
2608 | {
2609 | "name": "objectId",
2610 | "$ref": "RemoteObjectId",
2611 | "optional": true,
2612 | "description": "Unique object identifier (for non-primitive values)."
2613 | },
2614 | {
2615 | "name": "preview",
2616 | "$ref": "ObjectPreview",
2617 | "optional": true,
2618 | "description": "Preview containing abbreviated property values. Specified for object
type values only.",
2619 | "experimental": true
2620 | },
2621 | {
2622 | "name": "customPreview",
2623 | "$ref": "CustomPreview",
2624 | "optional": true,
2625 | "experimental": true
2626 | }
2627 | ]
2628 | },
2629 | {
2630 | "id": "PropertyDescriptor",
2631 | "type": "object",
2632 | "description": "Object property descriptor.",
2633 | "properties": [
2634 | {
2635 | "name": "name",
2636 | "type": "string",
2637 | "description": "Property name or symbol description."
2638 | },
2639 | {
2640 | "name": "value",
2641 | "$ref": "RemoteObject",
2642 | "optional": true,
2643 | "description": "The value associated with the property."
2644 | },
2645 | {
2646 | "name": "writable",
2647 | "type": "boolean",
2648 | "optional": true,
2649 | "description": "True if the value associated with the property may be changed (data descriptors only)."
2650 | },
2651 | {
2652 | "name": "get",
2653 | "$ref": "RemoteObject",
2654 | "optional": true,
2655 | "description": "A function which serves as a getter for the property, or undefined
if there is no getter (accessor descriptors only)."
2656 | },
2657 | {
2658 | "name": "set",
2659 | "$ref": "RemoteObject",
2660 | "optional": true,
2661 | "description": "A function which serves as a setter for the property, or undefined
if there is no setter (accessor descriptors only)."
2662 | },
2663 | {
2664 | "name": "configurable",
2665 | "type": "boolean",
2666 | "description": "True if the type of this property descriptor may be changed and if the property may be deleted from the corresponding object."
2667 | },
2668 | {
2669 | "name": "enumerable",
2670 | "type": "boolean",
2671 | "description": "True if this property shows up during enumeration of the properties on the corresponding object."
2672 | },
2673 | {
2674 | "name": "wasThrown",
2675 | "type": "boolean",
2676 | "optional": true,
2677 | "description": "True if the result was thrown during the evaluation."
2678 | },
2679 | {
2680 | "name": "isOwn",
2681 | "optional": true,
2682 | "type": "boolean",
2683 | "description": "True if the property is owned for the object."
2684 | },
2685 | {
2686 | "name": "symbol",
2687 | "$ref": "RemoteObject",
2688 | "optional": true,
2689 | "description": "Property symbol object, if the property is of the symbol
type."
2690 | }
2691 | ]
2692 | },
2693 | {
2694 | "id": "InternalPropertyDescriptor",
2695 | "type": "object",
2696 | "description": "Object internal property descriptor. This property isn't normally visible in JavaScript code.",
2697 | "properties": [
2698 | {
2699 | "name": "name",
2700 | "type": "string",
2701 | "description": "Conventional property name."
2702 | },
2703 | {
2704 | "name": "value",
2705 | "$ref": "RemoteObject",
2706 | "optional": true,
2707 | "description": "The value associated with the property."
2708 | }
2709 | ]
2710 | },
2711 | {
2712 | "id": "CallArgument",
2713 | "type": "object",
2714 | "description": "Represents function call argument. Either remote object id objectId
, primitive value
, unserializable primitive value or neither of (for undefined) them should be specified.",
2715 | "properties": [
2716 | {
2717 | "name": "value",
2718 | "type": "any",
2719 | "optional": true,
2720 | "description": "Primitive value."
2721 | },
2722 | {
2723 | "name": "unserializableValue",
2724 | "$ref": "UnserializableValue",
2725 | "optional": true,
2726 | "description": "Primitive value which can not be JSON-stringified."
2727 | },
2728 | {
2729 | "name": "objectId",
2730 | "$ref": "RemoteObjectId",
2731 | "optional": true,
2732 | "description": "Remote object handle."
2733 | }
2734 | ]
2735 | },
2736 | {
2737 | "id": "ExecutionContextId",
2738 | "type": "integer",
2739 | "description": "Id of an execution context."
2740 | },
2741 | {
2742 | "id": "ExecutionContextDescription",
2743 | "type": "object",
2744 | "description": "Description of an isolated world.",
2745 | "properties": [
2746 | {
2747 | "name": "id",
2748 | "$ref": "ExecutionContextId",
2749 | "description": "Unique id of the execution context. It can be used to specify in which execution context script evaluation should be performed."
2750 | },
2751 | {
2752 | "name": "origin",
2753 | "type": "string",
2754 | "description": "Execution context origin."
2755 | },
2756 | {
2757 | "name": "name",
2758 | "type": "string",
2759 | "description": "Human readable name describing given context."
2760 | },
2761 | {
2762 | "name": "auxData",
2763 | "type": "object",
2764 | "optional": true,
2765 | "description": "Embedder-specific auxiliary data."
2766 | }
2767 | ]
2768 | },
2769 | {
2770 | "id": "ExceptionDetails",
2771 | "type": "object",
2772 | "description": "Detailed information about exception (or error) that was thrown during script compilation or execution.",
2773 | "properties": [
2774 | {
2775 | "name": "exceptionId",
2776 | "type": "integer",
2777 | "description": "Exception id."
2778 | },
2779 | {
2780 | "name": "text",
2781 | "type": "string",
2782 | "description": "Exception text, which should be used together with exception object when available."
2783 | },
2784 | {
2785 | "name": "lineNumber",
2786 | "type": "integer",
2787 | "description": "Line number of the exception location (0-based)."
2788 | },
2789 | {
2790 | "name": "columnNumber",
2791 | "type": "integer",
2792 | "description": "Column number of the exception location (0-based)."
2793 | },
2794 | {
2795 | "name": "scriptId",
2796 | "$ref": "ScriptId",
2797 | "optional": true,
2798 | "description": "Script ID of the exception location."
2799 | },
2800 | {
2801 | "name": "url",
2802 | "type": "string",
2803 | "optional": true,
2804 | "description": "URL of the exception location, to be used when the script was not reported."
2805 | },
2806 | {
2807 | "name": "stackTrace",
2808 | "$ref": "StackTrace",
2809 | "optional": true,
2810 | "description": "JavaScript stack trace if available."
2811 | },
2812 | {
2813 | "name": "exception",
2814 | "$ref": "RemoteObject",
2815 | "optional": true,
2816 | "description": "Exception object if available."
2817 | },
2818 | {
2819 | "name": "executionContextId",
2820 | "$ref": "ExecutionContextId",
2821 | "optional": true,
2822 | "description": "Identifier of the context where exception happened."
2823 | }
2824 | ]
2825 | },
2826 | {
2827 | "id": "Timestamp",
2828 | "type": "number",
2829 | "description": "Number of milliseconds since epoch."
2830 | },
2831 | {
2832 | "id": "CallFrame",
2833 | "type": "object",
2834 | "description": "Stack entry for runtime errors and assertions.",
2835 | "properties": [
2836 | {
2837 | "name": "functionName",
2838 | "type": "string",
2839 | "description": "JavaScript function name."
2840 | },
2841 | {
2842 | "name": "scriptId",
2843 | "$ref": "ScriptId",
2844 | "description": "JavaScript script id."
2845 | },
2846 | {
2847 | "name": "url",
2848 | "type": "string",
2849 | "description": "JavaScript script name or url."
2850 | },
2851 | {
2852 | "name": "lineNumber",
2853 | "type": "integer",
2854 | "description": "JavaScript script line number (0-based)."
2855 | },
2856 | {
2857 | "name": "columnNumber",
2858 | "type": "integer",
2859 | "description": "JavaScript script column number (0-based)."
2860 | }
2861 | ]
2862 | },
2863 | {
2864 | "id": "StackTrace",
2865 | "type": "object",
2866 | "description": "Call frames for assertions or error messages.",
2867 | "exported": true,
2868 | "properties": [
2869 | {
2870 | "name": "description",
2871 | "type": "string",
2872 | "optional": true,
2873 | "description": "String label of this stack trace. For async traces this may be a name of the function that initiated the async call."
2874 | },
2875 | {
2876 | "name": "callFrames",
2877 | "type": "array",
2878 | "items": {
2879 | "$ref": "CallFrame"
2880 | },
2881 | "description": "JavaScript function name."
2882 | },
2883 | {
2884 | "name": "parent",
2885 | "$ref": "StackTrace",
2886 | "optional": true,
2887 | "description": "Asynchronous JavaScript stack trace that preceded this stack, if available."
2888 | }
2889 | ]
2890 | }
2891 | ],
2892 | "commands": [
2893 | {
2894 | "name": "evaluate",
2895 | "async": true,
2896 | "parameters": [
2897 | {
2898 | "name": "expression",
2899 | "type": "string",
2900 | "description": "Expression to evaluate."
2901 | },
2902 | {
2903 | "name": "objectGroup",
2904 | "type": "string",
2905 | "optional": true,
2906 | "description": "Symbolic group name that can be used to release multiple objects."
2907 | },
2908 | {
2909 | "name": "includeCommandLineAPI",
2910 | "type": "boolean",
2911 | "optional": true,
2912 | "description": "Determines whether Command Line API should be available during the evaluation."
2913 | },
2914 | {
2915 | "name": "silent",
2916 | "type": "boolean",
2917 | "optional": true,
2918 | "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException
state."
2919 | },
2920 | {
2921 | "name": "contextId",
2922 | "$ref": "ExecutionContextId",
2923 | "optional": true,
2924 | "description": "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."
2925 | },
2926 | {
2927 | "name": "returnByValue",
2928 | "type": "boolean",
2929 | "optional": true,
2930 | "description": "Whether the result is expected to be a JSON object that should be sent by value."
2931 | },
2932 | {
2933 | "name": "generatePreview",
2934 | "type": "boolean",
2935 | "optional": true,
2936 | "experimental": true,
2937 | "description": "Whether preview should be generated for the result."
2938 | },
2939 | {
2940 | "name": "userGesture",
2941 | "type": "boolean",
2942 | "optional": true,
2943 | "experimental": true,
2944 | "description": "Whether execution should be treated as initiated by user in the UI."
2945 | },
2946 | {
2947 | "name": "awaitPromise",
2948 | "type": "boolean",
2949 | "optional": true,
2950 | "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error."
2951 | }
2952 | ],
2953 | "returns": [
2954 | {
2955 | "name": "result",
2956 | "$ref": "RemoteObject",
2957 | "description": "Evaluation result."
2958 | },
2959 | {
2960 | "name": "exceptionDetails",
2961 | "$ref": "ExceptionDetails",
2962 | "optional": true,
2963 | "description": "Exception details."
2964 | }
2965 | ],
2966 | "description": "Evaluates expression on global object."
2967 | },
2968 | {
2969 | "name": "awaitPromise",
2970 | "async": true,
2971 | "parameters": [
2972 | {
2973 | "name": "promiseObjectId",
2974 | "$ref": "RemoteObjectId",
2975 | "description": "Identifier of the promise."
2976 | },
2977 | {
2978 | "name": "returnByValue",
2979 | "type": "boolean",
2980 | "optional": true,
2981 | "description": "Whether the result is expected to be a JSON object that should be sent by value."
2982 | },
2983 | {
2984 | "name": "generatePreview",
2985 | "type": "boolean",
2986 | "optional": true,
2987 | "description": "Whether preview should be generated for the result."
2988 | }
2989 | ],
2990 | "returns": [
2991 | {
2992 | "name": "result",
2993 | "$ref": "RemoteObject",
2994 | "description": "Promise result. Will contain rejected value if promise was rejected."
2995 | },
2996 | {
2997 | "name": "exceptionDetails",
2998 | "$ref": "ExceptionDetails",
2999 | "optional": true,
3000 | "description": "Exception details if stack strace is available."
3001 | }
3002 | ],
3003 | "description": "Add handler to promise with given promise object id."
3004 | },
3005 | {
3006 | "name": "callFunctionOn",
3007 | "async": true,
3008 | "parameters": [
3009 | {
3010 | "name": "objectId",
3011 | "$ref": "RemoteObjectId",
3012 | "description": "Identifier of the object to call function on."
3013 | },
3014 | {
3015 | "name": "functionDeclaration",
3016 | "type": "string",
3017 | "description": "Declaration of the function to call."
3018 | },
3019 | {
3020 | "name": "arguments",
3021 | "type": "array",
3022 | "items": {
3023 | "$ref": "CallArgument",
3024 | "description": "Call argument."
3025 | },
3026 | "optional": true,
3027 | "description": "Call arguments. All call arguments must belong to the same JavaScript world as the target object."
3028 | },
3029 | {
3030 | "name": "silent",
3031 | "type": "boolean",
3032 | "optional": true,
3033 | "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException
state."
3034 | },
3035 | {
3036 | "name": "returnByValue",
3037 | "type": "boolean",
3038 | "optional": true,
3039 | "description": "Whether the result is expected to be a JSON object which should be sent by value."
3040 | },
3041 | {
3042 | "name": "generatePreview",
3043 | "type": "boolean",
3044 | "optional": true,
3045 | "experimental": true,
3046 | "description": "Whether preview should be generated for the result."
3047 | },
3048 | {
3049 | "name": "userGesture",
3050 | "type": "boolean",
3051 | "optional": true,
3052 | "experimental": true,
3053 | "description": "Whether execution should be treated as initiated by user in the UI."
3054 | },
3055 | {
3056 | "name": "awaitPromise",
3057 | "type": "boolean",
3058 | "optional": true,
3059 | "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error."
3060 | }
3061 | ],
3062 | "returns": [
3063 | {
3064 | "name": "result",
3065 | "$ref": "RemoteObject",
3066 | "description": "Call result."
3067 | },
3068 | {
3069 | "name": "exceptionDetails",
3070 | "$ref": "ExceptionDetails",
3071 | "optional": true,
3072 | "description": "Exception details."
3073 | }
3074 | ],
3075 | "description": "Calls function with given declaration on the given object. Object group of the result is inherited from the target object."
3076 | },
3077 | {
3078 | "name": "getProperties",
3079 | "parameters": [
3080 | {
3081 | "name": "objectId",
3082 | "$ref": "RemoteObjectId",
3083 | "description": "Identifier of the object to return properties for."
3084 | },
3085 | {
3086 | "name": "ownProperties",
3087 | "optional": true,
3088 | "type": "boolean",
3089 | "description": "If true, returns properties belonging only to the element itself, not to its prototype chain."
3090 | },
3091 | {
3092 | "name": "accessorPropertiesOnly",
3093 | "optional": true,
3094 | "type": "boolean",
3095 | "description": "If true, returns accessor properties (with getter/setter) only; internal properties are not returned either.",
3096 | "experimental": true
3097 | },
3098 | {
3099 | "name": "generatePreview",
3100 | "type": "boolean",
3101 | "optional": true,
3102 | "experimental": true,
3103 | "description": "Whether preview should be generated for the results."
3104 | }
3105 | ],
3106 | "returns": [
3107 | {
3108 | "name": "result",
3109 | "type": "array",
3110 | "items": {
3111 | "$ref": "PropertyDescriptor"
3112 | },
3113 | "description": "Object properties."
3114 | },
3115 | {
3116 | "name": "internalProperties",
3117 | "optional": true,
3118 | "type": "array",
3119 | "items": {
3120 | "$ref": "InternalPropertyDescriptor"
3121 | },
3122 | "description": "Internal object properties (only of the element itself)."
3123 | },
3124 | {
3125 | "name": "exceptionDetails",
3126 | "$ref": "ExceptionDetails",
3127 | "optional": true,
3128 | "description": "Exception details."
3129 | }
3130 | ],
3131 | "description": "Returns properties of a given object. Object group of the result is inherited from the target object."
3132 | },
3133 | {
3134 | "name": "releaseObject",
3135 | "parameters": [
3136 | {
3137 | "name": "objectId",
3138 | "$ref": "RemoteObjectId",
3139 | "description": "Identifier of the object to release."
3140 | }
3141 | ],
3142 | "description": "Releases remote object with given id."
3143 | },
3144 | {
3145 | "name": "releaseObjectGroup",
3146 | "parameters": [
3147 | {
3148 | "name": "objectGroup",
3149 | "type": "string",
3150 | "description": "Symbolic object group name."
3151 | }
3152 | ],
3153 | "description": "Releases all remote objects that belong to a given group."
3154 | },
3155 | {
3156 | "name": "runIfWaitingForDebugger",
3157 | "description": "Tells inspected instance to run if it was waiting for debugger to attach."
3158 | },
3159 | {
3160 | "name": "enable",
3161 | "description": "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."
3162 | },
3163 | {
3164 | "name": "disable",
3165 | "description": "Disables reporting of execution contexts creation."
3166 | },
3167 | {
3168 | "name": "discardConsoleEntries",
3169 | "description": "Discards collected exceptions and console API calls."
3170 | },
3171 | {
3172 | "name": "compileScript",
3173 | "parameters": [
3174 | {
3175 | "name": "expression",
3176 | "type": "string",
3177 | "description": "Expression to compile."
3178 | },
3179 | {
3180 | "name": "sourceURL",
3181 | "type": "string",
3182 | "description": "Source url to be set for the script."
3183 | },
3184 | {
3185 | "name": "persistScript",
3186 | "type": "boolean",
3187 | "description": "Specifies whether the compiled script should be persisted."
3188 | },
3189 | {
3190 | "name": "executionContextId",
3191 | "$ref": "ExecutionContextId",
3192 | "optional": true,
3193 | "description": "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."
3194 | }
3195 | ],
3196 | "returns": [
3197 | {
3198 | "name": "scriptId",
3199 | "$ref": "ScriptId",
3200 | "optional": true,
3201 | "description": "Id of the script."
3202 | },
3203 | {
3204 | "name": "exceptionDetails",
3205 | "$ref": "ExceptionDetails",
3206 | "optional": true,
3207 | "description": "Exception details."
3208 | }
3209 | ],
3210 | "description": "Compiles expression."
3211 | },
3212 | {
3213 | "name": "runScript",
3214 | "async": true,
3215 | "parameters": [
3216 | {
3217 | "name": "scriptId",
3218 | "$ref": "ScriptId",
3219 | "description": "Id of the script to run."
3220 | },
3221 | {
3222 | "name": "executionContextId",
3223 | "$ref": "ExecutionContextId",
3224 | "optional": true,
3225 | "description": "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."
3226 | },
3227 | {
3228 | "name": "objectGroup",
3229 | "type": "string",
3230 | "optional": true,
3231 | "description": "Symbolic group name that can be used to release multiple objects."
3232 | },
3233 | {
3234 | "name": "silent",
3235 | "type": "boolean",
3236 | "optional": true,
3237 | "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException
state."
3238 | },
3239 | {
3240 | "name": "includeCommandLineAPI",
3241 | "type": "boolean",
3242 | "optional": true,
3243 | "description": "Determines whether Command Line API should be available during the evaluation."
3244 | },
3245 | {
3246 | "name": "returnByValue",
3247 | "type": "boolean",
3248 | "optional": true,
3249 | "description": "Whether the result is expected to be a JSON object which should be sent by value."
3250 | },
3251 | {
3252 | "name": "generatePreview",
3253 | "type": "boolean",
3254 | "optional": true,
3255 | "description": "Whether preview should be generated for the result."
3256 | },
3257 | {
3258 | "name": "awaitPromise",
3259 | "type": "boolean",
3260 | "optional": true,
3261 | "description": "Whether execution should wait for promise to be resolved. If the result of evaluation is not a Promise, it's considered to be an error."
3262 | }
3263 | ],
3264 | "returns": [
3265 | {
3266 | "name": "result",
3267 | "$ref": "RemoteObject",
3268 | "description": "Run result."
3269 | },
3270 | {
3271 | "name": "exceptionDetails",
3272 | "$ref": "ExceptionDetails",
3273 | "optional": true,
3274 | "description": "Exception details."
3275 | }
3276 | ],
3277 | "description": "Runs script with given id in a given context."
3278 | }
3279 | ],
3280 | "events": [
3281 | {
3282 | "name": "executionContextCreated",
3283 | "parameters": [
3284 | {
3285 | "name": "context",
3286 | "$ref": "ExecutionContextDescription",
3287 | "description": "A newly created execution contex."
3288 | }
3289 | ],
3290 | "description": "Issued when new execution context is created."
3291 | },
3292 | {
3293 | "name": "executionContextDestroyed",
3294 | "parameters": [
3295 | {
3296 | "name": "executionContextId",
3297 | "$ref": "ExecutionContextId",
3298 | "description": "Id of the destroyed context"
3299 | }
3300 | ],
3301 | "description": "Issued when execution context is destroyed."
3302 | },
3303 | {
3304 | "name": "executionContextsCleared",
3305 | "description": "Issued when all executionContexts were cleared in browser"
3306 | },
3307 | {
3308 | "name": "exceptionThrown",
3309 | "description": "Issued when exception was thrown and unhandled.",
3310 | "parameters": [
3311 | {
3312 | "name": "timestamp",
3313 | "$ref": "Timestamp",
3314 | "description": "Timestamp of the exception."
3315 | },
3316 | {
3317 | "name": "exceptionDetails",
3318 | "$ref": "ExceptionDetails"
3319 | }
3320 | ]
3321 | },
3322 | {
3323 | "name": "exceptionRevoked",
3324 | "description": "Issued when unhandled exception was revoked.",
3325 | "parameters": [
3326 | {
3327 | "name": "reason",
3328 | "type": "string",
3329 | "description": "Reason describing why exception was revoked."
3330 | },
3331 | {
3332 | "name": "exceptionId",
3333 | "type": "integer",
3334 | "description": "The id of revoked exception, as reported in exceptionUnhandled
."
3335 | }
3336 | ]
3337 | },
3338 | {
3339 | "name": "consoleAPICalled",
3340 | "description": "Issued when console API was called.",
3341 | "parameters": [
3342 | {
3343 | "name": "type",
3344 | "type": "string",
3345 | "enum": [
3346 | "log",
3347 | "debug",
3348 | "info",
3349 | "error",
3350 | "warning",
3351 | "dir",
3352 | "dirxml",
3353 | "table",
3354 | "trace",
3355 | "clear",
3356 | "startGroup",
3357 | "startGroupCollapsed",
3358 | "endGroup",
3359 | "assert",
3360 | "profile",
3361 | "profileEnd"
3362 | ],
3363 | "description": "Type of the call."
3364 | },
3365 | {
3366 | "name": "args",
3367 | "type": "array",
3368 | "items": {
3369 | "$ref": "RemoteObject"
3370 | },
3371 | "description": "Call arguments."
3372 | },
3373 | {
3374 | "name": "executionContextId",
3375 | "$ref": "ExecutionContextId",
3376 | "description": "Identifier of the context where the call was made."
3377 | },
3378 | {
3379 | "name": "timestamp",
3380 | "$ref": "Timestamp",
3381 | "description": "Call timestamp."
3382 | },
3383 | {
3384 | "name": "stackTrace",
3385 | "$ref": "StackTrace",
3386 | "optional": true,
3387 | "description": "Stack trace captured when the call was made."
3388 | }
3389 | ]
3390 | },
3391 | {
3392 | "name": "inspectRequested",
3393 | "description": "Issued when object should be inspected (for example, as a result of inspect() command line API call).",
3394 | "parameters": [
3395 | {
3396 | "name": "object",
3397 | "$ref": "RemoteObject"
3398 | },
3399 | {
3400 | "name": "hints",
3401 | "type": "object"
3402 | }
3403 | ]
3404 | }
3405 | ]
3406 | },
3407 | {
3408 | "domain": "Debugger",
3409 | "description": "Debugger domain exposes JavaScript debugging capabilities. It allows setting and removing breakpoints, stepping through execution, exploring stack traces, etc.",
3410 | "dependencies": [
3411 | "Runtime"
3412 | ],
3413 | "types": [
3414 | {
3415 | "id": "BreakpointId",
3416 | "type": "string",
3417 | "description": "Breakpoint identifier."
3418 | },
3419 | {
3420 | "id": "CallFrameId",
3421 | "type": "string",
3422 | "description": "Call frame identifier."
3423 | },
3424 | {
3425 | "id": "Location",
3426 | "type": "object",
3427 | "properties": [
3428 | {
3429 | "name": "scriptId",
3430 | "$ref": "Runtime.ScriptId",
3431 | "description": "Script identifier as reported in the Debugger.scriptParsed
."
3432 | },
3433 | {
3434 | "name": "lineNumber",
3435 | "type": "integer",
3436 | "description": "Line number in the script (0-based)."
3437 | },
3438 | {
3439 | "name": "columnNumber",
3440 | "type": "integer",
3441 | "optional": true,
3442 | "description": "Column number in the script (0-based)."
3443 | }
3444 | ],
3445 | "description": "Location in the source code."
3446 | },
3447 | {
3448 | "id": "CallFrame",
3449 | "type": "object",
3450 | "properties": [
3451 | {
3452 | "name": "callFrameId",
3453 | "$ref": "CallFrameId",
3454 | "description": "Call frame identifier. This identifier is only valid while the virtual machine is paused."
3455 | },
3456 | {
3457 | "name": "functionName",
3458 | "type": "string",
3459 | "description": "Name of the JavaScript function called on this call frame."
3460 | },
3461 | {
3462 | "name": "functionLocation",
3463 | "$ref": "Location",
3464 | "optional": true,
3465 | "experimental": true,
3466 | "description": "Location in the source code."
3467 | },
3468 | {
3469 | "name": "location",
3470 | "$ref": "Location",
3471 | "description": "Location in the source code."
3472 | },
3473 | {
3474 | "name": "scopeChain",
3475 | "type": "array",
3476 | "items": {
3477 | "$ref": "Scope"
3478 | },
3479 | "description": "Scope chain for this call frame."
3480 | },
3481 | {
3482 | "name": "this",
3483 | "$ref": "Runtime.RemoteObject",
3484 | "description": "this
object for this call frame."
3485 | },
3486 | {
3487 | "name": "returnValue",
3488 | "$ref": "Runtime.RemoteObject",
3489 | "optional": true,
3490 | "description": "The value being returned, if the function is at return point."
3491 | }
3492 | ],
3493 | "description": "JavaScript call frame. Array of call frames form the call stack."
3494 | },
3495 | {
3496 | "id": "Scope",
3497 | "type": "object",
3498 | "properties": [
3499 | {
3500 | "name": "type",
3501 | "type": "string",
3502 | "enum": [
3503 | "global",
3504 | "local",
3505 | "with",
3506 | "closure",
3507 | "catch",
3508 | "block",
3509 | "script"
3510 | ],
3511 | "description": "Scope type."
3512 | },
3513 | {
3514 | "name": "object",
3515 | "$ref": "Runtime.RemoteObject",
3516 | "description": "Object representing the scope. For global
and with
scopes it represents the actual object; for the rest of the scopes, it is artificial transient object enumerating scope variables as its properties."
3517 | },
3518 | {
3519 | "name": "name",
3520 | "type": "string",
3521 | "optional": true
3522 | },
3523 | {
3524 | "name": "startLocation",
3525 | "$ref": "Location",
3526 | "optional": true,
3527 | "description": "Location in the source code where scope starts"
3528 | },
3529 | {
3530 | "name": "endLocation",
3531 | "$ref": "Location",
3532 | "optional": true,
3533 | "description": "Location in the source code where scope ends"
3534 | }
3535 | ],
3536 | "description": "Scope description."
3537 | }
3538 | ],
3539 | "commands": [
3540 | {
3541 | "name": "enable",
3542 | "description": "Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received."
3543 | },
3544 | {
3545 | "name": "disable",
3546 | "description": "Disables debugger for given page."
3547 | },
3548 | {
3549 | "name": "setBreakpointsActive",
3550 | "parameters": [
3551 | {
3552 | "name": "active",
3553 | "type": "boolean",
3554 | "description": "New value for breakpoints active state."
3555 | }
3556 | ],
3557 | "description": "Activates / deactivates all breakpoints on the page."
3558 | },
3559 | {
3560 | "name": "setSkipAllPauses",
3561 | "parameters": [
3562 | {
3563 | "name": "skip",
3564 | "type": "boolean",
3565 | "description": "New value for skip pauses state."
3566 | }
3567 | ],
3568 | "description": "Makes page not interrupt on any pauses (breakpoint, exception, dom exception etc)."
3569 | },
3570 | {
3571 | "name": "setBreakpointByUrl",
3572 | "parameters": [
3573 | {
3574 | "name": "lineNumber",
3575 | "type": "integer",
3576 | "description": "Line number to set breakpoint at."
3577 | },
3578 | {
3579 | "name": "url",
3580 | "type": "string",
3581 | "optional": true,
3582 | "description": "URL of the resources to set breakpoint on."
3583 | },
3584 | {
3585 | "name": "urlRegex",
3586 | "type": "string",
3587 | "optional": true,
3588 | "description": "Regex pattern for the URLs of the resources to set breakpoints on. Either url
or urlRegex
must be specified."
3589 | },
3590 | {
3591 | "name": "columnNumber",
3592 | "type": "integer",
3593 | "optional": true,
3594 | "description": "Offset in the line to set breakpoint at."
3595 | },
3596 | {
3597 | "name": "condition",
3598 | "type": "string",
3599 | "optional": true,
3600 | "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true."
3601 | }
3602 | ],
3603 | "returns": [
3604 | {
3605 | "name": "breakpointId",
3606 | "$ref": "BreakpointId",
3607 | "description": "Id of the created breakpoint for further reference."
3608 | },
3609 | {
3610 | "name": "locations",
3611 | "type": "array",
3612 | "items": {
3613 | "$ref": "Location"
3614 | },
3615 | "description": "List of the locations this breakpoint resolved into upon addition."
3616 | }
3617 | ],
3618 | "description": "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."
3619 | },
3620 | {
3621 | "name": "setBreakpoint",
3622 | "parameters": [
3623 | {
3624 | "name": "location",
3625 | "$ref": "Location",
3626 | "description": "Location to set breakpoint in."
3627 | },
3628 | {
3629 | "name": "condition",
3630 | "type": "string",
3631 | "optional": true,
3632 | "description": "Expression to use as a breakpoint condition. When specified, debugger will only stop on the breakpoint if this expression evaluates to true."
3633 | }
3634 | ],
3635 | "returns": [
3636 | {
3637 | "name": "breakpointId",
3638 | "$ref": "BreakpointId",
3639 | "description": "Id of the created breakpoint for further reference."
3640 | },
3641 | {
3642 | "name": "actualLocation",
3643 | "$ref": "Location",
3644 | "description": "Location this breakpoint resolved into."
3645 | }
3646 | ],
3647 | "description": "Sets JavaScript breakpoint at a given location."
3648 | },
3649 | {
3650 | "name": "removeBreakpoint",
3651 | "parameters": [
3652 | {
3653 | "name": "breakpointId",
3654 | "$ref": "BreakpointId"
3655 | }
3656 | ],
3657 | "description": "Removes JavaScript breakpoint."
3658 | },
3659 | {
3660 | "name": "continueToLocation",
3661 | "parameters": [
3662 | {
3663 | "name": "location",
3664 | "$ref": "Location",
3665 | "description": "Location to continue to."
3666 | }
3667 | ],
3668 | "description": "Continues execution until specific location is reached."
3669 | },
3670 | {
3671 | "name": "stepOver",
3672 | "description": "Steps over the statement."
3673 | },
3674 | {
3675 | "name": "stepInto",
3676 | "description": "Steps into the function call."
3677 | },
3678 | {
3679 | "name": "stepOut",
3680 | "description": "Steps out of the function call."
3681 | },
3682 | {
3683 | "name": "pause",
3684 | "description": "Stops on the next JavaScript statement."
3685 | },
3686 | {
3687 | "name": "resume",
3688 | "description": "Resumes JavaScript execution."
3689 | },
3690 | {
3691 | "name": "setScriptSource",
3692 | "parameters": [
3693 | {
3694 | "name": "scriptId",
3695 | "$ref": "Runtime.ScriptId",
3696 | "description": "Id of the script to edit."
3697 | },
3698 | {
3699 | "name": "scriptSource",
3700 | "type": "string",
3701 | "description": "New content of the script."
3702 | },
3703 | {
3704 | "name": "dryRun",
3705 | "type": "boolean",
3706 | "optional": true,
3707 | "description": " If true the change will not actually be applied. Dry run may be used to get result description without actually modifying the code."
3708 | }
3709 | ],
3710 | "returns": [
3711 | {
3712 | "name": "callFrames",
3713 | "type": "array",
3714 | "optional": true,
3715 | "items": {
3716 | "$ref": "CallFrame"
3717 | },
3718 | "description": "New stack trace in case editing has happened while VM was stopped."
3719 | },
3720 | {
3721 | "name": "stackChanged",
3722 | "type": "boolean",
3723 | "optional": true,
3724 | "description": "Whether current call stack was modified after applying the changes."
3725 | },
3726 | {
3727 | "name": "asyncStackTrace",
3728 | "$ref": "Runtime.StackTrace",
3729 | "optional": true,
3730 | "description": "Async stack trace, if any."
3731 | },
3732 | {
3733 | "name": "exceptionDetails",
3734 | "optional": true,
3735 | "$ref": "Runtime.ExceptionDetails",
3736 | "description": "Exception details if any."
3737 | }
3738 | ],
3739 | "description": "Edits JavaScript source live."
3740 | },
3741 | {
3742 | "name": "restartFrame",
3743 | "parameters": [
3744 | {
3745 | "name": "callFrameId",
3746 | "$ref": "CallFrameId",
3747 | "description": "Call frame identifier to evaluate on."
3748 | }
3749 | ],
3750 | "returns": [
3751 | {
3752 | "name": "callFrames",
3753 | "type": "array",
3754 | "items": {
3755 | "$ref": "CallFrame"
3756 | },
3757 | "description": "New stack trace."
3758 | },
3759 | {
3760 | "name": "asyncStackTrace",
3761 | "$ref": "Runtime.StackTrace",
3762 | "optional": true,
3763 | "description": "Async stack trace, if any."
3764 | }
3765 | ],
3766 | "description": "Restarts particular call frame from the beginning."
3767 | },
3768 | {
3769 | "name": "getScriptSource",
3770 | "parameters": [
3771 | {
3772 | "name": "scriptId",
3773 | "$ref": "Runtime.ScriptId",
3774 | "description": "Id of the script to get source for."
3775 | }
3776 | ],
3777 | "returns": [
3778 | {
3779 | "name": "scriptSource",
3780 | "type": "string",
3781 | "description": "Script source."
3782 | }
3783 | ],
3784 | "description": "Returns source for the script with given id."
3785 | },
3786 | {
3787 | "name": "setPauseOnExceptions",
3788 | "parameters": [
3789 | {
3790 | "name": "state",
3791 | "type": "string",
3792 | "enum": [
3793 | "none",
3794 | "uncaught",
3795 | "all"
3796 | ],
3797 | "description": "Pause on exceptions mode."
3798 | }
3799 | ],
3800 | "description": "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
."
3801 | },
3802 | {
3803 | "name": "evaluateOnCallFrame",
3804 | "parameters": [
3805 | {
3806 | "name": "callFrameId",
3807 | "$ref": "CallFrameId",
3808 | "description": "Call frame identifier to evaluate on."
3809 | },
3810 | {
3811 | "name": "expression",
3812 | "type": "string",
3813 | "description": "Expression to evaluate."
3814 | },
3815 | {
3816 | "name": "objectGroup",
3817 | "type": "string",
3818 | "optional": true,
3819 | "description": "String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup
)."
3820 | },
3821 | {
3822 | "name": "includeCommandLineAPI",
3823 | "type": "boolean",
3824 | "optional": true,
3825 | "description": "Specifies whether command line API should be available to the evaluated expression, defaults to false."
3826 | },
3827 | {
3828 | "name": "silent",
3829 | "type": "boolean",
3830 | "optional": true,
3831 | "description": "In silent mode exceptions thrown during evaluation are not reported and do not pause execution. Overrides setPauseOnException
state."
3832 | },
3833 | {
3834 | "name": "returnByValue",
3835 | "type": "boolean",
3836 | "optional": true,
3837 | "description": "Whether the result is expected to be a JSON object that should be sent by value."
3838 | },
3839 | {
3840 | "name": "generatePreview",
3841 | "type": "boolean",
3842 | "optional": true,
3843 | "experimental": true,
3844 | "description": "Whether preview should be generated for the result."
3845 | }
3846 | ],
3847 | "returns": [
3848 | {
3849 | "name": "result",
3850 | "$ref": "Runtime.RemoteObject",
3851 | "description": "Object wrapper for the evaluation result."
3852 | },
3853 | {
3854 | "name": "exceptionDetails",
3855 | "$ref": "Runtime.ExceptionDetails",
3856 | "optional": true,
3857 | "description": "Exception details."
3858 | }
3859 | ],
3860 | "description": "Evaluates expression on a given call frame."
3861 | },
3862 | {
3863 | "name": "setVariableValue",
3864 | "parameters": [
3865 | {
3866 | "name": "scopeNumber",
3867 | "type": "integer",
3868 | "description": "0-based number of scope as was listed in scope chain. Only 'local', 'closure' and 'catch' scope types are allowed. Other scopes could be manipulated manually."
3869 | },
3870 | {
3871 | "name": "variableName",
3872 | "type": "string",
3873 | "description": "Variable name."
3874 | },
3875 | {
3876 | "name": "newValue",
3877 | "$ref": "Runtime.CallArgument",
3878 | "description": "New variable value."
3879 | },
3880 | {
3881 | "name": "callFrameId",
3882 | "$ref": "CallFrameId",
3883 | "description": "Id of callframe that holds variable."
3884 | }
3885 | ],
3886 | "description": "Changes value of variable in a callframe. Object-based scopes are not supported and must be mutated manually."
3887 | },
3888 | {
3889 | "name": "setAsyncCallStackDepth",
3890 | "parameters": [
3891 | {
3892 | "name": "maxDepth",
3893 | "type": "integer",
3894 | "description": "Maximum depth of async call stacks. Setting to 0
will effectively disable collecting async call stacks (default)."
3895 | }
3896 | ],
3897 | "description": "Enables or disables async call stacks tracking."
3898 | }
3899 | ],
3900 | "events": [
3901 | {
3902 | "name": "scriptParsed",
3903 | "parameters": [
3904 | {
3905 | "name": "scriptId",
3906 | "$ref": "Runtime.ScriptId",
3907 | "description": "Identifier of the script parsed."
3908 | },
3909 | {
3910 | "name": "url",
3911 | "type": "string",
3912 | "description": "URL or name of the script parsed (if any)."
3913 | },
3914 | {
3915 | "name": "startLine",
3916 | "type": "integer",
3917 | "description": "Line offset of the script within the resource with given URL (for script tags)."
3918 | },
3919 | {
3920 | "name": "startColumn",
3921 | "type": "integer",
3922 | "description": "Column offset of the script within the resource with given URL."
3923 | },
3924 | {
3925 | "name": "endLine",
3926 | "type": "integer",
3927 | "description": "Last line of the script."
3928 | },
3929 | {
3930 | "name": "endColumn",
3931 | "type": "integer",
3932 | "description": "Length of the last line of the script."
3933 | },
3934 | {
3935 | "name": "executionContextId",
3936 | "$ref": "Runtime.ExecutionContextId",
3937 | "description": "Specifies script creation context."
3938 | },
3939 | {
3940 | "name": "hash",
3941 | "type": "string",
3942 | "description": "Content hash of the script."
3943 | },
3944 | {
3945 | "name": "executionContextAuxData",
3946 | "type": "object",
3947 | "optional": true,
3948 | "description": "Embedder-specific auxiliary data."
3949 | },
3950 | {
3951 | "name": "isLiveEdit",
3952 | "type": "boolean",
3953 | "optional": true,
3954 | "description": "True, if this script is generated as a result of the live edit operation.",
3955 | "experimental": true
3956 | },
3957 | {
3958 | "name": "sourceMapURL",
3959 | "type": "string",
3960 | "optional": true,
3961 | "description": "URL of source map associated with script (if any)."
3962 | },
3963 | {
3964 | "name": "hasSourceURL",
3965 | "type": "boolean",
3966 | "optional": true,
3967 | "description": "True, if this script has sourceURL.",
3968 | "experimental": true
3969 | }
3970 | ],
3971 | "description": "Fired when virtual machine parses script. This event is also fired for all known and uncollected scripts upon enabling debugger."
3972 | },
3973 | {
3974 | "name": "scriptFailedToParse",
3975 | "parameters": [
3976 | {
3977 | "name": "scriptId",
3978 | "$ref": "Runtime.ScriptId",
3979 | "description": "Identifier of the script parsed."
3980 | },
3981 | {
3982 | "name": "url",
3983 | "type": "string",
3984 | "description": "URL or name of the script parsed (if any)."
3985 | },
3986 | {
3987 | "name": "startLine",
3988 | "type": "integer",
3989 | "description": "Line offset of the script within the resource with given URL (for script tags)."
3990 | },
3991 | {
3992 | "name": "startColumn",
3993 | "type": "integer",
3994 | "description": "Column offset of the script within the resource with given URL."
3995 | },
3996 | {
3997 | "name": "endLine",
3998 | "type": "integer",
3999 | "description": "Last line of the script."
4000 | },
4001 | {
4002 | "name": "endColumn",
4003 | "type": "integer",
4004 | "description": "Length of the last line of the script."
4005 | },
4006 | {
4007 | "name": "executionContextId",
4008 | "$ref": "Runtime.ExecutionContextId",
4009 | "description": "Specifies script creation context."
4010 | },
4011 | {
4012 | "name": "hash",
4013 | "type": "string",
4014 | "description": "Content hash of the script."
4015 | },
4016 | {
4017 | "name": "executionContextAuxData",
4018 | "type": "object",
4019 | "optional": true,
4020 | "description": "Embedder-specific auxiliary data."
4021 | },
4022 | {
4023 | "name": "sourceMapURL",
4024 | "type": "string",
4025 | "optional": true,
4026 | "description": "URL of source map associated with script (if any)."
4027 | },
4028 | {
4029 | "name": "hasSourceURL",
4030 | "type": "boolean",
4031 | "optional": true,
4032 | "description": "True, if this script has sourceURL.",
4033 | "experimental": true
4034 | }
4035 | ],
4036 | "description": "Fired when virtual machine fails to parse the script."
4037 | },
4038 | {
4039 | "name": "breakpointResolved",
4040 | "parameters": [
4041 | {
4042 | "name": "breakpointId",
4043 | "$ref": "BreakpointId",
4044 | "description": "Breakpoint unique identifier."
4045 | },
4046 | {
4047 | "name": "location",
4048 | "$ref": "Location",
4049 | "description": "Actual breakpoint location."
4050 | }
4051 | ],
4052 | "description": "Fired when breakpoint is resolved to an actual script and location."
4053 | },
4054 | {
4055 | "name": "paused",
4056 | "parameters": [
4057 | {
4058 | "name": "callFrames",
4059 | "type": "array",
4060 | "items": {
4061 | "$ref": "CallFrame"
4062 | },
4063 | "description": "Call stack the virtual machine stopped on."
4064 | },
4065 | {
4066 | "name": "reason",
4067 | "type": "string",
4068 | "enum": [
4069 | "XHR",
4070 | "DOM",
4071 | "EventListener",
4072 | "exception",
4073 | "assert",
4074 | "debugCommand",
4075 | "promiseRejection",
4076 | "other"
4077 | ],
4078 | "description": "Pause reason.",
4079 | "exported": true
4080 | },
4081 | {
4082 | "name": "data",
4083 | "type": "object",
4084 | "optional": true,
4085 | "description": "Object containing break-specific auxiliary properties."
4086 | },
4087 | {
4088 | "name": "hitBreakpoints",
4089 | "type": "array",
4090 | "optional": true,
4091 | "items": {
4092 | "type": "string"
4093 | },
4094 | "description": "Hit breakpoints IDs"
4095 | },
4096 | {
4097 | "name": "asyncStackTrace",
4098 | "$ref": "Runtime.StackTrace",
4099 | "optional": true,
4100 | "description": "Async stack trace, if any."
4101 | }
4102 | ],
4103 | "description": "Fired when the virtual machine stopped on breakpoint or exception or any other stop criteria."
4104 | },
4105 | {
4106 | "name": "resumed",
4107 | "description": "Fired when the virtual machine resumed execution."
4108 | }
4109 | ]
4110 | },
4111 | {
4112 | "domain": "Profiler",
4113 | "dependencies": [
4114 | "Runtime",
4115 | "Debugger"
4116 | ],
4117 | "types": [
4118 | {
4119 | "id": "ProfileNode",
4120 | "type": "object",
4121 | "description": "Profile node. Holds callsite information, execution statistics and child nodes.",
4122 | "properties": [
4123 | {
4124 | "name": "id",
4125 | "type": "integer",
4126 | "description": "Unique id of the node."
4127 | },
4128 | {
4129 | "name": "callFrame",
4130 | "$ref": "Runtime.CallFrame",
4131 | "description": "Function location."
4132 | },
4133 | {
4134 | "name": "hitCount",
4135 | "type": "integer",
4136 | "optional": true,
4137 | "experimental": true,
4138 | "description": "Number of samples where this node was on top of the call stack."
4139 | },
4140 | {
4141 | "name": "children",
4142 | "type": "array",
4143 | "items": {
4144 | "type": "integer"
4145 | },
4146 | "optional": true,
4147 | "description": "Child node ids."
4148 | },
4149 | {
4150 | "name": "deoptReason",
4151 | "type": "string",
4152 | "optional": true,
4153 | "description": "The reason of being not optimized. The function may be deoptimized or marked as don't optimize."
4154 | },
4155 | {
4156 | "name": "positionTicks",
4157 | "type": "array",
4158 | "items": {
4159 | "$ref": "PositionTickInfo"
4160 | },
4161 | "optional": true,
4162 | "experimental": true,
4163 | "description": "An array of source position ticks."
4164 | }
4165 | ]
4166 | },
4167 | {
4168 | "id": "Profile",
4169 | "type": "object",
4170 | "description": "Profile.",
4171 | "properties": [
4172 | {
4173 | "name": "nodes",
4174 | "type": "array",
4175 | "items": {
4176 | "$ref": "ProfileNode"
4177 | },
4178 | "description": "The list of profile nodes. First item is the root node."
4179 | },
4180 | {
4181 | "name": "startTime",
4182 | "type": "number",
4183 | "description": "Profiling start timestamp in microseconds."
4184 | },
4185 | {
4186 | "name": "endTime",
4187 | "type": "number",
4188 | "description": "Profiling end timestamp in microseconds."
4189 | },
4190 | {
4191 | "name": "samples",
4192 | "optional": true,
4193 | "type": "array",
4194 | "items": {
4195 | "type": "integer"
4196 | },
4197 | "description": "Ids of samples top nodes."
4198 | },
4199 | {
4200 | "name": "timeDeltas",
4201 | "optional": true,
4202 | "type": "array",
4203 | "items": {
4204 | "type": "integer"
4205 | },
4206 | "description": "Time intervals between adjacent samples in microseconds. The first delta is relative to the profile startTime."
4207 | }
4208 | ]
4209 | }
4210 | ],
4211 | "commands": [
4212 | {
4213 | "name": "enable"
4214 | },
4215 | {
4216 | "name": "disable"
4217 | },
4218 | {
4219 | "name": "setSamplingInterval",
4220 | "parameters": [
4221 | {
4222 | "name": "interval",
4223 | "type": "integer",
4224 | "description": "New sampling interval in microseconds."
4225 | }
4226 | ],
4227 | "description": "Changes CPU profiler sampling interval. Must be called before CPU profiles recording started."
4228 | },
4229 | {
4230 | "name": "start"
4231 | },
4232 | {
4233 | "name": "stop",
4234 | "returns": [
4235 | {
4236 | "name": "profile",
4237 | "$ref": "Profile",
4238 | "description": "Recorded profile."
4239 | }
4240 | ]
4241 | }
4242 | ],
4243 | "events": [
4244 | {
4245 | "name": "consoleProfileStarted",
4246 | "parameters": [
4247 | {
4248 | "name": "id",
4249 | "type": "string"
4250 | },
4251 | {
4252 | "name": "location",
4253 | "$ref": "Debugger.Location",
4254 | "description": "Location of console.profile()."
4255 | },
4256 | {
4257 | "name": "title",
4258 | "type": "string",
4259 | "optional": true,
4260 | "description": "Profile title passed as an argument to console.profile()."
4261 | }
4262 | ],
4263 | "description": "Sent when new profile recodring is started using console.profile() call."
4264 | },
4265 | {
4266 | "name": "consoleProfileFinished",
4267 | "parameters": [
4268 | {
4269 | "name": "id",
4270 | "type": "string"
4271 | },
4272 | {
4273 | "name": "location",
4274 | "$ref": "Debugger.Location",
4275 | "description": "Location of console.profileEnd()."
4276 | },
4277 | {
4278 | "name": "profile",
4279 | "$ref": "Profile"
4280 | },
4281 | {
4282 | "name": "title",
4283 | "type": "string",
4284 | "optional": true,
4285 | "description": "Profile title passed as an argument to console.profile()."
4286 | }
4287 | ]
4288 | }
4289 | ]
4290 | }
4291 | ]
4292 | }
4293 |
--------------------------------------------------------------------------------
/test/page_session_test.exs:
--------------------------------------------------------------------------------
1 | defmodule ChromeRemoteInterface.PageSessionTest do
2 | use ExUnit.Case
3 |
4 | alias ChromeRemoteInterface.PageSession
5 |
6 | describe "Event subscriptions" do
7 | test "Notifies subscribers of events" do
8 | state = %PageSession{}
9 | state = subscribe_to_test_event(state)
10 | fire_test_event(state)
11 |
12 | assert_receive {:chrome_remote_interface, "TestEvent", _}
13 | end
14 |
15 | test "Can unsubscribe from events" do
16 | state = %PageSession{}
17 | state = subscribe_to_test_event(state)
18 |
19 | {:reply, :ok, state} =
20 | PageSession.handle_call(
21 | {:unsubscribe, "TestEvent", self()},
22 | self(),
23 | state
24 | )
25 |
26 | fire_test_event(state)
27 |
28 | refute_receive {:chrome_remote_interface, "TestEvent", _}
29 | end
30 |
31 | test "Can unsubscribe from all events" do
32 | state = %PageSession{}
33 | state = subscribe_to_test_event(state)
34 |
35 | {:reply, :ok, state} =
36 | PageSession.handle_call(
37 | {:unsubscribe_all, self()},
38 | self(),
39 | state
40 | )
41 |
42 | fire_test_event(state)
43 |
44 | refute_receive {:chrome_remote_interface, "TestEvent", _}
45 | end
46 | end
47 |
48 | describe "RPC" do
49 | test "Can call RPC events" do
50 | websocket = spawn_fake_websocket()
51 | from = {make_ref(), self()}
52 |
53 | state = %PageSession{socket: websocket}
54 |
55 | {:noreply, state} =
56 | PageSession.handle_call({:call_command, "TestCommand", %{}}, from, state)
57 |
58 | assert [{_ref, {:call, _from}}] = state.callbacks
59 | end
60 |
61 | test "Receiving message for RPC event removes callback" do
62 | websocket = spawn_fake_websocket()
63 | from = {self(), make_ref()}
64 |
65 | state = %PageSession{socket: websocket}
66 |
67 | {:noreply, state} =
68 | PageSession.handle_call({:call_command, "TestCommand", %{}}, from, state)
69 |
70 | assert [{ref, {:call, _from}}] = state.callbacks
71 |
72 | frame = %{"id" => ref, "result" => %{"data" => %{"foo" => "bar"}}} |> Jason.encode!()
73 | {:noreply, state} = PageSession.handle_info({:message, frame}, state)
74 |
75 | assert [] = state.callbacks
76 | end
77 | end
78 |
79 | def subscribe_to_test_event(state) do
80 | {:reply, :ok, state} =
81 | PageSession.handle_call(
82 | {:subscribe, "TestEvent", self()},
83 | self(),
84 | state
85 | )
86 |
87 | state
88 | end
89 |
90 | def fire_test_event(state) do
91 | json =
92 | Jason.encode!(%{
93 | method: "TestEvent"
94 | })
95 |
96 | PageSession.handle_info({:message, json}, state)
97 | end
98 |
99 | def spawn_fake_websocket() do
100 | spawn_link(fn ->
101 | receive do
102 | {:"$websockex_send", from, _frame} -> GenServer.reply(from, :ok)
103 | end
104 | end)
105 | end
106 | end
107 |
--------------------------------------------------------------------------------
/test/test_helper.exs:
--------------------------------------------------------------------------------
1 | ExUnit.start()
2 |
--------------------------------------------------------------------------------