Skip to content

feat(storage): capture OPFS in storage state - #42248

Merged
Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-41400
Sep 1, 2026
Merged

feat(storage): capture OPFS in storage state#42248
Yury Semikhatsky (yury-s) merged 3 commits into
microsoft:mainfrom
yury-s:fix-41400

Conversation

@yury-s

Copy link
Copy Markdown
Member

Summary

  • add opt-in OPFS capture and restoration to storage state
  • preserve binary files, nested directories, and empty directories across browser and request contexts
  • handle Firefox worker-based writes and persistent WebKit contexts

Fixes #41400

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@yury-s
Yury Semikhatsky (yury-s) marked this pull request as ready for review August 14, 2026 17:24
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Hi, I'm the Playwright bot — I took a first pass at the CI failures here.

🟡 No failure points at this PR, but three timeouts I can't fully clear

The four red tests are all timedOut, none touch the OPFS/storage-state path this PR changes, and they cluster on two specific bots (mcp-macos-latest-chrome, windows-latest-node22) — the signature of slow/overloaded runners, not a code bug. One is a confirmed pre-existing flake; the other three I can't strictly prove either way, so I'm landing on yellow.

Details

Overall: the diff is scoped to OPFS capture in storage state (fetch.ts, browserContext.ts, networkDispatchers.ts, protocol, docs). It doesn't touch MCP CLI or the trace/UI-mode network tab. Every failure is a timeout, and the same tests time out on the same bots across this PR's last few runs (31830009958, 31830010211) as in the latest report — a bot/OS pattern, not a per-feature one.

Pre-existing flake / infra

  • [firefox] › mcp/cli-json.spec.ts:220 › request and per-part commands return JSON result (mcp-windows-latest-firefox) — pre-existing flake. In the test-results DB it failed 4 of 723 runs across 2 unrelated PRs, passing the rest. The PR doesn't touch the MCP JSON path.

Uncertain (most likely infra, unproven)

  • [chrome] › mcp/cli-core.spec.ts:248 › click in iframe (mcp-macos-latest-chrome)

  • [chrome] › mcp/cli-devtools.spec.ts:189 › request with out-of-range index (mcp-macos-latest-chrome)

  • [playwright-test] › ui-mode-test-network-tab.spec.ts:107 › should filter network requests by url (windows-latest-node22)

    All three have 0 failures across 700–1000+ prior runs in the DB, so I can't cite the same test failing off this PR to call it a flake outright. But they can't be reached by the diff — OPFS storage-state capture has nothing to do with clicking an iframe, an out-of-range MCP request index, or filtering the UI-mode network tab — and all three timedOut on the same two bots in earlier runs of this same PR (31830009958, 31830010211). That reads as slow-runner/infra noise. To be sure, a rerun on those bots should clear them; if the identical (test, bot) timeouts persist across reruns, worth a second look at macOS-chrome / Windows agent load.

Triaged by the Playwright bot - agent run

Comment thread docs/src/api/class-apirequest.md Outdated
});

it('should round-trip OPFS in a persistent WebKit context', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/41400' } }, async ({ browserName, launchPersistent, server }) => {
it.skip(browserName !== 'webkit');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's a weird feature, why supporting something that does not work on major browsers?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. But WebKit doesn't have current plans to support it in ephemeral contexts and adding it would be a non-trivial effort: yury-s/WebKit@main...yury-s:WebKit:opfs-in-memory

@github-actions

This comment has been minimized.

Add opt-in OPFS serialization and restoration for browser and request
context storage state, including cross-browser handling and round-trip
coverage.

Fixes: microsoft#41400
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🟢 CI is clear — the one failure is a pre-existing flake

Hi, I'm the Playwright bot and I took a first look at the CI failures.

The latest "tests 1" run has a single real failure, ui-mode-test-network-tab.spec.ts:146 › should pretty-print JSON request body on windows-latest-node22. It's a known flake that also fails on unrelated PRs, and this PR only touches OPFS storage-state code — nothing in the UI-mode network tab. Nothing here to act on.

Details

This PR is OPFS storage-state capture: storageScript.ts, browserContext/fetch client + server, dispatchers, protocol specs, and two storage-state tests. It doesn't touch the UI-mode trace viewer or the network-tab JSON pretty-printer.

Pre-existing flake / infra

  • [playwright-test] › ui-mode-test-network-tab.spec.ts:146 › should pretty-print JSON request body @windows-latest-node22 — flake. Across the test-results DB this test is green 4488 of 4490 runs; the only other failure is on windows-latest-node22 in PR feat(chromium): roll to r1237 #42072 (roll-into-pw-chromium/1237), a Chromium roll with no relation to this change. Same test, same bot, unrelated PR — the PR isn't responsible.

Flaky (rescued on retry, no action needed)

  • [chromium-library] › library/video.spec.ts:736 › screencast › should work with video+trace @frozen-time-library-chromium-linux
  • [chromium-library] › library/popup.spec.ts:260 › should not throw when click closes popup @chromium-ubuntu-22.04-node24

Both passed on retry in this same report and are unrelated to storage state.

Triaged by the Playwright bot - agent run

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

8 flaky ⚠️ [chromium-library] › library/beforeunload.spec.ts:130 › should support dismissing the dialog multiple times `@chromium-ubuntu-22.04-arm-node20`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:179 › serviceWorker(), and fromServiceWorker() work `@realtime-time-library-chromium-linux`
⚠️ [chromium-library] › library/chromium/chromium.spec.ts:213 › should intercept service worker requests (main and within) `@chromium-ubuntu-22.04-node24`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:257 › third party 'Partitioned;' cookies `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/browsercontext-cookies-third-party.spec.ts:470 › top level 'Partitioned;' cookie and same origin iframe `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-emulate-media.spec.ts:144 › should keep reduced motion and color emulation after reload `@firefox-ubuntu-22.04-node20`
⚠️ [firefox-page] › page/page-event-request.spec.ts:181 › should return response body when Cross-Origin-Opener-Policy is set `@firefox-ubuntu-22.04-node20`
⚠️ [webkit-library] › library/browsertype-connect.spec.ts:807 › run-server › should upload a folder `@webkit-ubuntu-22.04-node20`

51290 passed, 1249 skipped


Merge workflow run.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7711 passed, 1229 skipped


Merge workflow run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Capture OPFS in storageState

3 participants