fix(mobile): withhold a screenshot turned from the screen when a secure field is on it

KA
15h ago
+98-6

What

  • On a device screen with a secure field, a screenshot whose image is turned 90 degrees from the screen is withheld: app.screenshot() fails with POLICY_DENIED, and an observation goes without pixels.

Why

  • An iOS simulator in landscape returns the screenshot in portrait. The masks were painted in landscape coordinates onto that image, so the password field was left visible and the mask covered the navigation bar.
  • agent-device reports displayRotation only when the simulator's panel answers in time; on this simulator it did not, and the engine does not read it yet. Masking a turned image in place with it is a follow-up, as is a 180° turn (portrait-upside-down), which the shape check can't see.

How it works

  1. redactSecure returns turned when one of the image and the viewport is landscape and the other portrait (packages/mobile/src/surface.ts:2194); maskedScreenshot throws POLICY_DENIED and capturePixels withholds the pixels (:2111, :2147).

Issue

Fixes #2407

Verified

Ran it locally: yes, iPhone 17 simulator on iOS 26.5, apps/mobile-benchmark, new test tests/login-form.e2e.ts:61.

mainthis PR
the issue's repro writes the password dots unmasked; the new test fails because the screenshot is writtenPOLICY_DENIED, nothing written; login-form.e2e.ts 4/4
  • The issue's repro in portrait still writes a masked screenshot. Only a screen with a secure field and a turned image changes, so no bench:ab.
  • Not run: Android, whose screenshot follows the rotation, and a physical iPhone, whose capture's orientation I could not check; the guard fails closed there either way. pnpm --filter @e2e-dev/mobile test and pnpm check green.

Checklist

  • Changeset added (pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.
  • Breaking change: title carries !, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).
  • Docs updated in the same PR: the docs/**/*.mdx page for the behavior, and skills/e2e/ if the skill describes it.
  • Contract change: emitted .d.ts reviewed, tests/types/sdk-types.ts updated; wire change edits the schema and both fixtures.
  • Engine contract change (e2e/engine): changesets for e2e, @e2e-dev/web, and @e2e-dev/mobile.

Summary by CodeRabbit

  • Bug Fixes

    • Screenshot capture is denied with POLICY_DENIED when a secure field is visible and the captured image is rotated 90 degrees relative to the screen.
    • Agent-step observations withhold image pixels when a secure field is visible in a rotated screenshot.
    • Secure fields continue to be masked in upright screenshots. Rotated screenshots without secure fields remain available.
  • Documentation

    • Clarified when screenshot capture can return POLICY_DENIED on iOS and Android.