Skip to content

Commit

Permalink
API: add placeholder tests for Browser.on/3
Browse files Browse the repository at this point in the history
However, the function is not yet implemented. A single event is supported in Playwright proper: `disconnected`. And, the event is meant to be emitted from the client-side, upon `Browser.close/1`; we don't yet have a good mechanism for that.

Also, some cleanup.
  • Loading branch information
coreyti committed Oct 9, 2024
1 parent acc143f commit d9a1313
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 27 deletions.
5 changes: 3 additions & 2 deletions lib/playwright/browser.ex
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,9 @@ defmodule Playwright.Browser do
"""
@type worker_settings :: String.t()

@typedoc "Options for tracing API."
@type opts_tracing :: map()

# callbacks
# ---------------------------------------------------------------------------

Expand Down Expand Up @@ -725,8 +728,6 @@ defmodule Playwright.Browser do

# ---

@type opts_tracing :: map()

@spec start_tracing(t(), Page.t(), opts_tracing()) :: t() | {:error, Error.t()}
def start_tracing(browser, page \\ nil, options \\ %{})

Expand Down
2 changes: 1 addition & 1 deletion lib/playwright/cdp_session.ex
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ defmodule Playwright.CDPSession do
# private
# ---------------------------------------------------------------------------

def handle_event(session, %{params: %{method: method, params: params}}) do
defp handle_event(session, %{params: %{method: method, params: params}}) do
event = %{
params: params,
target: session
Expand Down
24 changes: 0 additions & 24 deletions lib/playwright/sdk/channel/event.ex
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,3 @@ defmodule Playwright.SDK.Channel.Event do
end)
end
end

# defp module_for(%{__struct__: module}) do
# module
# end

# defp prepare(%{newDocument: %{request: request}} = params, type, catalog) when type in ["navigated"] do
# document = %{request: Channel.Catalog.get(catalog, request.guid)}
# Map.put(params, :newDocument, document)
# end

# defp prepare(params, type, catalog) when type in ["page"] do
# page = Channel.Catalog.get(catalog, params.page.guid)
# frame = Channel.Catalog.get(catalog, page.main_frame.guid)

# Map.merge(params, %{
# page: page,
# url: frame.url
# })
# end

# defp prepare(params, type, _catalog) do
# Logger.debug("Event.prepare/3 not implemented for type: #{inspect(type)} w/ params: #{inspect(params)}")
# params
# end

0 comments on commit d9a1313

Please sign in to comment.