feat(app): grant every permission with app.permissions: 'all'

Merged
IM
9h ago
+474-67

What and why

  • app.permissions takes 'all' as well as a map: grant every permission the target's engine can grant. Nothing is granted unless the target asks, and a map works as before.
  • mobile(): permissions are set before each fresh launch (app.open(), app.restart(), app.clearState()). device.openApp(app, { relaunch: true, permissions: 'all' }) does the same for one launch.
    • Both platforms: one agent-device permission all grant, which agent-device expands itself.
    • Android: every runtime permission the app's manifest declares; ones Android grants at install, such as INTERNET, are skipped. A loop over DEVICE_PERMISSIONS would fail on a permission the app doesn't declare. An app that declares none launches with nothing changed (agent-device 0.21.42, which main pins).
    • iOS simulator: each privacy service the runtime can set, with location always. The simulator refuses to set notifications ("Operation not permitted", the same as naming it today), so that prompt still needs device.alert('accept').
  • web(): every name in BROWSER_PERMISSIONS for the target's browser. A browser older than that list (a CDP attach to an older Chrome) refuses the whole grant over one type it doesn't know; for 'all' the names it reports as unknown (localNetworkAccess, storageAccess, localFonts) are left out and the rest granted. A named grant keeps the refusal.
  • Engine contract: an engine opts in with grantsAllPermissions: true (in defineEngine, the protocol manifest and its schema) and receives EngineAppInfo.allPermissions: true, so EngineAppInfo.permissions stays a map of names. For an engine that doesn't declare it, including a @e2e-dev/web or @e2e-dev/mobile released before this change, config load refuses 'all' with INVALID_CONFIG instead of handing it a string it would read as a map.
app: { bundleId: 'com.example.app', permissions: 'all' },

Browser targets: the claim asked whether 'all' should cover them or stay mobile-only. I made it grant the browser's whole list. If you'd rather keep it mobile-only, dropping grantsAllPermissions: true from the web engine is a one-line change, and config load then refuses 'all' on a web() target.

Issue

Part of #1855, item app: { permissions: 'all' } under Device and app. @okwasniewski

Verified

Ran it locally: yes, on an Android 16 emulator (Pixel 9), an iOS 27.2 simulator (iPhone 17 Pro) and Chromium.

Android, an app that declares no permissions: the examples/with-compose app, built with its DYNAMIC_RECEIVER_NOT_EXPORTED_PERMISSION removed so the manifest has no <uses-permission> at all. dumpsys package dev.e2e.examples.compose prints no declared, requested or install permissions section, and an empty runtime permissions: block. Its three deterministic tests, run with app: { bundleId: 'dev.e2e.examples.compose', permissions: 'all' }, pass:

 ✓ mobile engine for target "android" prepared 1.81s
   ✓ |android| tests/deterministic.e2e.ts > shows the greeting form 1.79s
   ✓ |android| tests/deterministic.e2e.ts > asks for a name when the field is empty 1.66s
   ✓ |android| tests/deterministic.e2e.ts > greets the name you type 2.53s
      Tests  3 passed (3)

The unmodified example app, which requests only that non-runtime permission, passes the same three tests with 'all'.

Android, an app that declares runtime permissions: com.android.camera2, with location and notifications reset first. After a run with app.permissions: 'all', dumpsys package shows POST_NOTIFICATIONS, ACCESS_FINE_LOCATION and ACCESS_COARSE_LOCATION go from granted=false to granted=true. CAMERA and RECORD_AUDIO were granted by default and stay granted.

iOS simulator: an installed app with no TCC entries, run with app.permissions: 'all'. The run wrote auth_value 2 (allowed) to TCC.db for AddressBook, Calendar, Camera, MediaLibrary, Microphone, Motion, Photos, Reminders and Siri, and rewrote the app's location authorization, which agent-device grants as location-always. The BulletinBoard store has no entry for the app afterwards, so notifications stay unset. That's why the docs say to accept that prompt with device.alert('accept').

Benchmark test: apps/mobile-benchmark/tests/device.e2e.ts gets permissions all grants the microphone without a system dialog. It resets the microphone, relaunches with permissions: 'all', and taps the Permission Prompt scenario's request button. It has to reach "Microphone enabled", so a system dialog fails it.

Web: packages/web/tests/integration/permissions.test.ts passes in Chromium (3 of 3), including the 'all' clipboard round-trip. I didn't run Firefox or WebKit; their lists are the existing BROWSER_PERMISSIONS.

Checks:

  • pnpm check passes.
  • Unit tests pass: mobile (633), web (410), and the e2e config, engine-protocol and schema-fixture tests (212).
  • Mutants: unit tests fail when the Android and iOS all grant is dropped, when the web list isn't expanded, when web stops leaving out a name an older browser doesn't know, and when config load stops refusing 'all' on an engine without grantsAllPermissions.

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.