Skip to content

feat: add page-scoped network mocks - #3384

Merged
OrKoN merged 3 commits into
ChromeDevTools:mainfrom
marco-prontera:feat/network-request-overrides
Nov 10, 2026
Merged

OrKoN merged 3 commits into
ChromeDevTools:mainfrom
marco-prontera:feat/network-request-overrides

Conversation

@marco-prontera

@marco-prontera marco-prontera commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Part 1 of 3 for #848: the core and local-file replacements.

mock_network 1 --body file.js -> create or update a page mock
mock_network 1 [filters]     -> inspect mocks
remove_network_mock 1       -> remove matching mocks, or all

Network mocks are disabled by default in MCP and CLI. Enable them with
--categoryNetworkMocks; changing the category requires a server restart.

Adds the two-tool interface for local response files through MCP and CLI.
Rules use absolute URLPatterns with optional resource types. An omitted
query matches any query string; regex and named groups are rejected. Mocks survive reloads
and reread files on each request. Updating a rule preserves unrelated rules;
the most recently updated matching rule wins.

Inspection reports hit counts, unmatched rules, and replacement errors.
No-match navigation warnings follow main-frame document requests, so hash
changes do not trigger them.
Mocks disable the page cache and intercept all requests, so tool responses,
performance traces, and Lighthouse reports carry a measurement warning.
Changes are rejected during a trace; removing the last mock restores the
cache and stops interception.

Includes generated CLI definitions, documentation, metrics, and tests.
Follow-ups: #3420 adds upstream responses; #3421 adds abort and allow-origin.
Both are dependent drafts targeting main until their prerequisites land.

Evidence

  • Before: replacing a page resource required manual DevTools setup.
    After: local-file replacement and rebuilds work through the new tools,
    with useful diagnostics when a file disappears.
  • Rebased on main; new source and test files are registered with GN.
  • npm run sync, npm run gen, npm run format, and the full
    npm run test suite passed:
    1,863 passed, 3 skipped, 0 failed, including real Chrome integration tests.

Merge Danger

Door: two-way

Blast Radius: page

Active mocks alter request delivery and measurements for their page.

@samiyac

samiyac commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@natorion can you take an initial look to see if the PR aligns with the direction we want to take for this feature?

cc: @OrKoN

@natorion

natorion commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @marco-prontera for the thorough PR, and @samiyac for the ping.

Directionally yes. Swapping a production bundle for a local build (or pointing it at a dev server) is a real workflow for coding agents, and #848 shows the demand. I gave the branch a spin over MCP and the CLI on Canary and the core flow works well (local file and redirect, persists across reloads, rebuilds get picked up).

A few things I'd like us to sort out before landing. What do you think about the following?

1.) One tool instead of three. We are trying to keep the default tool list small to save agent context, so folding add/list/remove into a single tool (similar to set_logpoints) would fit better. OR maybe there is even a better way to do this?
2.) Keep perf traces trustworthy. A big use case in #848 is swapping a library and then tracing or running Lighthouse. Right now an active override disables the cache for the whole page and intercepts every request, which skews those numbers. This caveat somehow needs to be dealt with/communicated to the agent.
3.) Help agents notice when nothing matched. A relative pattern like /app.js* is accepted but silently matches nothing, and a failed local file only shows up as net::ERR_FAILED. A warning plus hit counts in the list output would save turns.
4.) Blocklist on redirects. A cross-origin redirect target that 302s to a host on --blocked-url-pattern currently gets through. That should be closed before merge. Minor: the CLI examples in the skill use --urlPattern / --id flags, but those are positional.

@curbeloalexey1-del

curbeloalexey1-del commented Nov 5, 2026 via email

Copy link
Copy Markdown

@OrKoN

OrKoN commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

I think with a single tool we need to have a textual representation for a single override to make it usable via CLI.

@marco-prontera
marco-prontera force-pushed the feat/network-request-overrides branch from 3979aa0 to b64a092 Compare November 5, 2026 10:32
@marco-prontera

Copy link
Copy Markdown
Contributor Author

Thanks @marco-prontera for the thorough PR, and @samiyac for the ping.

