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

fix: #203 window-size is for window, page can have its own viewport #427

Merged
merged 1 commit into from
Dec 21, 2023
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
11 changes: 2 additions & 9 deletions lib/ferrum/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ class Browser
add_script_tag add_style_tag bypass_csp
on position position=
playback_rate playback_rate=
disable_javascript set_viewport] => :page
disable_javascript set_viewport resize] => :page
delegate %i[default_user_agent] => :process

attr_reader :client, :process, :contexts, :options, :window_size, :base_url
attr_reader :client, :process, :contexts, :options, :base_url
attr_accessor :timeout

#
Expand Down Expand Up @@ -126,7 +126,6 @@ def initialize(options = nil)
@client = @process = @contexts = nil

@timeout = @options.timeout
@window_size = @options.window_size
@base_url = @options.base_url if @options.base_url

start
Expand Down Expand Up @@ -228,7 +227,6 @@ def command(*args)
# browser.quit
#
def reset
@window_size = options.window_size
contexts.reset
end

Expand All @@ -245,11 +243,6 @@ def quit
@client = @process = @contexts = nil
end

def resize(**options)
@window_size = [options[:width], options[:height]]
page.resize(**options)
end

def crash
command("Browser.crash")
end
Expand Down
1 change: 0 additions & 1 deletion lib/ferrum/browser/options/chrome.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ class Chrome < Base
def merge_required(flags, options, user_data_dir)
flags = flags.merge("remote-debugging-port" => options.port,
"remote-debugging-address" => options.host,
# Doesn't work on MacOS, so we need to set it by CDP
"window-size" => options.window_size&.join(","),
"user-data-dir" => user_data_dir)

Expand Down
3 changes: 0 additions & 3 deletions lib/ferrum/page.rb
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,6 @@ def prepare_page

inject_extensions

width, height = @browser.window_size
resize(width: width, height: height)

response = command("Page.getNavigationHistory")
transition_type = response.dig("entries", 0, "transitionType")
return if transition_type == "auto_toplevel"
Expand Down
7 changes: 0 additions & 7 deletions spec/browser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,6 @@
expect(browser.viewport_size).to eq([200, 400])
end

it "inherits size for a new window" do
browser.go_to
browser.resize(width: 1200, height: 800)
page = browser.create_page
expect(page.viewport_size).to eq [1200, 800]
end

it "resizes windows" do
browser.go_to

Expand Down