Skip to content

[WIP] Reject executeTool() failures with the draft's DOMException names - #12

Draft
Kulikowski wants to merge 2 commits into
webmachinelearning:mainfrom
Kulikowski:kulikowski/execution-errors
Draft

Kulikowski wants to merge 2 commits into
webmachinelearning:mainfrom
Kulikowski:kulikowski/execution-errors

Conversation

@Kulikowski

@Kulikowski Kulikowski commented Oct 13, 2026 •

Copy link
Copy Markdown

The spec now gives each executeTool() failure its own error name instead of UnknownError (webmcp#339), and rejects a call to an already-removed frame with InvalidStateError (webmcp#337). This PR does the same, and TESTING.md now tracks spec version eada13b.

Failure Before Now
Tool missing, origin mismatch, or not exposed to the caller UnknownError NotFoundError
Input does not parse to an object UnknownError DataError
Callback throws or rejects; result not serializable UnknownError OperationError
Target document unloads during the call UnknownError AbortError
Target frame already removed, or in another frame tree UnknownError InvalidStateError

TBD

@Kulikowski
Kulikowski force-pushed the kulikowski/execution-errors branch from f7bcce6 to cbfab42 Compare October 13, 2026 22:12
Draft b206dae replaced UnknownError with NotFoundError, DataError,
OperationError, AbortError, and InvalidStateError, and eada13b rejects a
target without a navigable with InvalidStateError. Frames now carry the
failure name in their error replies, and the draft pin moves to eada13b.

Pinned WPT still expects, and Chromium still throws, UnknownError
(crbug.com/509555636), so six subtests become expected failures and one
detachment case passes.
@Kulikowski
Kulikowski force-pushed the kulikowski/execution-errors branch from cbfab42 to 5a3e74c Compare October 13, 2026 22:53
Comment thread TESTING.md Outdated
Comment thread TESTING.md
still tests them.
- **Draft differences:** results are JSON-serialized; some pinned tests expect raw
strings. Omitted or `undefined` input becomes `{}`; `null` and primitives reject.
- **Execution errors:** failures reject with the draft's `NotFoundError`, `DataError`,

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.

You may want to wait until https://chromium-review.googlesource.com/c/chromium/src/+/8546218 is merged so that we can check the polyfill works as intended.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I think it is a good idea to wait for Chromium changes here

Comment thread README.md Outdated

`executeTool()` accepts an object and returns a JSON-serialized result. Omitted or `undefined` input defaults to a fresh empty object. Callbacks must validate their inputs; schema inference provides TypeScript checks only.

A failed execution rejects with the draft's `DOMException` name: `NotFoundError` when the target has no such tool exposed to the caller, `DataError` when the input does not parse to an object, `OperationError` when the callback throws, rejects, or returns an unserializable result, `AbortError` when the target document unloads during the call, and `InvalidStateError` when the target frame was already removed or is in another frame tree. The callback's own error stays in its frame.

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.

It may be a bit much in this README. WDYT?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Agreed. I cut it to one sentence

Comment thread src/frames.ts
Comment on lines +794 to +801
const executionFailures = {
NotFoundError: "The tool is not registered in the target document",
DataError: "The tool input could not be parsed",
OperationError: "The tool failed or returned an unserializable result",
AbortError: "The target document was unloaded",
InvalidStateError: "The target document is detached or in another frame tree",
NotAllowedError: "WebMCP is disabled by Permissions Policy",
} as const;

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.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks! It now uses Chromium's messages

@beaufortfrancois

beaufortfrancois commented Oct 16, 2026 •

Copy link
Copy Markdown
Collaborator

@Kulikowski

Copy link
Copy Markdown
Author

Changes have just landed: https://chromiumdash.appspot.com/commit/0b6fe2677649e16ed923849bb9ab70dd77c1a7c7

The PR is updated to match.

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.

2 participants