Skip to content

Commit 7f38bf3

Browse files
committed
windowState is normal by default
1 parent 6d1612d commit 7f38bf3

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
@@ -89,15 +89,14 @@ def close
8989
end
9090

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

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

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

spec/browser_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,13 @@ module Ferrum
8787
expect(browser.viewport_size).to eq([200, 400])
8888
end
8989

90-
it "allows the viewport to be resized by fullscreen" do
90+
it "allows the viewport to be resized to fullscreen and back" do
9191
browser.goto("/ferrum/custom_html_size")
9292
expect(browser.viewport_size).to eq([1024, 768])
9393
browser.resize(fullscreen: true)
9494
expect(browser.viewport_size).to eq([1280, 1024])
95+
browser.resize(width: 200, height: 400)
96+
expect(browser.viewport_size).to eq([200, 400])
9597
end
9698

9799
it "allows the page to be scrolled" do

0 commit comments

Comments
 (0)