Directionally yes. Swapping a production bundle for a local build (or pointing it at a dev server) is a real workflow for coding agents, and #848 shows the demand. I gave the branch a spin over MCP and the CLI on Canary and the core flow works well (local file and redirect, persists across reloads, rebuilds get picked up).

A few things I'd like us to sort out before landing. What do you think about the following?

1.) One tool instead of three. We are trying to keep the default tool list small to save agent context, so folding add/list/remove into a single tool (similar to set_logpoints) would fit better. OR maybe there is even a better way to do this? 2.) Keep perf traces trustworthy. A big use case in #848 is swapping a library and then tracing or running Lighthouse. Right now an active override disables the cache for the whole page and intercepts every request, which skews those numbers. This caveat somehow needs to be dealt with/communicated to the agent. 3.) Help agents notice when nothing matched. A relative pattern like /app.js* is accepted but silently matches nothing, and a failed local file only shows up as net::ERR_FAILED. A warning plus hit counts in the list output would save turns. 4.) Blocklist on redirects. A cross-origin redirect target that 302s to a host on --blocked-url-pattern currently gets through. That should be closed before merge. Minor: the CLI examples in the skill use --urlPattern / --id flags, but those are positional.

Thanks @natorion, these points are great and thank you for the explanation for all of them, you helped me understand some of the principles behind the goals.
I'm working on it, I should almost be there.

@marco-prontera

Copy link
Copy Markdown
Contributor Author

I think with a single tool we need to have a textual representation for a single override to make it usable via CLI.

Do you mean a compact string representation for each override, similar to set_logpoint?

@OrKoN

OrKoN commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

I think with a single tool we need to have a textual representation for a single override to make it usable via CLI.

Do you mean a compact string representation for each override, similar to set_logpoint?

yes, if it is possible (I have not really thought about it). Otherwise the CLI needs to accept plain JSON objects that are a bit harder to read and work with.

@OrKoN

OrKoN commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

Perhaps let's brain storm about what is the ideal payload for network overrides is before changing code. Once we agree, let's split the PR into a stack of smaller PRs to simplify review.

@OrKoN

OrKoN commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

It appears to be somewhat complex to work with a single command + string representation. What do you think about the following commands instead:

  • mock_network: all arguments optional: route as url pattern, resource-type (enum), abort (boolean), allow-origin (string), body (path to response body file). If only url or resource-type (e.g., route filters) is provided, it reads existing mocks. if no args given, reads all of them. If actions are provided, the mock is updated.
  • remove_network_mock: all arguments optional: route as url pattern, resource-type (enum).

WDYT?

@marco-prontera

Copy link
Copy Markdown
Contributor Author

It appears to be somewhat complex to work with a single command + string representation. What do you think about the following commands instead:

  • mock_network: all arguments optional: route as url pattern, resource-type (enum), abort (boolean), allow-origin (string), body (path to response body file). If only url or resource-type (e.g., route filters) is provided, it reads existing mocks. if no args given, reads all of them. If actions are provided, the mock is updated.
  • remove_network_mock: all arguments optional: route as url pattern, resource-type (enum).

WDYT?

I've used the three original tools extensively in practice. I initially chose add_network_override, list_network_overrides, and remove_network_override because this separation felt natural and consistent with the workflow in the browser Developer Tools UI.

I'm happy to move in this direction using two tools. Before proceeding, how would you handle URL overrides? The current implementation supports both local response files and override URLs, while the proposed body parameter covers local files.
Redirecting to other URLs is useful, for example, when you have different paths for the same product. One for the staging environment and one for production (which is actually integrated into a website). In this case, you make changes with agents and want them to open the website and use either the staging or local version. Or, your architecture might generate the final script via a backend pipeline that you can't reproduce locally, so in that case you need to use the staging version, and replacement URLs are a great solution for this use case. ps I've developed a lot of 3p scripts, and this use case is really useful because some 3p scripts are optimized by excluding parts of the code for certain geographic locations, and having URL redirects is common and really useful for replicating different users.

@marco-prontera

Copy link
Copy Markdown
Contributor Author

