Skip to content

Commit aa0b7ad

Browse files
authored
chore: revert default for :pending_connection_errors to true and update related docs and specs (#572)
* chore: revert default for :pending_connection_errors to true and update related docs and specs * fix: add back downloads specs That was a sinatra disposition header issue, not chrome that was opening pdf extension. The header was not set because public folder was handled by rack static and file was returned to chrome without disposition header making chrome extension to intercept pdf request.
1 parent 3606d54 commit aa0b7ad

12 files changed

Lines changed: 20 additions & 32 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
### Changed
99
- `Ferrum::Network::Response#body` returns body or nil in case of errors
1010
- Disable Chrome code sign clones [#555]
11-
- `Ferrum::Browser` option `:pending_connection_errors` is set to false by default
1211
- Ruby version required is >= 3.1 [#565]
1312

1413
### Fixed

docs/2-customization.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Ferrum::Browser.new(options)
2929
communicating with browser. Default is 5.
3030
* `:js_errors` (Boolean) - When true, JavaScript errors get re-raised in Ruby.
3131
* `:pending_connection_errors` (Boolean) - Raise `PendingConnectionsError` when main frame is still waiting
32-
for slow responses and timeout is reached. Default is false.
32+
for slow responses and timeout is reached. Default is true.
3333
* `:browser_name` (Symbol) - `:chrome` by default, only experimental support
3434
for `:firefox` for now.
3535
* `:browser_path` (String) - Path to Chrome binary, you can also set ENV

lib/ferrum/browser/options.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def initialize(options = nil)
3030
@incognito = @options.fetch(:incognito, true)
3131
@dockerize = @options.fetch(:dockerize, false)
3232
@flatten = @options.fetch(:flatten, true)
33-
@pending_connection_errors = @options.fetch(:pending_connection_errors, false)
33+
@pending_connection_errors = @options.fetch(:pending_connection_errors, true)
3434
@process_timeout = @options.fetch(:process_timeout, PROCESS_TIMEOUT)
3535
@slowmo = @options[:slowmo].to_f
3636

lib/ferrum/contexts.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def size
7272

7373
private
7474

75-
def subscribe # rubocop:disable Metrics/PerceivedComplexity
75+
def subscribe # rubocop:disable Metrics/PerceivedComplexity, Metrics/CyclomaticComplexity
7676
@client.on("Target.attachedToTarget") do |params|
7777
info, session_id = params.values_at("targetInfo", "sessionId")
7878
next unless ALLOWED_TARGET_TYPES.include?(info["type"])

lib/ferrum/cookies/cookie.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ def ==(other)
161161
# The raw cookie string.
162162
#
163163
def to_s
164-
string = String.new("#{@attributes['name']}=#{@attributes['value']}")
164+
string = "#{@attributes['name']}=#{@attributes['value']}"
165165

166166
@attributes.each do |key, value|
167167
case key

spec/browser_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,9 +236,9 @@
236236
end
237237

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

241-
expect { browser.go_to("/really_slow") }.to raise_error(Ferrum::PendingConnectionsError)
241+
expect { browser.go_to("/really_slow") }.not_to raise_error
242242
ensure
243243
browser&.quit
244244
end

spec/cookies_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
"secure" => false,
2424
"session" => true,
2525
"priority" => "Medium",
26-
"sameParty" => false,
2726
"sourceScheme" => "NonSecure",
2827
"sourcePort" => server.port)
2928
]
@@ -47,7 +46,6 @@
4746
"secure" => false,
4847
"session" => true,
4948
"priority" => "Medium",
50-
"sameParty" => false,
5149
"sourceScheme" => "NonSecure",
5250
"sourcePort" => server.port)
5351
]
@@ -72,7 +70,6 @@
7270
"secure" => false,
7371
"session" => true,
7472
"priority" => "Medium",
75-
"sameParty" => false,
7673
"sourceScheme" => "NonSecure",
7774
"sourcePort" => server.port) })
7875
end

spec/downloads_spec.rb

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,8 @@
44
let(:filename) { "attachment.pdf" }
55
let(:save_path) { "/tmp/ferrum" }
66

7-
def skip_browser_bug
8-
# Also https://github.com/puppeteer/puppeteer/issues/10161
9-
skip "https://bugs.chromium.org/p/chromium/issues/detail?id=1444729"
10-
end
11-
127
describe "#files" do
138
it "saves an attachment" do
14-
skip_browser_bug
15-
169
page.downloads.set_behavior(save_path: save_path)
1710
page.go_to("/#{filename}")
1811
page.downloads.wait
@@ -50,8 +43,6 @@ def skip_browser_bug
5043
describe "#set_behavior" do
5144
context "with absolute path" do
5245
it "saves an attachment" do
53-
skip_browser_bug
54-
5546
page.downloads.set_behavior(save_path: save_path)
5647
page.go_to("/#{filename}")
5748
page.downloads.wait
@@ -62,17 +53,13 @@ def skip_browser_bug
6253
end
6354

6455
it "saves no attachment when behavior is deny" do
65-
skip_browser_bug
66-
6756
page.downloads.set_behavior(save_path: save_path, behavior: :deny)
6857
page.downloads.wait { page.go_to("/#{filename}") }
6958

7059
expect(File.exist?("#{save_path}/#{filename}")).to be false
7160
end
7261

7362
it "saves an attachment on click" do
74-
skip_browser_bug
75-
7663
page.downloads.set_behavior(save_path: save_path)
7764
page.go_to("/attachment")
7865
page.downloads.wait { page.at_css("#download").click }

spec/network/exchange_spec.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,12 @@
197197
it "determines if exchange is not fully loaded" do
198198
allow(page).to receive(:timeout) { 2 }
199199

200-
page.go_to("/visit_timeout")
200+
expect do
201+
page.go_to("/visit_timeout")
202+
end.to raise_error(
203+
Ferrum::PendingConnectionsError,
204+
%r{Request to http://.*/visit_timeout reached server, but there are still pending connections: http://.*/really_slow}
205+
)
201206

202207
expect(last_exchange.pending?).to be true
203208
end

spec/page_spec.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

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

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

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

0 commit comments

Comments
 (0)