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
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
## [Unreleased](https://github.com/rubycdp/ferrum/compare/v0.22.0...main) ##

### Added

### Changed

### Deprecated

### Fixed

### Removed
- `:extensions`, `browser.add_extension` and `browser.extensions`, use `:init_scripts`, `add_init_script` and
`init_scripts`
- `network.clear`, use `network.clear_traffic` or `network.clear_cache`
- `browser.reset`, use `browser.contexts.reset`

## [0.22.0](https://github.com/rubycdp/ferrum/compare/v0.21.0...v0.22.0) (December 1, 2026) ##

### Added
Expand Down
3 changes: 1 addition & 2 deletions docs/13-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,7 @@ page.remove_script_on_new_document(id)

Adds an init script, see the `:init_scripts` option. It runs in every page and iframe, popups and out-of-process
iframes included, attached after the call, before their own scripts. Pages already open keep the scripts they had.
`browser.init_scripts` returns the source of every init script. `add_extension` and `extensions` are deprecated
aliases.
`browser.init_scripts` returns the source of every init script.

* script `String | Hash` a path to a JS file or `{ source: "..." }`

Expand Down
1 change: 0 additions & 1 deletion docs/2-customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ Ferrum::Browser.new(options)
* `:init_scripts` (Array[String | Hash]) - Paths to JS files or JS source code to run in every page and iframe
before their own scripts, e.g. `["/path/to/script.js", { source: "window.secret = 'top'" }]`. Files are read in
`Browser.new`. See `add_init_script` in [JavaScript](/docs/ferrum/javascript).
* `:extensions` - Deprecated, use `:init_scripts`.
* `:logger` (Object responding to `puts`, or a `Logger`) - When present, debug output is
written to it, see [Logging](#logging).
* `:slowmo` (Integer | Float) - Set a delay in seconds to wait before sending command.
Expand Down
1 change: 0 additions & 1 deletion lib/ferrum.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
require "ferrum/concurrency/dispatcher"
require "ferrum/utils/attempt"
require "ferrum/utils/poll"
require "ferrum/utils/deprecate"
require "ferrum/errors"
require "ferrum/browser"
require "ferrum/remote_object"
Expand Down
22 changes: 1 addition & 21 deletions lib/ferrum/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ module Ferrum
class Browser
extend Forwardable

RESET_DEPRECATED = "browser.reset will be removed in Ferrum 1.0. Use browser.contexts.reset instead."

delegate %i[default_context] => :contexts
delegate %i[targets create_target page pages await_page await_page! workers service_workers
attach_target close_target cookies downloads] => :default_context
Expand All @@ -50,7 +48,7 @@ class Browser
attr_reader :client, :process, :contexts, :options

delegate %i[timeout timeout= base_url base_url= default_user_agent default_user_agent= init_scripts
add_init_script extensions add_extension on_page] => :options
add_init_script on_page] => :options

#
# Initializes the browser.
Expand Down Expand Up @@ -79,9 +77,6 @@ class Browser
# Paths to JS files or JS source code to run in every page and iframe before their own scripts, e.g.
# `["/path/to/script.js", { source: "window.secret = 'top'" }]`.
#
# @option options [Array<String, Hash>] :extensions
# Deprecated, use `:init_scripts`.
#
# @option options [#puts, Logger] :logger
# When present, debug output is written to this object, see {Log}.
#
Expand Down Expand Up @@ -195,21 +190,6 @@ def create_page(new_context: false, new_window: false, proxy: nil)
end
end

#
# Closes browser tabs opened by the `Browser` instance.
#
# @deprecated Use {Contexts#reset} via `browser.contexts.reset`.
#
# @return [nil]
#
# @raise [TimeoutError]
#
def reset
Utils::Deprecate.warn(RESET_DEPRECATED, user_code: true)
contexts.reset
nil
end

#
# Restarts the browser process, keeping the same options.
#
Expand Down
36 changes: 1 addition & 35 deletions lib/ferrum/browser/options.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@ class Options
BASE_URL_SCHEMES = %w[http https].freeze
DEFAULT_TIMEOUT = ENV.fetch("FERRUM_DEFAULT_TIMEOUT", 5).to_f
PROCESS_TIMEOUT = ENV.fetch("FERRUM_PROCESS_TIMEOUT", 10).to_i
EXTENSIONS_DEPRECATED = "The :extensions option will be removed in Ferrum 1.0. Use :init_scripts instead."
EXTENSIONS_READER_DEPRECATED = "extensions will be removed in Ferrum 1.0. Use init_scripts instead."
ADD_EXTENSION_DEPRECATED = "add_extension will be removed in Ferrum 1.0. Use add_init_script instead."

attr_reader :window_size, :logger, :log, :ws_max_receive_size,
:base_url, :slowmo,
Expand Down Expand Up @@ -94,36 +91,6 @@ def add_init_script(script)
@init_scripts = [*@init_scripts, read_init_script(script)].freeze
end

#
# Adds a script to run in every new document.
#
# @deprecated Use {#add_init_script}.
#
# @param [String, Hash] extension
# A path to a JS file, or `{ source: "..." }`.
#
# @return [Array<String>]
#
# @raise [Errno::ENOENT]
# If the file doesn't exist.
#
def add_extension(extension)
Utils::Deprecate.warn(ADD_EXTENSION_DEPRECATED, user_code: true)
add_init_script(extension)
end

