Skip to content

Commit f7659f0

Browse files
NakilonMifrill
authored andcommitted
windowState is normal by default
1 parent 7c84cdb commit f7659f0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

lib/ferrum/page.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,14 @@ def close
9090
end
9191

9292
def resize(width: nil, height: nil, fullscreen: false)
93-
result = @browser.command("Browser.getWindowForTarget", targetId: @target_id)
94-
@window_id, @bounds = result.values_at("windowId", "bounds")
93+
@window_id = @browser.command("Browser.getWindowForTarget", targetId: @target_id)["windowId"]
9594

9695
if fullscreen
9796
width, height = document_size
9897
@browser.command("Browser.setWindowBounds", windowId: @window_id, bounds: { windowState: "fullscreen" })
9998
else
10099
@browser.command("Browser.setWindowBounds", windowId: @window_id, bounds: { windowState: "normal" })
101-
@browser.command("Browser.setWindowBounds", windowId: @window_id, bounds: { width: width, height: height, windowState: "normal" })
100+
@browser.command("Browser.setWindowBounds", windowId: @window_id, bounds: { width: width, height: height })
102101
end
103102

104103
command("Emulation.setDeviceMetricsOverride", slowmoable: true,

spec/browser_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,13 @@ module Ferrum
9999

100100
context 'fullscreen' do
101101
shared_examples 'resize viewport by fullscreen' do
102-
it "allows the viewport to be resized by fullscreen" do
102+
it "allows the viewport to be resized to fullscreen and back" do
103103
expect(browser.viewport_size).to eq([1024, 768])
104104
browser.go_to(path)
105105
browser.resize(fullscreen: true)
106106
expect(browser.viewport_size).to eq(viewport_size)
107+
browser.resize(width: 200, height: 400)
108+
expect(browser.viewport_size).to eq([200, 400])
107109
end
108110
end
109111

0 commit comments

Comments
 (0)