Files
Oskar Kwaśniewski 31a814ad93 feat(core): capture the whole page or a clip in screenshots (ENG-1223) (#2405)
* feat(core): add fullPage and clip to screenshots (ENG-1223)

app.screenshot(label, { fullPage, clip }) and expect(screen).toHaveScreenshot({ fullPage, clip }). A viewport clip is cut in core on any engine; a full page needs the new fullPageScreenshots engine capability, which the web engine declares.

* fix(core): give a clipped screenshot its own capture budget

* feat(electron): capture the whole page for fullPage screenshots

The Electron engine declares fullPageScreenshots: Page.captureScreenshot with captureBeyondViewport over the page's content size, cut to the clip, with the scroll offset on full-page observation pixels. The fixed-position masks land on their elements past the viewport too. Adds a clip test to the mobile benchmark's control inventory.

* test(mobile-benchmark): compare the clip once the screen holds still

On a real emulator the push transition still repaints the header right after the scenario opens, so the clip and the locator cut are compared until the screen holds still. The refusals block relies on the screenshot, restart, and clearState test leaving the app on its home list, so the clip test runs before it.

* fix(electron): honor zoom in full-page captures, refuse past 16384 px

Under browser zoom the capture clip is read in zoomed pixels, so the page rectangle and the caller's clip scale by cssVisualViewport.zoom. Past 16384 image pixels on a side Chromium repeats the top of the page, so such a capture is refused with UNSUPPORTED_CAPABILITY and the caller clips it. Tests cover masks on a scrolled window and a fixed bottom field, zoom, and the limit, at a pinned scale factor; the mobile clip test measures the header in each round.

* fix(web): keep the asked-for CSS scale on full-page pixels

A page width read before Playwright stops animations can differ from the captured one, so full-page observation pixels report scale 1, the scale they were asked for, and read only the scroll. The Electron tests build their data URLs escaped, as the others do.

* test(electron): load full-page test pages from a file, not built code

The pages the new full-page tests show are written beside the app's main script and loaded with loadFile, so no page text is built into the script CodeQL reads as code.

* fix(core): refuse a viewport clip before capturing it

A clip with nothing of the viewport inside it fails before the engine takes a screenshot. The Electron viewport capture reads the layout only at CSS scale again, so a device-scale app.screenshot() costs one round trip. Clarifies the clip and pixels docs, and the message for a screenshot that cannot be decoded.

* fix(core): name a clip under one pixel as such

A clip inside the viewport that rounds to no pixel of the screenshot now says so, rather than calling the clip outside the viewport.
2026-12-02 15:20:07 +01:00
..