- From: Fernando Fiori via GitHub <noreply@w3.org>
- Date: Tue, 05 May 2026 19:14:30 +0000
- To: public-css-archive@w3.org
ffiori has just created a new issue for https://github.com/w3c/csswg-drafts:
== [css-highlight-api] CSS.highlights getter realm is underspecified for cross-realm access ==
[3.2 Registering Custom Highlights](https://drafts.csswg.org/css-highlight-api/#registration) says:
> The highlight registry is accessed via the `highlights` attribute of the `CSS` namespace, and represents all the custom highlights registered for the [current global object](https://html.spec.whatwg.org/multipage/webappapis.html#current-global-object)'s [associated `Document`](https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-document-window).
This wording doesn't sound right for cross-realm access through another window's `CSS` namespace, e.g.:
```js
const iframeWin = document.querySelector("iframe").contentWindow;
iframeWin.CSS.highlights.set("name", new Highlight(/* range over iframe nodes */));
```
The phrase "current global object" refers to the realm of the *calling script*, not the realm of the namespace object on which the property was accessed. So the parent's HighlightRegistry would be returned even though the author wrote `iframeWin.CSS.highlights`. That contradicts the implicit intent in #6417, which resolved on per-document registries with paint-time filtering of foreign-document ranges.
### Observed behavior
- Firefox returns the iframe's HighlightRegistry from `iframeWin.CSS.highlights`.
- Chromium returns the caller's registry, matching the literal spec text. (See https://crbug.com/407812149)
### Proposed fix
Reword 3.2 so the realm is taken from the namespace object on which the property was accessed, not from the running script. Something along these lines:
> The highlight registry is accessed via the `highlights` attribute of the `CSS` namespace, and represents all the custom highlights registered for the associated Document of the [relevant global object](https://html.spec.whatwg.org/multipage/webappapis.html#concept-relevant-global) of the CSS namespace object on which the property is accessed.
cc @dandclark
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/13888 using your GitHub account
--
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 5 May 2026 19:14:35 UTC