Perhaps let's brain storm about what is the ideal payload for network overrides is before changing code. Once we agree, let's split the PR into a stack of smaller PRs to simplify review.

Yes once we agree I will create smaller PRs sounds good, thank you!

@OrKoN

OrKoN commented Nov 5, 2026

Copy link
Copy Markdown
Collaborator

I think supporting url redirect is fine as long as we make sure that the allowlists/blocklists apply to that URL including redirects (in the 2 tool design proposal it could be modeled as --upstream param mutually exclusive with --body). @natorion WDYT? 2 tool design or the original 3 tool design is better?

@marco-prontera
marco-prontera force-pushed the feat/network-request-overrides branch from 91fed8f to 7d51987 Compare November 5, 2026 12:00
@marco-prontera

Copy link
Copy Markdown
Contributor Author

in the meanwhile I will do some tests with all the three kind of implementation just to have a measure from some example of use cases

@marco-prontera

Copy link
Copy Markdown
Contributor Author

Hi @OrKoN, I tried all 3 choices of implementation, 3 tools, 1 and two as you proposed.
I like the two tool approach, and splitting this into a stack of smaller PRs makes sense.
I'd propose, this one could have only the tools and local file replacement, one for url replacement and the last one for abort and allow-origin support. Any suggestion is appreciated

@OrKoN

OrKoN commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@marco-prontera thanks! do you have any number from your test? did you try only the MCP interface or also the CLI interface?

@marco-prontera

marco-prontera commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor Author

@marco-prontera thanks! do you have any number from your test? did you try only the MCP interface or also the CLI interface?

Yes, I’ve now tested all three versions with real Chrome, through both MCP and the CLI. On a real website, I replaced the same JavaScript resource with a local file and verified that it executed and picked up subsequent file changes.

Version MCP checks passed MCP calls CLI checks passed CLI commands
3 tools 18/18 77 18/18 77
1 tool 18/18 73 18/18 73
2 tools 18/18 73 18/18 73

These cover the same scenarios, including updates, removal, diagnostics, redirect allowlists/blocklists, and trace/Lighthouse warnings. Counts include reloads and verification, excluding session setup and cleanup.

The two-tool version also passed three additional checks on both interfaces: abort toggling, body/upstream exclusivity, and allow-origin with filtered removal—13 extra calls per interface.

The practical difference was updating one mock while keeping another: three tools needed remove + add; the other versions needed one call. With the single tool, though, I had to resend the unchanged mock too.

I leave the decision to you, but from the usage and this report I think the 2 tools choice is winning here.
Do you need some different kind of test? Any suggestion is appreciated

@OrKoN

OrKoN commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@marco-prontera thanks! I think 2 tool design with 1 tool to read + edit and 1 tool to remove might be indeed the best and I think it is more natural for the CLI interface. let's update this PR for this and I will do more testing next week.

@OrKoN
OrKoN self-requested a review November 6, 2026 12:43
@marco-prontera

Copy link
Copy Markdown
Contributor Author

@marco-prontera thanks! I think 2 tool design with 1 tool to read + edit and 1 tool to remove might be indeed the best and I think it is more natural for the CLI interface. let's update this PR for this and I will do more testing next week.

Perfect I already updated the PR as you suggested, I prefer it too. Do I need to split it, into 3 PRs?

@OrKoN

OrKoN commented Nov 6, 2026

Copy link
Copy Markdown
Collaborator

@marco-prontera it would be great (using a github pr stack) to allow for more careful review of the parts of the change

@marco-prontera marco-prontera changed the title feat: add network request overrides feat: add network mocking tools Nov 6, 2026
@marco-prontera
marco-prontera force-pushed the feat/network-request-overrides branch from 7c8b72e to 983cc3b Compare November 6, 2026 14:09
@marco-prontera marco-prontera changed the title feat: add network mocking tools feat: add page-scoped network mocks Nov 6, 2026
@marco-prontera

Copy link
Copy Markdown
Contributor Author

@OrKoN I’ve split the change into three PRs, keeping the two-tool design:

#3384: core and local-file replacements
#3420: upstream responses and redirect checks
#3421: abort and allow-origin

