Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove headless new #518

Merged
merged 1 commit into from
Feb 4, 2025
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 @@ -13,6 +13,7 @@

- `Ferrum::Network::Exchange#finished?` takes into account that exchange might be in an unknown state after loader changed(next `go_to` call) and considers
such as finished [#426]
- `headless: "new"` mode is removed as it's now default in modern Chrome, just use `headless: true` instead [#518]

### Fixed

Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ Ferrum::Browser.new(options)
```

* options `Hash`
* `:headless` (String | Boolean) - Set browser as headless or not, `true` by default. You can set `"new"` to support
[new headless mode](https://developer.chrome.com/articles/new-headless/).
* `:headless` (String | Boolean) - Set browser as headless or not, `true` by default.
* `: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.
* `:window_size` (Array) - The dimensions of the browser window in which to
Expand Down
4 changes: 0 additions & 4 deletions lib/ferrum/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ def version
VersionInfo.new(command("Browser.getVersion"))
end

def headless_new?
process&.command&.headless_new?
end

private

def start
Expand Down
4 changes: 0 additions & 4 deletions lib/ferrum/browser/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ def xvfb?
!!options.xvfb
end

def headless_new?
@flags["headless"] == "new"
end

def to_a
[path] + @flags.map { |k, v| v.nil? ? "--#{k}" : "--#{k}=#{v}" }
end
Expand Down
8 changes: 1 addition & 7 deletions lib/ferrum/browser/options/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,7 @@ def merge_required(flags, options, user_data_dir)
end

def merge_default(flags, options)
defaults = case options.headless
when false
except("headless", "disable-gpu")
when "new"
except("headless").merge("headless" => "new")
end

defaults = except("headless", "disable-gpu") if options.headless == false
defaults ||= DEFAULT_OPTIONS
# On Windows, the --disable-gpu flag is a temporary work around for a few bugs.
# See https://bugs.chromium.org/p/chromium/issues/detail?id=737678 for more information.
Expand Down
2 changes: 1 addition & 1 deletion spec/network_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,6 @@
%r{Request to http://.*/with_js failed \(net::ERR_INTERNET_DISCONNECTED\)}
)

expect(page.at_css("body").text).to match("No internet") if browser.headless_new?
expect(page.at_css("body").text).to match("No internet")
end
end
2 changes: 1 addition & 1 deletion spec/page_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

describe "#position=" do
it "allows the window to be positioned" do
skip if Ferrum::Utils::Platform.mac? && !browser.headless_new?
skip if Ferrum::Utils::Platform.mac?

expect do
page.position = { left: 10, top: 20 }
Expand Down
1 change: 0 additions & 1 deletion spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
config.before(:all) do
base_url = Ferrum::Server.server.base_url
options = { base_url: base_url }
options.merge!(headless: "new") if ENV["HEADLESS"] == "new"
options.merge!(headless: false) if ENV["HEADLESS"] == "false"
options.merge!(slowmo: ENV["SLOWMO"].to_f) if ENV["SLOWMO"].to_f > 0

Expand Down
2 changes: 1 addition & 1 deletion spec/support/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def authorized?(login, password)

get "/" do
response.set_cookie("cookie", value: "root cookie", domain: request.host, path: request.path)
%(Hello world! <a href="with_html">Relative</a>)
%(<link rel="icon" href="data:,">Hello world! <a href="with_html">Relative</a>)
end

get "/set_cookie" do
Expand Down