Skip to content

Commit

Permalink
fix: README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
route committed Sep 14, 2023
1 parent 4e26235 commit dfaf338
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,8 @@ Ferrum::Browser.new(options)
```

* options `Hash`
* `:headless` (Boolean) - Set browser as headless or not, `true` by default.
* `: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/).
* `:xvfb` (Boolean) - Run browser in a virtual framebuffer, `false` by default.
* `: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]
Expand Down
9 changes: 7 additions & 2 deletions lib/ferrum/browser/options/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class Browser
class Options
class Chrome < Base
DEFAULT_OPTIONS = {
"headless" => "new",
"headless" => nil,
"disable-gpu" => nil,
"hide-scrollbars" => nil,
"mute-audio" => nil,
Expand Down Expand Up @@ -76,7 +76,12 @@ def merge_required(flags, options, user_data_dir)
end

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

defaults ||= DEFAULT_OPTIONS
defaults.merge(flags)
Expand Down

0 comments on commit dfaf338

Please sign in to comment.