Skip to content

feat(routeFromHar): add interceptAPIRequests option#41294

Open
stkevintan wants to merge 1 commit into
microsoft:mainfrom
stkevintan:fix-22869
Open

feat(routeFromHar): add interceptAPIRequests option#41294
stkevintan wants to merge 1 commit into
microsoft:mainfrom
stkevintan:fix-22869

Conversation

@stkevintan

@stkevintan stkevintan commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Fixes #22869

Summary

  • Adds opt-in interceptAPIRequests option to BrowserContext.routeFromHAR so page.request.* / context.request.* calls are also served from the HAR file.
  • Defaults to false — fully backward compatible.
  • API-request lookup is restricted to entries marked _apiRequest: true (already written by the HAR recorder), so browser-side recordings are never served to API requests for the same URL.

Make `BrowserContext.routeFromHAR` also intercept requests issued via
APIRequestContext (`page.request.*` / `context.request.*`) when the new
`interceptAPIRequests: true` option is set. Defaults to `false` so existing
behavior is unchanged.

Under the hood, `HarBackend.lookup` gains an `apiRequestOnly` flag that
filters matches to entries with `_apiRequest: true` (already written by the
HAR recorder), so API-side replay never picks up a browser-side recording
for the same URL.

Fixes microsoft#22869
@github-actions

Copy link
Copy Markdown
Contributor

Test results for "MCP"

7328 passed, 1122 skipped


Merge workflow run.

@github-actions

Copy link
Copy Markdown
Contributor

Test results for "tests 1"

4 flaky ⚠️ [chromium-library] › library/chromium/chromium.spec.ts:434 › should produce network events, routing, and annotations for Service Worker (advanced) `@chromium-ubuntu-22.04-node24`
⚠️ [chromium-page] › page/workers.spec.ts:190 › should attribute network activity for worker inside iframe to the iframe `@chromium-ubuntu-22.04-node20`
⚠️ [firefox-library] › library/inspector/cli-codegen-3.spec.ts:224 › cli codegen › should generate frame locators (4) `@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`

39599 passed, 743 skipped


Merge workflow run.

@dgozman dgozman requested a review from dcrousso June 15, 2026 15:45
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] routeFromHar should also apply to apiRequestContext

1 participant