The last two are dependent drafts targeting main, so their diffs currently include the earlier changes. Could you publish the core and upstream branches in this repository so we can retarget the drafts and review each part separately? Otherwise, I’ll update them as each preceding PR lands.

@natorion

natorion commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

Seems like 2 tools is the best approach, so +1 to that one.

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please address the following:

  1. Remove the stale entries from src/telemetry/tool_call_metrics.json: the set_network_overrides tool and the deprecated abort, allow_origin_length, and upstream_length args of mock_network. These names never shipped on main; they are leftovers of earlier revisions of this branch, and npm run gen keeps them because it only marks missing entries as deprecated.

  2. Wrap the wildcard characters in backticks in the route descriptions in src/tools/network.ts (for example `*` matches any sequence). Prettier turns the current '*' ... '*' into emphasis, so docs/tool-reference.md now reads '_' matches any sequence and configure '_'.

  3. Declare verifyFilesSchema: {body: true} on mock_network and drop the first context.validatePath(params.body) call from the handler. ToolHandler.validateToolFiles already validates and resolves path parameters before the handler runs (see src/tools/memory.ts); keep only the per-read revalidation inside loadResponseFile.

  4. Use one term in all user-facing text. The tools are mock_network / remove_network_mock, but the measurement warning in src/formatters/NetworkOverridesFormatter.ts, the error in McpPage.#getNetworkOverrideManagerForChanges, the ignoreCache description, and the SKILL say "network overrides".

  5. Simplify NetworkOverrideManager.#activate: remove the two isClosed() checks after the awaited calls and the nested cleanup branches. A page that closes mid-activation makes the next CDP call reject, and McpPage.dispose() → manager.dispose() already releases the state; #mock rolls back the rule set on any rejection.

  6. Count navigations from the document request of the main frame inside #handleRequest instead of the framenavigated listener. framenavigated also fires for same-document navigations (hash changes), which produces the "no requests matched after navigation" warning without any request, and removing the listener drops one lifecycle to manage.

  7. Remove the URL-redaction replace(...) on lastError in #handleRequest. The message is built from a validated local file path and an fs error, so it contains no URL.

  8. Remove the test exposes optional scalar CLI parameters without a string representation in tests/tools/network.test.ts. It asserts that optional Zod fields accept undefined and parse strings, which is Zod behavior and not a scenario of this tool.

  9. Nit: in scripts/eval_scenarios/network_override_local_file_test.ts, compile overrideCall.args.route and assert that it matches the my-third-party.js URL instead of comparing it to the literal *my-third-party.js*. A model that emits */my-third-party.js is correct but fails the scenario.

  10. Nit: replace the manual guard[Symbol.dispose]() in #runLifecycleOperation with using guard = await this.#lifecycleMutex.acquire();.

Comment thread src/tools/network.ts Resolved
Comment thread src/tools/network.ts Resolved
@marco-prontera
marco-prontera requested a review from OrKoN November 9, 2026 14:44
@marco-prontera

Copy link
Copy Markdown
Contributor Author

