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 @@ -54,6 +54,7 @@
`page.on(:console)` instead
- `:pending_connection_errors` and `PendingConnectionsError`, will be removed in 0.22. Pass `on_timeout: :raise` to
`go_to` instead
- `flatten: false`, the option will be removed in 0.22 and every page will share the browser's websocket connection
- `FERRUM_DEBUG`, will be removed in 0.22. Use `FERRUM_LOG=*` instead
- `:protocol_timeout`, `browser.protocol_timeout`, `browser.protocol_timeout=` and `FERRUM_PROTOCOL_TIMEOUT`, will be
removed in 0.22. They are ignored and warn, `:timeout` bounds everything else
Expand Down
2 changes: 1 addition & 1 deletion docs/2-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Ferrum::Browser.new(options)
* `:xvfb` (Boolean) - Run browser in a virtual framebuffer, `false` by default.
* `:flatten` (Boolean) - Use one websocket connection to the browser and all the pages in flatten mode,
`true` by default. When set to `false`, each page/target opens its own dedicated websocket connection instead
of sharing the browser's connection.
of sharing the browser's connection. Passing `false` is deprecated, the option will be removed in 0.22.
* `:window_size` (Array) - The dimensions of the browser window in which to
test, expressed as a 2-element array, e.g. [1024, 768]. Default: [1024, 768]
* `:extensions` (Array[String | Hash]) - An array of paths to files or JS
Expand Down
2 changes: 2 additions & 0 deletions lib/ferrum/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ class Browser
#
# @option options [Boolean] :flatten (true)
# Use one websocket connection to the browser and all the pages in flatten mode.
# Passing `false` is deprecated, the option will be removed in Ferrum 0.22
# and every page will share the browser's connection.
#
# @option options [(Integer, Integer)] :window_size ([1024, 768])
# The dimensions of the browser window in which to test, expressed as a
Expand Down
8 changes: 8 additions & 0 deletions lib/ferrum/browser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def initialize(options = nil)
@incognito = @options.fetch(:incognito, true)
@dockerize = @options.fetch(:dockerize, false)
@flatten = @options.fetch(:flatten, true)
warn_flatten unless @flatten
@pending_connection_errors = fetch_deprecated(
:pending_connection_errors, "Pass on_timeout: :raise to go_to instead: page.go_to(url, on_timeout: :raise)."
)
Expand Down Expand Up @@ -171,6 +172,13 @@ def warn_protocol_timeout
Utils::Deprecate.warn(":protocol_timeout #{PROTOCOL_TIMEOUT_REMOVED}", user_code: true)
end

def warn_flatten
Utils::Deprecate.warn(
"flatten: false will be removed in Ferrum 0.22. Every page will share the browser's websocket connection.",
user_code: true
)
end

def fetch_deprecated(name, instead)
return false unless @options.key?(name)

Expand Down
4 changes: 3 additions & 1 deletion sig/ferrum/browser/options.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module Ferrum

attr_reader incognito: bool

attr_reader flatten: bool
%a{deprecated} attr_reader flatten: bool

attr_reader ignore_default_browser_options: bool?

Expand Down Expand Up @@ -113,6 +113,8 @@ module Ferrum

def warn_protocol_timeout: () -> void

def warn_flatten: () -> void

def fetch_deprecated: (Symbol name, String instead) -> bool

def read_extension: (String | Hash[Symbol, String] extension) -> String
Expand Down
9 changes: 9 additions & 0 deletions spec/unit/browser/options_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
expect { described_class.new(protocol_timeout: 10) }
.to output(/:protocol_timeout is ignored.*called from #{__FILE__}/m).to_stderr
end

it "warns that flatten: false will be removed" do
expect { described_class.new(flatten: false) }
.to output(/flatten: false will be removed in Ferrum 0.22.*called from #{__FILE__}/m).to_stderr
end

it "stays silent when :flatten is true" do
expect { described_class.new(flatten: true) }.not_to output.to_stderr
end
end

describe "#protocol_timeout" do
Expand Down
Loading