Repository navigation
fix(dump): include and strip shadow roots in html dumps - #2821
Merged
Merged
Conversation
lanyue-llk
commented
Nov 12, 2026
lanyue-llk
left a comment
Contributor
Author
There was a problem hiding this comment.
Independent review of aa4c276
No blocking findings
Reviewed against base fix/dump-nested-frames (#2801), one commit.
- Root cause fixed in both paths. The post-process dump (
page_dump.rs:37-59) strips every shadow fragment in the copy before frames are inlined and then serializes the top document through the sameget_html_from_copyprovider that child frames use. The fast path (page_dom.rs:3527-3537) does the same.--dump jsongoes throughrender_html, so it picks up the fix too. - Open and closed roots are both emitted. The roots are passed as explicit roots with
serializable: false. That is consistent with moli's frame path and Markdown output, and it is the right default for an agent dump. Nested roots are covered because the serializer engine queries the provider for every element (engine.rs:292). Slotted nodes stay as light children and are not duplicated.delegatesfocus,serializable,clonableandslotassignmentare written by the existingwrite_shadow_root_template_start. - Strip:
apply_strip_optionsreturns early when no flag is set, so the new per-root loop does nothing without--strip-mode. With a flag,js,cssanduiall apply inside the shadow fragments. - Cost: a page without shadow roots still goes through
serialize_document()unchanged. The only extra work is an empty-map snapshot. The numbers in the body are plausible. - Test:
cli_dump_html_includes_and_strips_shadow_rootswould fail without the fix on all three asserts.
Non-blocking note: serialize_html also backs CDP Page.captureSnapshot (moli-protocol/src/domains/page/capture.rs:172). MHTML snapshots of shadow pages now contain <template shadowrootmode>. Chrome's MHTML serializer also writes shadow roots, so this moves toward Chrome, but the body should list this consumer.
CI: Clippy, Format, Node, Python and Windows pass. Nextest, CDP smoke and the release builds are still pending.
Picture: pending.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Track: Web Fetch (Browser Eval). Closes #2804. Replaces part of #1592. Stacked on #2801 (
fix/dump-nested-frames).HTML dumps now include author Shadow DOM at the top level and inside loaded child frames. CSS/JS/UI stripping applies to the export copy before nested frame markup is folded into
srcdoc.<template shadowrootmode>through the existing shadow-root provider. Plain HTML dumps and CDP MHTML snapshots use the same representation; ordinary shadow-excluding DOM outerHTML retains its contract.template.contentowners from connected frame queries.--strip-mode css/fullalso omitsshadowrootadoptedstylesheetsfrom generated shadow templates, at both top level and inside frames. Ordinary exports, JS-only stripping, and WebgetHTML()retain authored stylesheet metadata.Regression coverage waits for the actual child DOM update (
AFTER, absent from the authored markup) and adopted stylesheet computed color before exporting. It covers shadow → iframe, iframe → closed shadow → iframe, frame reordering and detachment, inert template candidates, plain versus CSS/full/JS stripping, and live metadata preservation.Validation on the final tree (Rust 1.96.1, 24 build jobs/test threads, retries disabled):
aa4c276f88with production code unchanged: stalebeforemarkup despite liveAFTER, and adopted CSS metadata retained under CSS stripping.--flaky-result fail.cargo fmt --allcargo clippy --workspace --all-targets --all-features -- -D warningscargo nextest run --no-fail-fast: 22,978 passed, 20 skipped, 0 failed.The review fixes are separate English commits. Baseline failures and the inactive-template probe are retained with the local investigation logs in
target/dump-shadow-review-20261112/.