Please address the following:

  1. Remove the stale entries from src/telemetry/tool_call_metrics.json: the set_network_overrides tool and the deprecated abort, allow_origin_length, and upstream_length args of mock_network. These names never shipped on main; they are leftovers of earlier revisions of this branch, and npm run gen keeps them because it only marks missing entries as deprecated.
  2. Wrap the wildcard characters in backticks in the route descriptions in src/tools/network.ts (for example `*` matches any sequence). Prettier turns the current '*' ... '*' into emphasis, so docs/tool-reference.md now reads '_' matches any sequence and configure '_'.
  3. Declare verifyFilesSchema: {body: true} on mock_network and drop the first context.validatePath(params.body) call from the handler. ToolHandler.validateToolFiles already validates and resolves path parameters before the handler runs (see src/tools/memory.ts); keep only the per-read revalidation inside loadResponseFile.
  4. Use one term in all user-facing text. The tools are mock_network / remove_network_mock, but the measurement warning in src/formatters/NetworkOverridesFormatter.ts, the error in McpPage.#getNetworkOverrideManagerForChanges, the ignoreCache description, and the SKILL say "network overrides".
  5. Simplify NetworkOverrideManager.#activate: remove the two isClosed() checks after the awaited calls and the nested cleanup branches. A page that closes mid-activation makes the next CDP call reject, and McpPage.dispose() → manager.dispose() already releases the state; #mock rolls back the rule set on any rejection.
  6. Count navigations from the document request of the main frame inside #handleRequest instead of the framenavigated listener. framenavigated also fires for same-document navigations (hash changes), which produces the "no requests matched after navigation" warning without any request, and removing the listener drops one lifecycle to manage.
  7. Remove the URL-redaction replace(...) on lastError in #handleRequest. The message is built from a validated local file path and an fs error, so it contains no URL.
  8. Remove the test exposes optional scalar CLI parameters without a string representation in tests/tools/network.test.ts. It asserts that optional Zod fields accept undefined and parse strings, which is Zod behavior and not a scenario of this tool.
  9. Nit: in scripts/eval_scenarios/network_override_local_file_test.ts, compile overrideCall.args.route and assert that it matches the my-third-party.js URL instead of comparing it to the literal *my-third-party.js*. A model that emits */my-third-party.js is correct but fails the scenario.
  10. Nit: replace the manual guard[Symbol.dispose]() in #runLifecycleOperation with using guard = await this.#lifecycleMutex.acquire();.

Applied, thank for your review

Comment thread src/tools/network.ts Resolved

@OrKoN OrKoN left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think this is the last round of comments I have:

  1. Rebase on main and add the new files to src/BUILD.gn (NetworkOverrideManager.ts, formatters/NetworkOverridesFormatter.ts) and tests/BUILD.gn (NetworkOverrideManager.test.ts, network_overrides.test.ts, tools/network_override_measurements.test.ts). main now lists every .ts file explicitly, so npm run build and npm run test skip the new modules and tests on the merge commit. Run npm run sync to set up gclient.

  2. Nit: use one term in code identifiers. ContextPage exposes mockNetwork / removeNetworkMocks next to listNetworkOverrides, and NetworkMockInput / NetworkMockFilter sit next to NetworkOverride / NetworkOverrideManager / NetworkOverridesFormatter; rename at least listNetworkOverrides to listNetworkMocks.

  3. Nit: remove the method and headers options from createMockHTTPRequest in tests/mocks.ts. No test passes them.

  4. Nit: remove the this.#page.isClosed() check in NetworkOverrideManager.#mock after #createOverride. #activate performs the same check and throws the same class of error, and when interception is already active no CDP call follows.

@marco-prontera
marco-prontera force-pushed the feat/network-request-overrides branch from e03a77d to 00ded7b Compare November 10, 2026 16:12
@marco-prontera
marco-prontera requested a review from OrKoN November 10, 2026 16:15
@OrKoN
OrKoN enabled auto-merge November 10, 2026 16:22
@OrKoN
OrKoN disabled auto-merge November 10, 2026 16:23
@OrKoN
OrKoN added this pull request to the merge queue Nov 10, 2026
Merged via the queue into ChromeDevTools:main with commit 1d692d3 Nov 10, 2026
15 checks passed
marco-prontera added a commit to marco-prontera/chrome-devtools-mcp that referenced this pull request Nov 11, 2026
## Summary

Part 2 of 3 for ChromeDevTools#848. Builds on the network mock core merged in ChromeDevTools#3384.
This PR contains only upstream response support.

```text
mock_network 1 --upstream URL
  -> validate URL -> fetch -> validate each redirect -> fulfill response
```

Adds `upstream` as an alternative to `body` for GET/HEAD requests.
Allowlists and blocklists apply before contacting the initial target and
every redirect destination, including same-origin replacements.
Cross-origin hops drop credentials and other non-allowlisted headers.
Fetch negotiates compression independently of Chrome. Decoded responses
omit stale compression and length headers, and separate Set-Cookie
headers
are preserved.

The redirect loop and URL policy checks are shared with `McpContext`
resource loading. Resource loading still returns text and rejects HTTP
errors; mocks preserve response status and binary bodies. Shared errors
redact URL credentials and query strings, report missing Location
headers,
and release redirect bodies on error paths.

