Add --width/--height/--device flags for mobile/responsive viewport emulation - #15
Open
josefrichter wants to merge 2 commits into
Open
Add --width/--height/--device flags for mobile/responsive viewport emulation#15josefrichter wants to merge 2 commits into
josefrichter wants to merge 2 commits into
Conversation
Lets `web` render responsive/mobile layouts so CSS media queries (e.g. Tailwind's max-sm:/sm: breakpoints) fire as they would on a phone — useful for screenshotting and verifying responsive UIs. - --width / --height set the viewport size (height defaults to 900) - --device maps a preset name (iphone, iphone-se, iphone-max, pixel, ipad, desktop) to a viewport size + mobile user-agent - Resizes the headless Firefox window before navigating; in headless mode the window size maps directly to the layout viewport
josefrichter
force-pushed
the
feature/mobile-viewport
branch
from
July 1, 2026 15:20
05fab95 to
807bd66
Compare
… ultrawide) Headless Firefox enforces a minimum window width (~450px) at the Gecko widget layer, and the WebDriver Set Window Rect command clamps anything below it. That made the per-device phone presets fiction: iphone-se (375), iphone (390), pixel (412) and iphone-max (430) all rendered at the same 450px viewport, differing only in height. Name presets by what the tool can actually deliver — viewport size classes — and have "mobile" declare the 450px floor directly instead of requesting a width that silently clamps: - mobile: 450x900 + mobile UA (Firefox floor; max-sm:/sm: fire) - tablet: 820x1180 + mobile UA - desktop: 1280x800 - wide: 1920x1080 - ultrawide: 2560x1440 Explicit --width/--height remain for exact sizes above the floor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds viewport-size control so
webcan render responsive/mobile layouts. Passing a width makes CSS media queries (e.g. Tailwind'smax-sm:/sm:breakpoints) fire as they would on that device — very useful for screenshotting and verifying responsive UIs.Changes
--width <px>/--height <px>— set the viewport (height defaults to 900 when only width is given)--device <name>— preset viewport size classes:mobile,tablet,desktop,wide,ultrawide(mobileandtabletalso send a mobile user-agent)ResizeWindowis already provided by the selenium lib).Example:
Why size classes instead of device names
Headless Firefox enforces a minimum window width (~450px) at the Gecko widget layer, and
Set Window Rectclamps anything below it. An earlier revision had per-device presets (iphone-se375,iphone390,pixel412,iphone-max430) — but the clamp meant all of them rendered at the same 450px viewport, differing only in height. Presets are now named by what the tool can actually deliver, andmobiledeclares the 450px floor directly (mobile breakpoints likematchMedia("(max-width: 639px)")still match). Explicit--width/--heightremain for exact sizes above the floor.