Web: viewport DSL keyword (Playwright-style, web-only)#77
Closed
richjun wants to merge 2 commits into
Closed
Conversation
Adds a web-only `viewport` surface that mirrors Playwright's two-tier
viewport model: an initial `viewport: {width, height}` in the flow
header (analogous to browser.newContext({ viewport })) and an in-flow
`viewport` step that resizes mid-run (analogous to page.setViewportSize).
- flow schema: new ViewportStep + Config.Viewport (positive int W/H,
validated at parse time, no runtime workaround for missing/zero/neg).
- core: optional ViewportConfigurer interface so the executor can apply
the flow-header viewport without coupling to the web driver.
- web (CDP) driver: SetViewport(w,h) calls Emulation.setDeviceMetrics
via go-rod and updates the cached viewportW/H used by tap coords,
orientation, and initPage for future tabs.
- executor: flow_runner applies Config.Viewport via the optional
interface before any step runs; mobile drivers silently skip.
Mobile drivers fall through their existing default branch — the step
returns a clear "not supported" message rather than being silently
ignored.
- parser: viewport mapping accepted in header and in-flow; missing/ zero/negative width or height rejected at parse time; isStepType recognizes the new keyword. - step: ViewportStep registered in the step-type sanity matrix and Describe renders "viewport: WxH". - CDP driver: TestViewportStep dispatches mid-flow resize and verifies window.innerWidth/innerHeight reflect the new size; SetViewport rejects non-positive dimensions; compile-time assertion that *Driver satisfies core.ViewportConfigurer so flow_runner can pick it up.
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 a
viewportkeyword to the YAML DSL — Playwright-style, web-only. Not in upstream Maestro.Two surfaces, same shape as
playwright'sviewportoption:width/heightrequired positive ints. Missing/zero/negative → parse-time error, browser not started.step type *flow.ViewportStep is not supported.Emulation.setDeviceMetricsOverride(the same CDP primitive Playwright uses) — no shim.Test plan
go test ./pkg/flow/...— parser + step matrixgo test ./pkg/driver/browser/cdp/ -run TestViewport— real Chromium resize,window.innerWidthverifiedinnerWidth × innerHeightmatches every step🤖 Generated with Claude Code