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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
- `Ferrum::PendingConnectionsError` and `Ferrum::TimeoutError` were swallowed even though it happens when a traffic iterator results in an empty array. [#583]
- `webrick` is no longer a runtime dependency. It is only required by `Ferrum::Proxy`, so add `gem "webrick"` to your Gemfile if you use it.
- Logger output for `Runtime.consoleAPICalled` now includes the console API type and stack trace call frames, not just the argument values [#605]
- `Ferrum::Browser` option `:pending_connection_errors` is set to false by default

### Removed
- `webrick` runtime dependency dropped from the gemspec. `Ferrum::Proxy` still needs it, so add `gem "webrick"` to your Gemfile if you use the proxy server.
Expand Down
2 changes: 1 addition & 1 deletion docs/2-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Ferrum::Browser.new(options)
communicating with browser. Default is 5.
* `:js_errors` (Boolean) - When true, JavaScript errors get re-raised in Ruby.
* `:pending_connection_errors` (Boolean) - Raise `PendingConnectionsError` when main frame is still waiting
for slow responses and timeout is reached. Default is true.
for slow responses and timeout is reached. Default is false.
* `:browser_name` (Symbol) - `:chrome` by default, only experimental support
for `:firefox` for now.
* `:browser_path` (String) - Path to Chrome binary, you can also set ENV
Expand Down
2 changes: 1 addition & 1 deletion lib/ferrum/browser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def initialize(options = nil)
@incognito = @options.fetch(:incognito, true)
@dockerize = @options.fetch(:dockerize, false)
@flatten = @options.fetch(:flatten, true)
@pending_connection_errors = @options.fetch(:pending_connection_errors, true)
@pending_connection_errors = @options.fetch(:pending_connection_errors, false)
@process_timeout = @options.fetch(:process_timeout, PROCESS_TIMEOUT)
@slowmo = @options[:slowmo].to_f

Expand Down
4 changes: 2 additions & 2 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,9 @@
end

it "supports :pending_connection_errors argument" do
browser = Ferrum::Browser.new(base_url: base_url, pending_connection_errors: false, timeout: 0.5)
browser = Ferrum::Browser.new(base_url: base_url, pending_connection_errors: true, timeout: 0.5)

expect { browser.go_to("/really_slow") }.not_to raise_error
expect { browser.go_to("/really_slow") }.to raise_error(Ferrum::PendingConnectionsError)
ensure
browser&.quit
end
Expand Down
7 changes: 1 addition & 6 deletions spec/network/exchange_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,7 @@
it "determines if exchange is not fully loaded" do
allow(page).to receive(:timeout) { 2 }

expect do
page.go_to("/visit_timeout")
end.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/visit_timeout reached server, but there are still pending connections: http://.*/really_slow}
)
page.go_to("/visit_timeout")

expect(last_exchange.pending?).to be true
end
Expand Down
3 changes: 3 additions & 0 deletions spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

it "reports pending connection for image" do
with_timeout(2) do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
expect { browser.go_to("/visit_timeout") }.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/visit_timeout reached server, but there are still pending connections: http://.*/really_slow}
Expand All @@ -34,6 +35,7 @@

it "reports pending connection for main frame" do
with_timeout(0.5) do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
expect { browser.go_to("/really_slow") }.to raise_error(
Ferrum::PendingConnectionsError,
%r{Request to http://.*/really_slow reached server, but there are still pending connections: http://.*/really_slow}
Expand Down Expand Up @@ -164,6 +166,7 @@

describe "#timeout=" do
it "supports to change timeout dynamically" do
allow(browser.options).to receive(:pending_connection_errors).and_return(true)
page.timeout = 4
expect { page.go_to("/really_slow") }.not_to raise_error

Expand Down
Loading