[w3ctag/design-reviews] Question: How should `Document`-scoped objects interact with `window.navigator`? (Issue #1231)

domfarolino created an issue (w3ctag/design-reviews#1231)

[WebMCP](https://github.com/webmachinelearning/webmcp) provides `navigator.modelContext`, which returns an object that tracks a per-Document set of tools. This is unfortunate since `navigator` and `window` are both reused between the initial about:blank Document and the next same-origin document. This means `navigator.modelContext` should be "reset" after navigations like this, to return a different object, since the [associated Document](https://html.spec.whatwg.org/#concept-document-window) has changed.

Since `modelContext` is effectively per-Document, it actually makes more sense to just have it live on `document.modelContext`, but we wanted to keep the door open to adding this API in workers—particularly Service Workers—in the future, and since `self.navigator` is shared both contexts, the consistency of `navigator` felt nice.

Should we just move it to `document.modelContext` now, and if worker support ever comes, introduce `self.modelContext` or `navigator.modelContext` only for workers, since that's more honest about the scoping? Or should we keep this very Document-specific object on the `navigator` object in Window contexts for consistency with workers in the future, and just have it change values after navigation away from the initial about:blank Document?

> This means `navigator.modelContext` should be "reset" after navigations like this, to return a different object, since the [associated Document](https://html.spec.whatwg.org/#concept-document-window) has changed.

Or, should we NOT reset the `modelContext` object, and instead keep it stable forever, and just "reset" its internal state when we detect that the document has changed from the initial about:blank Document to the next same-origin one after navigation. This is elegant and conceals most of the complexity from the developers, but it's doing a lot under the hood to conceal and work around the fact that everything is really document-scoped here, so maybe it's not worth it.

Penny for your thoughts?

<!-- Content below this is maintained by @w3c-tag-bot -->
---

Track conversations at https://tag-github-bot.w3.org/gh/w3ctag/design-reviews/1231


-- 
Reply to this email directly or view it on GitHub:
https://github.com/w3ctag/design-reviews/issues/1231
You are receiving this because you are subscribed to this thread.

Message ID: <w3ctag/design-reviews/issues/1231@github.com>

Received on Monday, 18 May 2026 19:12:00 UTC