Includes mutually exclusive parameter validation, generated CLI/docs,
redirect-policy tests, and browser coverage. ChromeDevTools#3421 adds `abort` and
`allowOrigin` after this PR.

Network mocks are disabled by default in MCP and CLI. Enable them with
`--categoryNetworkMocks`; changing the category requires a server
restart.

## Evidence

- **Before:** mocks could only serve local files.
**After:** upstream responses work across reloads, and redirects to
blocked
  destinations fail before the destination is contacted.
- Rebased after ChromeDevTools#3384 merged; source and test files are registered with
GN.
- `npm run format` and the full
  `npm run test -- --test-concurrency=2` suite passed on this revision:
1,890 passed, 3 skipped, 0 failed, including real Chrome integration
tests.

- Three regression cases fail on the previous revision and pass with
these
fixes: same-origin and cross-origin Accept-Encoding, and multiple
Set-Cookie.

## Merge Danger

**Door:** two-way

**Blast Radius:** network

Opt-in upstream responses use server-side fetches and retain the core
measurement warning.
Lightning00Blade pushed a commit to jaeminbird/chrome-devtools-mcp that referenced this pull request Nov 11, 2026
🤖 I have created a release *beep* *boop*
---


##
[1.13.0](ChromeDevTools/chrome-devtools-mcp@chrome-devtools-mcp-v1.12.0...chrome-devtools-mcp-v1.13.0)
(2026-11-11)


### 🎉 Features

