Skip to content

Commit f6a5577

Browse files
committed
Remove automatic resizing from Ferrum
This should really live at the Cuprite level, emulating specific devices.
1 parent 1560ecd commit f6a5577

File tree

2 files changed

+9
-29
lines changed

2 files changed

+9
-29
lines changed

lib/ferrum/page.rb

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ def close_connection
138138
#
139139
# Overrides device screen dimensions and emulates viewport according to parameters.
140140
#
141-
# Note that passing mobile: true will cause set_viewport to ignore the passed
142-
# height and width values, and instead use 390 x 844, which is the viewport size
143-
# of an iPhone 14.
144-
#
145141
# Read more [here](https://chromedevtools.github.io/devtools-protocol/tot/Emulation/#method-setDeviceMetricsOverride).
146142
#
147143
# @param [Integer] width width value in pixels. 0 disables the override
@@ -159,30 +155,21 @@ def set_viewport(width:, height:, scale_factor: 0, mobile: false)
159155
enabled: true,
160156
maxTouchPoints: 1
161157
)
162-
163-
command(
164-
"Emulation.setDeviceMetricsOverride",
165-
deviceScaleFactor: 3.0,
166-
height: 844,
167-
mobile: true,
168-
slowmoable: true,
169-
width: 390
170-
)
171158
else
172159
command(
173160
"Emulation.setTouchEmulationEnabled",
174161
enabled: false
175162
)
176-
177-
command(
178-
"Emulation.setDeviceMetricsOverride",
179-
deviceScaleFactor: scale_factor,
180-
height: height,
181-
mobile: false,
182-
slowmoable: true,
183-
width: width
184-
)
185163
end
164+
165+
command(
166+
"Emulation.setDeviceMetricsOverride",
167+
deviceScaleFactor: scale_factor,
168+
height: height,
169+
mobile: true,
170+
slowmoable: true,
171+
width: width
172+
)
186173
end
187174

188175
def resize(width: nil, height: nil, fullscreen: false, mobile: false)

spec/page_spec.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,6 @@ def is_mobile?
277277
page.reload
278278
end.to change { is_mobile? }.to(true)
279279
end
280-
281-
it "resizes to the size of an iPhone 14 viewport, taking into account scale factor" do
282-
expect do
283-
page.resize(width: 0, height: 0, mobile: true)
284-
page.reload
285-
end.to change { body_size }.to(width: 980, height: 2120)
286-
end
287280
end
288281
end
289282
end

0 commit comments

Comments
 (0)