Skip to content

Fire toolactivated after invoking execute - #371

Merged
domfarolino merged 2 commits into
webmachinelearning:mainfrom
beaufortfrancois:toolactivated-after-execute
Nov 9, 2026
Merged

domfarolino merged 2 commits into
webmachinelearning:mainfrom
beaufortfrancois:toolactivated-after-execute

Conversation

@beaufortfrancois

@beaufortfrancois beaufortfrancois commented Nov 2, 2026 •

Copy link
Copy Markdown
Collaborator

Fires the toolactivated event after invoking the tool's execute callback, so listeners observe the tool's synchronous effects (e.g. a filled-in declarative form). This matches Chromium and WPT (executeTool-abort.https.html).

No explicit fully active guard is needed: if execute detaches the document, DOM's inner invoke already skips listeners when the target's relevant global object's associated Document is not fully active, matching executeTool-detach-toolactivated.https.html.

Fixes #332


Preview | Diff

Fires the toolactivated event after invoking the tool's execute callback,
so listeners observe the tool's synchronous effects. This matches
Chromium and WPT.

Fixes webmachinelearning#332
@domfarolino

Copy link
Copy Markdown
Collaborator

@sjdallst2, do you want to take a first pass at this PR?

Comment thread index.bs Resolved

@sjdallst2 sjdallst2 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.

Thanks for the change, @beaufortfrancois !

@beaufortfrancois

Copy link
Copy Markdown
Collaborator Author

@domfarolino Once this PR is merged, I'll resume w3c-oss/webmcp-polyfill#7

@domfarolino
domfarolino merged commit f2f2ae2 into webmachinelearning:main Nov 9, 2026
2 checks passed
github-actions Bot added a commit that referenced this pull request Nov 9, 2026
SHA: f2f2ae2
Reason: push, by domfarolino

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
beaufortfrancois added a commit to w3c-oss/webmcp-polyfill that referenced this pull request Nov 10, 2026
Follow webmachinelearning/webmcp#245: define the ToolActivatedEvent and
ToolCancelEvent interfaces, add the ontoolactivated and ontoolcancel
handlers to ModelContext, and dispatch the events at the ModelContext of
the document that owns the tool. Bump webmcp-types to 0.1.10 for the
declarations.

Follow webmachinelearning/webmcp#371 (draft f2f2ae2) for timing:
toolactivated fires after the execute callback is invoked, so listeners
observe its synchronous effects. If the callback detaches its document,
DOM's inner invoke skips the listeners. toolcancel fires when a caller
aborts a callback that has started and not settled.

All pinned IDL checks, the ToolActivatedEvent tests, and executeTool-abort's
caller-abort case now pass. Record the remaining expected failures:
isTrusted is false for script-dispatched events, blank.html frames have no
polyfill, and aborting before dispatch skips the callback.

Validation: 253 browser tests and packed consumer checks pass. WPT in
Chrome Canary 159.0.8153.0: 70 files, 190 subtests, zero unexpected
results.
@beaufortfrancois

Copy link
Copy Markdown
Collaborator Author

Thank you both!

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.

Fire toolactivated after invoking execute

3 participants