* add logpoints built on the DevTools BreakpointManager
([ChromeDevTools#3211](ChromeDevTools#3211))
([0877ee0](ChromeDevTools@0877ee0))
* add page-scoped network mocks
([ChromeDevTools#3384](ChromeDevTools#3384))
([1d692d3](ChromeDevTools@1d692d3))
* support upstream network mock responses
([ChromeDevTools#3420](ChromeDevTools#3420))
([c4bf342](ChromeDevTools@c4bf342))


### 🛠️ Fixes

* **config:** accept config files with a UTF-8 BOM
([ChromeDevTools#3365](ChromeDevTools#3365))
([63170b1](ChromeDevTools@63170b1))
* **console:** stop resolving a cyclic Error.cause chain after 10 causes
([ChromeDevTools#3338](ChromeDevTools#3338))
([172656a](ChromeDevTools@172656a))
* disable set_logpoints when --no-javascript-evaluation is set
([ChromeDevTools#3415](ChromeDevTools#3415))
([11fcc59](ChromeDevTools@11fcc59)),
closes
[ChromeDevTools#3414](ChromeDevTools#3414)
* **extensions:** say list_extensions only lists unpacked extensions
([ChromeDevTools#3433](ChromeDevTools#3433))
([1383bb9](ChromeDevTools@1383bb9))
* ignore an invalid cached version in the update check
([ChromeDevTools#3392](ChromeDevTools#3392))
([3a9f378](ChromeDevTools@3a9f378))
* **input:** validate press_key and submitKey parameters in Zod schema
([ChromeDevTools#3382](ChromeDevTools#3382))
([375a269](ChromeDevTools@375a269))
* **network:** start an empty request list for navigations without a
request
([ChromeDevTools#3357](ChromeDevTools#3357))
([b701776](ChromeDevTools@b701776))
* normalize non-Error values thrown by tool handlers
([ChromeDevTools#3068](ChromeDevTools#3068))
([535a3dc](ChromeDevTools@535a3dc))
* **performance:** error when performance_stop_trace is called on a
non-recording page
([ChromeDevTools#2971](ChromeDevTools#2971))
([ChromeDevTools#3117](ChromeDevTools#3117))
([1ab630a](ChromeDevTools@1ab630a))
* **plugin:** launch the Claude Code MCP server with npx --prefix
([ChromeDevTools#3353](ChromeDevTools#3353))
([a24334d](ChromeDevTools@a24334d))
* preserve task serialization on request cancellation
([ChromeDevTools#3079](ChromeDevTools#3079))
([03fd4e8](ChromeDevTools@03fd4e8))
* report page loads that keep the URL
([ChromeDevTools#3395](ChromeDevTools#3395))
([3cc38bb](ChromeDevTools@3cc38bb))
* save binary request bodies byte for byte
([ChromeDevTools#3404](ChromeDevTools#3404))
([e3eb901](ChromeDevTools@e3eb901))
* suggest --headless when Chrome cannot find an X server
([ChromeDevTools#3428](ChromeDevTools#3428))
([8b0856a](ChromeDevTools@8b0856a))
* **url:** unwrap view-source: before all scheme checks in validateUrl
([ChromeDevTools#3335](ChromeDevTools#3335))
([7275268](ChromeDevTools@7275268))
* **wait:** explain whitespace-sensitive text matching
([ChromeDevTools#3350](ChromeDevTools#3350))
([81a0379](ChromeDevTools@81a0379))


### 📄 Documentation

* add Pi client configuration
([ChromeDevTools#3364](ChromeDevTools#3364))
([bc0d93e](ChromeDevTools@bc0d93e))
* clarify custom browser launch and connection options
([ChromeDevTools#3386](ChromeDevTools#3386))
([7e10c08](ChromeDevTools@7e10c08))
* **input:** note that press_key cannot drive native <select>
popups on macOS
([ChromeDevTools#3288](ChromeDevTools#3288))
([8e79bd0](ChromeDevTools@8e79bd0))


### ⚡ Performance

* **memory:** drop async parents of request initiators in
NetworkCollector
([ChromeDevTools#3345](ChromeDevTools#3345))
([ca6f834](ChromeDevTools@ca6f834)),
closes
[ChromeDevTools#3344](ChromeDevTools#3344)


### 🏗️ Refactor

* re-export only used Zod runtime members from third_party barrel
([ChromeDevTools#3439](ChromeDevTools#3439))
([6b056c8](ChromeDevTools@6b056c8))
* reuse Zod schemas and validate integer viewport dimensions
([ChromeDevTools#3367](ChromeDevTools#3367))
([3c609da](ChromeDevTools@3c609da))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: Alex Rudenko <[email protected]>
daedal-ping Bot pushed a commit to DaedalGames/chrome-devtools-mcp that referenced this pull request Nov 11, 2026
## Summary

Adds `abort` and `allowOrigin` actions to page-scoped network mocks.
The core (ChromeDevTools#3384) and upstream responses (ChromeDevTools#3420) are already on `main`.
Closes ChromeDevTools#848.

```text
abort=true                  -> fail matching requests
abort=false                 -> resume the stored source or browser request
allowOrigin + body/upstream -> set Access-Control-Allow-Origin
allowOrigin without source  -> configuration error
```

Omitted actions retain existing settings; `abort=true` takes precedence
over the response source and origin header. `allowOrigin` requires a
`body` or `upstream` source, supplied in the same call or already stored
on the matching rule. It accepts `*`, `null`, or a serialized origin.
This does not configure preflight or credential headers. Only upstream
sources use server-side GET/HEAD fetches. With no source, `abort=false`
sends the request to the network and still takes precedence over older
matching mocks.

Includes validation, generated CLI/docs, and tests for abort toggling,
preserving sources, origin headers, and rejected aborts without retries
or false replacement errors.

Network mocks are disabled by default in MCP and CLI. Enable them with
`--categoryNetworkMocks`; changing the category requires a server
restart.

## Evidence

- **Before:** rules needed a local body or upstream source.
  **After:** agents can abort requests or set an origin header on a
replacement response, then update actions without replacing its source.
- A real Chrome test verifies that a cross-origin fetch fails without
  `allowOrigin`, succeeds with it, and fails again with `abort: true`.
- Regression tests reproduce source-less origins, invalid origin values,
  and duplicate aborts on the previous revision (12 failures).
- `npm run gen` (including build and format) and the full
  `npm run test -- --test-concurrency=2` suite passed:
  1,955 passed, 3 skipped, 0 failed.
- Updated with `main` (`cf587b48`) and tested with Chrome for Testing
157.

## Merge Danger

**Door:** two-way

**Blast Radius:** page

These actions are opt-in and retain the existing measurement warning.
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.

5 participants