#
# JS source code of every init script.
#
# @deprecated Use {#init_scripts}.
#
# @return [Array<String>]
#
def extensions
Utils::Deprecate.warn(EXTENSIONS_READER_DEPRECATED, user_code: true)
init_scripts
end

#
# Calls the block with every new page before Ferrum returns it, so the page can be set up before anything runs
# on it. That covers pages you create and pages other pages open, like popups. Pages already open when you call
Expand Down Expand Up @@ -191,8 +158,7 @@ def to_h
private

def parse_init_scripts
Utils::Deprecate.warn(EXTENSIONS_DEPRECATED, user_code: true) if @options.key?(:extensions)
[*@options[:extensions], *@options[:init_scripts]].map { |s| read_init_script(s) }.freeze
Array(@options[:init_scripts]).map { |s| read_init_script(s) }.freeze
end

def read_init_script(script)
Expand Down
22 changes: 0 additions & 22 deletions lib/ferrum/network.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ module Ferrum
#
class Network
WAIT_INTERVAL = 0.05
CLEAR_TYPE = %i[traffic cache].freeze
CLEAR_DEPRECATED = "network.clear will be removed in Ferrum 1.0. Use network.clear_traffic or " \
"network.clear_cache instead."
EMULATE_KEYS = %i[user_agent accept_language platform metadata].freeze
METADATA_REQUIRED = %i[platform platform_version architecture model mobile].freeze
METADATA_OPTIONAL = %i[brands full_version_list full_version bitness wow64 form_factors].freeze
Expand Down Expand Up @@ -179,25 +176,6 @@ def status
response&.status
end

#
# Clear browser's cache or collected traffic.
#
# @deprecated Use {#clear_traffic} or {#clear_cache}.
#
# @param [:traffic, :cache] type
# The type of traffic to clear.
#
# @return [nil]
#
# @raise [TimeoutError]
#
def clear(type)
raise ArgumentError, ":type should be #{CLEAR_TYPE.map(&:inspect).join(' | ')}" unless CLEAR_TYPE.include?(type)

Utils::Deprecate.warn(CLEAR_DEPRECATED, user_code: true)
type == :traffic ? clear_traffic : clear_cache
end

#
# Forgets the collected traffic, including the main frame's {#request} and
# {#response}.
Expand Down
76 changes: 0 additions & 76 deletions lib/ferrum/utils/deprecate.rb

This file was deleted.

8 changes: 0 additions & 8 deletions sig/ferrum/browser.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ module Ferrum
class Browser
extend Forwardable

RESET_DEPRECATED: String

attr_reader client: ::Ferrum::Client
attr_reader process: Browser::Process
attr_reader contexts: Contexts
Expand Down Expand Up @@ -35,14 +33,8 @@ module Ferrum

def add_init_script: (String | Hash[Symbol, String] script) -> ::Array[String]

%a{deprecated} def extensions: () -> ::Array[String]

%a{deprecated} def add_extension: (String | Hash[Symbol, String] extension) -> ::Array[String]

def command: (String method, ?timeout: (::Numeric | Deadline)?, **untyped params) -> Hash[String, untyped]

%a{deprecated} def reset: () -> nil

def restart: () -> void

def quit: (?wait: bool) -> Thread?
Expand Down
10 changes: 0 additions & 10 deletions sig/ferrum/browser/options.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ module Ferrum

PROCESS_TIMEOUT: ::Integer

EXTENSIONS_DEPRECATED: String

EXTENSIONS_READER_DEPRECATED: String

ADD_EXTENSION_DEPRECATED: String

attr_reader window_size: ::Array[::Integer]

attr_accessor timeout: ::Numeric
Expand Down Expand Up @@ -99,10 +93,6 @@ module Ferrum

def add_init_script: (String | Hash[Symbol, String] script) -> ::Array[String]

%a{deprecated} def add_extension: (String | Hash[Symbol, String] extension) -> ::Array[String]

%a{deprecated} def extensions: () -> ::Array[String]

def on_page: () { (Page page) -> void } -> nil

attr_reader page_handlers: ::Array[^(Page) -> void]
Expand Down
4 changes: 0 additions & 4 deletions sig/ferrum/network.rbs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
module Ferrum
class Network
WAIT_INTERVAL: ::Float
CLEAR_TYPE: ::Array[:traffic | :cache]
CLEAR_DEPRECATED: String
EMULATE_KEYS: ::Array[:user_agent | :accept_language | :platform | :metadata]
METADATA_REQUIRED: ::Array[Symbol]
METADATA_OPTIONAL: ::Array[Symbol]
Expand Down Expand Up @@ -37,8 +35,6 @@ module Ferrum

def status: () -> untyped

%a{deprecated} def clear: (:traffic | :cache `type`) -> nil

def clear_traffic: () -> nil

def clear_cache: () -> nil
Expand Down
13 changes: 0 additions & 13 deletions sig/ferrum/utils/deprecate.rbs

This file was deleted.

Loading
Loading