Skip to content

Framed pages - #1

Open
temeddix wants to merge 3 commits into
mainfrom
reach-into-frames
Open

temeddix wants to merge 3 commits into
mainfrom
reach-into-frames

Conversation

@temeddix

@temeddix temeddix commented Sep 13, 2026

Copy link
Copy Markdown
Member

applyThinScrollbarsEverywhere now follows iframe, frame, object, and
embed into the same-origin pages they hold, as deeply as those nest, and
restyles a framed page when it navigates.

Each framed page needs its own sheet (a constructable one is refused by any
other document) and its own attachShadow patch. Realm-agnostic tests
throughout: instanceof answers for one realm only.

Cross-origin and allow-same-origin-less frames stay out of reach.

@temeddix

Copy link
Copy Markdown
Member Author

Review pass: three cross-realm faults found and fixed in 00f598f.

  1. patchRoot remembered its owner document. A shadow host adopted into another same-origin document kept being handed the old document's sheet, which the new one refuses. The owner is now read afresh on every call, via a restored ownerOf.
  2. A root was flagged observed before it was known to be observable. observedRoots.add ran ahead of the defaultView !== null check, so a root first seen in a window-less document was recorded as watched and never got an observer. The null check now returns first.
  3. instanceof was asked of the document's realm, not the node's. A node built in one realm keeps that realm's prototypes after adoption, so whole subtrees were skipped in silence. Element and frame tests are now nodeType and localName, which belong to no realm, and framedDocumentOf reads contentDocument/getSVGDocument through a type predicate instead of a four-branch instanceof chain.

Also folded in: the attachShadow patch is keyed by Element.prototype rather than by document, so a frame showing about:blank before its real page no longer wraps the same prototype twice.

Measured against a throwaway harness, before and after:

before after
host adopted into another document 0 sheets, 2 uncaught NotAllowedError 1 sheet, 0 errors
frame inside a root first seen window-less auto thin
subtree built in another realm, then adopted auto thin

The example page still reports thin at all eight depths. deno check, deno lint, deno fmt --check, and deno task build pass.

🤖 Generated with Claude Code

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