feat(web): add bounded buffered file uploads
- Add
web({ fileUploads: 'buffered' })for tests that inspect multipart request bytes before forwarding. Chromium can omit disk-backed file bytes from intercepted request bodies; replaying that body can truncate the upload. - Read the selected files through bounded regular-file handles, then hand their actual bytes to Playwright's native file-payload API. No HTTP body or destination is rewritten. Path-based uploads remain the default, including their existing large-file behavior.
- Buffered mode limits the selection to 32 files and 2,000,000 bytes. It refuses symlinks, files changed during reading, oversized selections and PDF extensions without a PDF header. It uses basenames and normal MIME lookup. Payload
lastModifiedfollows Playwright's current-time behavior, documented as opt-in.
engine: web({ fileUploads: 'buffered' })
The common preparation helper can also serve the preferred button-upload path in #958. This PR contains none of the closed #1386 chooser-node workflow. It grants no upload destination or mutation permission and changes no redirect policy.
Issue
Related to the native upload work in #954 and #958. This addresses the separate file-byte omission seen when a guarded caller inspects and replays multipart bodies.
Verified
Ran it locally: yes, deterministic Chromium and owned loopback HTTP, Playwright1.64.1 and Node24.19.0.
pnpm --filter @e2e-dev/web exec vitest run tests/unit/upload-files.test.ts tests/unit/actions.test.ts tests/unit/protected-app-options.test.ts tests/integration/buffered-upload.test.ts: 72 checks passed in independent review. The server verifies the selected binary file's exact bytes, name, size and SHA. The page receives200, and a307 response is not followed.- Core/web builds and package typecheck passed, including public negative type checks. File-change, pathname replacement, cancellation after reads/cleanup, aggregate byte/count bounds and the default no-read path have regression coverage. A real file-close preparation delay times out before any native call as NOT_ACTIONABLE; a started native call that hangs remains ACTION_MAY_HAVE_COMMITTED. The old classifier fails this causal control,12pass/1fail. Non-upload classification and cancellation remain unchanged.
| Native multipart control | Path/default | Buffered |
|---|---|---|
| Intercepted selected file | File content omitted | Exact selected bytes present |
| Strict byte guard | Refuses before forwarding | Accepts exact name/size/SHA |
| Owned server | No upload forwarded | Exact bytes received once |
| Redirect follow | No change | 307 target never reached |
These are native protocol and source checks, not a real-agent or production-application pass. Full CLI/testbed/benchmark and model verification have not run for this change; no model or production call was made. A separate real-agent loopback allocation is planned before any application opts in. The complete application upload failures remain retained.