Skip to content

feat(engine): re-render an iframe after a parent mutates it via contentDocument - #434

Merged
tannevaled merged 1 commit into
mainfrom
iframe-rerender-on-mutation
Nov 15, 2026
Merged

tannevaled merged 1 commit into
mainfrom
iframe-rerender-on-mutation

Conversation

@tannevaled

Copy link
Copy Markdown
Contributor

Summary

Round 41's own last disclosed limitation (Refs #431, already closed; cited for context only): the iframe's pixels were already composited into the parent page before any parent script ran, and nothing afterward ever looked again.

A new refreshIframeImages (iframe.go) mirrors the existing refreshCanvasImages exactly: after the parent's settle loop finishes, walk every already-loaded <iframe> and re-paint its CURRENT tree (n.IframeDoc, whatever a parent script's contentDocument access left it as) into the same imgSize/imgs maps the final composite reads.

Deliberately does NOT re-run the nested document's own JavaScript — a real correctness hazard checked directly, not assumed safe: a copy of Engine with DisableJS forced on gives cascade→layout→paint of the tree exactly as it now stands. Verified both ways with a nested <script>console.log(...)</script>, since its output shares this engine's single JSLog callback with the parent's own: removing the DisableJS guard logs it twice; restoring it logs exactly once.

A new dom.Node.IframeURL field (set alongside IframeDoc) carries the nested document's own base URL forward into the refresh, so a relative resource inside it still resolves correctly on re-render.

Also fixed: a stray double blank line in js/dom.go, introduced by the previous round's own edit and missed at the time (gofmt -l . now clean of it).

Fixes #433.

Test plan

  • go build ./... && go vet ./... && gofmt -l . clean
  • go vet -tags "webengine_nojs webengine_nonet webengine_fontsext" . ./paint/... clean
  • go test ./... full suite green
  • govulncheck ./... clean
  • 2 new top-level tests: a parent script's contentDocument.body.style.background mutation lands in the final rendered pixels; a nested script's own console.log fires exactly once, not twice, after the refresh
  • Git-stash-confirmed both ways: removing the refreshIframeImages call reproduces the exact stale-colour symptom; removing DisableJS reproduces the exact double-log symptom
  • All five gated packages held their coverage floors (css 99.5%, layout/paint/paginate 100.0%, dom 98.8%)

🤖 Generated with Claude Code

…ntDocument

Round 41's own last disclosed limitation: the iframe's pixels were already
composited into the parent page before any parent script ran, and nothing
afterward ever looked again.

A new refreshIframeImages (iframe.go) mirrors the existing
refreshCanvasImages exactly: after the parent's settle loop finishes, walk
every already-loaded iframe and re-paint its CURRENT tree into the same
maps the final composite reads. Deliberately does NOT re-run the nested
document's own JavaScript -- a copy of Engine with DisableJS forced on
gives cascade->layout->paint of the tree exactly as it now stands.
Verified both ways with a nested script sharing this engine's own JSLog
callback: removing the DisableJS guard logs it twice, restoring it logs
exactly once.

A new dom.Node.IframeURL field carries the nested document's own base URL
forward so a relative resource inside it still resolves on re-render.

Also fixes a stray double blank line in js/dom.go, introduced by the
previous round's own edit and missed at the time (gofmt -l . now clean of
it).

Fixes #433

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@tannevaled
tannevaled merged commit 6bffb26 into main Nov 15, 2026
13 checks passed
@tannevaled
tannevaled deleted the iframe-rerender-on-mutation branch November 15, 2026 13:18
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.

<iframe> content mutated via contentDocument does not re-render

1 participant