Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions lib/chromic_pdf/pdf/protocol_macros.ex
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,12 @@ defmodule ChromicPDF.ProtocolMacros do

if JsonRPC.response?(msg, last_call_id) do
cond do
function_exported?(__MODULE__, unquote(cb_name), 2) ->
apply(__MODULE__, unquote(cb_name), [state, msg])

JsonRPC.is_error?(msg) ->
{:error, JsonRPC.extract_error(msg)}

function_exported?(__MODULE__, unquote(cb_name), 2) ->
apply(__MODULE__, unquote(cb_name), [state, msg])

true ->
:ok
end
Expand Down
7 changes: 7 additions & 0 deletions test/integration/pdf_generation_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,13 @@ defmodule ChromicPDF.PDFGenerationTest do
end)
end

@tag :pdftotext
test "raises an error for invalid paths, e.g. relative" do
assert_raise ChromicPDF.ChromeError, ~r/Cannot navigate to invalid URL/, fn ->
ChromicPDF.print_to_pdf({:url, "/doesnotwork"})
end
end

@tag :pdftotext
test "it waits for external resources when printing HTML content" do
html = ~s(<img src="file://#{test_image_path()}" />)
Expand Down