Skip to content

fix(dump): inline child frame documents in markdown with --with-frames - #2808

Open
lanyue-llk wants to merge 1 commit into
mainfrom
fix/markdown-with-frames
Open

lanyue-llk wants to merge 1 commit into
mainfrom
fix/markdown-with-frames

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

PR #2808 at a glance

**Track:** Web Fetch (Browser Eval). Replaces part of #1592.

Closes #2757.
Replaces part of #1592.

Problem. moli fetch URL --dump markdown --with-frames ignored --with-frames. An iframe with src came out as [Embedded content](src), and a srcdoc iframe produced nothing. --dump html and semantic_tree_text do inline frames. Repro (issue fixture): moli fetch http://127.0.0.1:8000/index.html --dump markdown --with-frames.

Reproduce (steps from #2757)
mkdir -p site/sub && cd site
echo '<!doctype html><body><h1>Root</h1><p>Before frame</p><iframe src="sub/child.html"></iframe><p>After frame</p></body>' > index.html
echo '<!doctype html><p>CHILD TEXT <a href="page.html">child link</a></p>' > sub/child.html
python3 -m http.server 8000 &
moli fetch http://127.0.0.1:8000/index.html --dump markdown --with-frames

Expected

The frame's current document appears at the iframe position, and child links resolve against the child URL. This is what the moli-webfetch skill describes ("Add --with-frames if the content is in an iframe"), and it is what --dump html --with-frames and --dump semantic_tree_text --with-frames already do:

# Root

Before frame

CHILD TEXT [child link](http://127.0.0.1:8000/sub/page.html)

After frame

Actual

The output is the same with and without --with-frames:

# Root

Before frame

[Embedded content](http://127.0.0.1:8000/sub/child.html)

After frame

An <iframe srcdoc="<p>SRCDOC TEXT</p>"> produces no output at all.

Change. Rebased onto #2836 and reworked to use its export design: Markdown reaches child Documents through the same borrowed lookup as the HTML writer, with no DOM copy and no separate frame traversal.

  • RendererMarkdownOptions gains with_frames, mirroring RendererHtmlSerializeOptions. fetch_dump forwards the CLI flag through it the same way it does for --dump html.
  • context_host/html_serialization.rs: the existing "with frames and child Documents exist" gate becomes embedded_documents_for_export, shared by the HTML writer and Markdown. Both receive the same HtmlEmbeddedDocumentProvider, which validates each FrameOwnerStore record. ScriptVm::with_embedded_documents_for_export lends it for one export.
  • markdown_dump/live_dom.rs: LiveDom asks the provider for an owner's Document while html2md walks the tree. This is the per-element lookup the writer also makes, and it honours sole_owner too. The owner then reads as a plain div whose only child is that Document's <body> (or root element). The export-local projection cache maps the body's parent back to the owner. A Document is inlined under one owner at most, which also rules out cycles. A hidden iframe still hides its content through the existing inherited visibility.
  • MarkdownSource::frame_base_url (default None) borrows the base URL of an inlined Document. markdown_dump/visibility.rs uses it to resolve href/src, so child links resolve against the child URL.
  • When --with-frames is off or the page has no child Documents, the provider is None. The adapter and every lookup behave exactly as on main.

Verification. Rebased build (main 16861c2 + this commit), issue fixture index.html and md.html (a srcdoc frame, a display:none frame and a nested frame):

main --with-frames                      this branch --with-frames
# Root                                  # Root

Before frame                            Before frame

[Embedded content](…/sub/child.html)    CHILD TEXT [child link](http://127.0.0.1:18791/sub/page.html)

After frame                             After frame

md.html --with-frames on this branch gives # Root / SRCDOC TEXT / OUTER / INNER / End; the hidden frame's text is omitted. Without --with-frames the output matches main.

  • cargo nextest run -p moli --test fetch_cli -E 'test(markdown) | test(with_frames)': 10 passed, including markdown_with_frames_inlines_child_documents_with_their_own_base_url. That test covers a nested srcdoc frame, a child <base href> that must win over the parent URL, and unchanged output without the flag. It also includes cli_dump_html_with_frames_nests_and_strips_child_documents.
  • cargo nextest run -p moli-renderer-v8 -E 'test(markdown) | test(html_dump) | test(html_serialization) | test(virtual_base) | test(lazy_main_world)': 65 passed. This covers refactor(html): serialize page exports without DOM copies #2836's serializer neighbours and the LiveDom projection test.
  • cargo nextest run -p moli --lib -E 'test(fetch_dump)': 18 passed.
  • cargo fmt --all is clean, and so is cargo clippy -p moli-renderer-v8 -p moli --all-targets --all-features -- -D warnings. Workspace clippy was not run locally.
  • The full workspace nextest was not run locally because the renderer test binary does not link within local RAM. It is left to CI.

Cost. Without --with-frames, or with no child Documents, the change adds one Option check per lookup. No map is built. With frames, each element gets the same provider lookup the HTML writer already makes, and each inlined frame adds one cache entry. Child Document nodes are styled and converted once, like top-document nodes. Both sides are debug builds of the same profile: main 16861c2 and this branch. Each was measured with /usr/bin/time -l over 5 alternating runs; the table shows the median. Another build was running on the host, so differences of ±0.02 s are noise.

case main wall / max RSS branch wall / max RSS
md.html --dump markdown --with-frames 0.15 s / 94.6 MiB 0.17 s / 95.6 MiB
index.html --dump markdown --with-frames 0.13 s / 91.3 MiB 0.11 s / 92.0 MiB
ordinary local article --dump markdown 0.12 s / 77.3 MiB 0.13 s / 77.8 MiB
ordinary local article --dump markdown --with-frames 0.13 s / 77.3 MiB 0.14 s / 77.8 MiB

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of 3b30348

No blocking findings

Checked against origin/main:

  • Root cause: page_dump.rs:16 now passes with_frames through. Frames come from live_child_document_handles_in_snapshot_order, the same list the HTML dump uses. Each owner projects exactly one child (its child Document's <body>, live_dom.rs:228-234), so the text lands at the iframe's DOM position. Nested owners are already in that list, and no document can be emitted twice: the owner's own children and its srcdoc attribute are replaced, not added to.
  • Failed / empty frames: a frame that fails to connect has no child document, so it is not in the list and keeps [Embedded content](src). I checked this with v1.1.23 --dump html --with-frames on the same list: http://127.0.0.1:9/... gets no srcdoc. about:blank, an iframe with no src, and a frame whose body is empty contribute nothing. Script-filled and 404 frames show their live document, as in Chromium.
  • Base URL: frame_base_url reads the child Document's base URL. That covers a child <base>, and srcdoc/about:blank inherit the parent's base through DocumentBaseUrlState. visibility.rs:297 applies it per node, and nested documents are keyed separately.
  • Visibility: document_snapshot_style_context (styles.rs:718-744) computes child-document nodes in their own document context. A display:none owner yields HiddenChildFrame and is suppressed through the projected parent.
  • Shadow DOM in frames: child documents are marked connected (mark_subtree_connected_preserving_owner_document), so has_shadow_roots sees their shadow roots.
  • Without --with-frames, frames is empty, is_projected() reduces to the old has_shadow_roots, and frame_base_url returns at the is_empty() guard, so the output is byte-identical. A page with no iframes does no new work, because child_browsing_context_handles_in_document_order returns early when the registry is empty.
  • Test: without the fix, the new CLI test fails (no CHILD TEXT). The child <base> checks the per-document base URL, and the no-flag assertion locks the old output.
  • CI: still pending at review time (Format, Node, Python and Windows pass). Nothing has failed yet.
  • Body: title, Closes #2757, and an honest Cost table and run scope. Picture: pending.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Spider Bench A/B

✅ All benchmark browser service runs completed; results are informational.

Public HEAD: 184 / 240 rows; 38 / 48 sites produced rows; 10 unexpected empty sites.

✅ Deterministic fixture contract is clean.

Common ancestor 16861c2e39e8 → HEAD 622b0fb0b213; benchmark order: base-first; workflow: success.

Public 48-site run · informational

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 184 / 240 184 / 240 0 (0.00%)
Contract fill 76.67% 76.67% 0.00 pp (0.00%)
Sites with rows 38 / 48 38 / 48 0 (0.00%)
Sites meeting row contract 36 / 48 36 / 48 0 (0.00%)
Unexpected empty sites 10 10 0 (0.00%)
Partial-row sites 2 2 0 (0.00%)
Site outcomes extracted: 36; HTTP error + rows: 2; empty: 8; HTTP error + empty: 1; snapshot error + empty: 1 extracted: 37; HTTP error + rows: 1; empty: 8; navigation error + empty: 1; snapshot error + empty: 1 —
Observed duration 57.68 s 75.93 s +18.25 s (+31.65%)
Estimated CPU 41.61 s 42.59 s +0.97 s (+2.34%)
Peak PSS 239.77 MiB 245.02 MiB +5.25 MiB (+2.19%)
Peak RSS 243.48 MiB 248.65 MiB +5.17 MiB (+2.12%)
Peak threads 31 30 -1 (-3.23%)
Mismatched sites 0 0 0
Timeout with items 0 0 0
Category rows Base HEAD Δ
news 35 / 40 35 / 40 0
stocks 20 / 40 20 / 40 0
tech 35 / 40 35 / 40 0
sports 27 / 40 27 / 40 0
games 32 / 40 32 / 40 0
life 35 / 40 35 / 40 0

Public-site content, timing, and memory are noisy. This single A/B run reports evidence only; site outcome counts explain missing rows without treating them as a deterministic regression.

CPU and memory timelines

These are bounded 40-point views of the same complete process-tree samples used by the HTML report. CPU uses 100% per occupied logical core; memory lines are RSS first and PSS second when complete PSS samples are available.

Base

xychart-beta
    title "Base CPU"
    x-axis "Elapsed seconds" [1.537, 3.04, 5.045, 6.545, 8.046, 9.548, 11.551, 13.055, 14.556, 16.059, 17.56, 19.561, 21.065, 21.565, 22.566, 24.067, 26.069, 27.07, 27.571, 29.072, 30.573, 32.075, 34.078, 35.579, 37.081, 38.583, 40.586, 42.088, 43.592, 45.093, 46.595, 48.598, 50.101, 51.603, 53.105, 54.607, 55.108, 56.61]
    y-axis "CPU percent" 0 --> 200
    line [77.91, 2, 89.8, 127.97, 93.94, 125.77, 129.74, 137.62, 3.99, 3.99, 44.01, 77.9, 5.99, 0, 0, 133.68, 117.69, 99.84, 105.94, 101.8, 115.83, 121.79, 105.88, 43.96, 47.95, 111.69, 29.97, 25.93, 25.93, 2, 25.98, 9.97, 89.93, 5.99, 99.88, 153.7, 119.88, 121.82]
Loading
xychart-beta
    title "Base memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.036, 1.537, 3.04, 5.045, 6.545, 8.046, 9.548, 11.551, 13.055, 14.556, 16.059, 17.56, 19.561, 21.065, 21.565, 22.566, 24.067, 26.069, 27.07, 27.571, 29.072, 30.573, 32.075, 34.078, 35.579, 37.081, 38.583, 40.586, 42.088, 43.592, 45.093, 46.595, 48.598, 50.101, 51.603, 53.105, 54.607, 55.108, 56.61, 57.677]
    y-axis "Memory MiB" 0 --> 500
    line [13.68, 101.78, 100.65, 129.87, 142.83, 130.78, 154.46, 155.23, 136.32, 121.51, 120.36, 130.54, 147.29, 125.18, 125.18, 124.02, 148.48, 139.42, 243.48, 220.79, 202.72, 138.38, 180.57, 138.76, 139.98, 150.22, 235.9, 224.56, 234.75, 229.8, 232.14, 230.68, 131.5, 149.37, 130.42, 149.62, 142.64, 152.82, 148.61, 0]
    line [10.2, 98.22, 96.95, 126.18, 139.22, 127.09, 150.84, 151.54, 132.58, 117.77, 116.62, 126.8, 143.55, 121.44, 121.44, 120.28, 144.74, 135.6, 239.77, 216.62, 199, 134.64, 176.82, 135, 136.24, 146.48, 232.06, 220.82, 231.01, 226.06, 228.4, 226.93, 127.76, 145.65, 126.68, 145.99, 139.32, 149.18, 144.89, 0]
Loading

HEAD

xychart-beta
    title "HEAD CPU"
    x-axis "Elapsed seconds" [2.038, 4.041, 6.544, 8.546, 10.549, 12.552, 14.054, 15.056, 17.059, 19.06, 21.063, 23.066, 25.568, 27.571, 29.574, 31.577, 34.079, 36.082, 38.084, 39.587, 40.087, 42.089, 44.593, 46.596, 48.6, 50.603, 53.105, 55.107, 57.109, 59.111, 61.114, 63.618, 65.621, 67.624, 69.627, 72.13, 74.133, 75.634]
    y-axis "CPU percent" 0 --> 200
    line [107.81, 133.7, 91.92, 107.9, 135.89, 23.94, 0, 8, 3.99, 111.95, 2, 2, 67.91, 99.91, 103.76, 63.92, 69.92, 105.84, 45.94, 105.92, 139.8, 23.98, 41.91, 27.96, 25.98, 23.97, 0, 0, 2, 0, 2, 23.97, 23.97, 21.96, 15.97, 125.81, 49.93, 162.04]
Loading
xychart-beta
    title "HEAD memory: RSS then PSS"
    x-axis "Elapsed seconds" [0.036, 2.038, 4.041, 6.544, 8.546, 10.549, 12.552, 14.054, 15.056, 17.059, 19.06, 21.063, 23.066, 25.568, 27.571, 29.574, 31.577, 34.079, 36.082, 38.084, 39.587, 40.087, 42.089, 44.593, 46.596, 48.6, 50.603, 53.105, 55.107, 57.109, 59.111, 61.114, 63.618, 65.621, 67.624, 69.627, 72.13, 74.133, 75.634, 75.931]
    y-axis "Memory MiB" 0 --> 500
    line [13.61, 113.45, 156.77, 128.02, 142.57, 132.18, 124.35, 123.46, 124.81, 125.66, 150.08, 127.35, 126.39, 144.01, 220.86, 202.1, 147.2, 163.7, 148.1, 171.52, 248.65, 247.4, 226.77, 233.83, 232.33, 232.45, 232.42, 232.45, 232.49, 231.89, 231.32, 231.33, 231.25, 231.3, 231.3, 142.39, 160.54, 149.15, 155.64, 0]
    line [10.26, 109.96, 153.35, 124.41, 138.98, 128.66, 120.75, 119.85, 121.21, 122.19, 146.59, 123.71, 122.75, 141.68, 217.26, 198.5, 143.58, 160.08, 144.46, 167.92, 245.02, 243.81, 223.29, 230.35, 228.7, 228.82, 228.78, 228.82, 228.85, 228.2, 227.69, 227.7, 227.62, 227.67, 227.68, 138.77, 156.93, 145.54, 152.87, 0]
Loading

Deterministic fixture · required contract

The fixture exercises 15 routes: 8 are expected to emit rows and 7 intentionally exercise empty, loading, or timeout behavior.

Metric Base HEAD Δ
Run status success success —
Extracted rows / contract 40 / 40 40 / 40 0 (0.00%)
Contract fill 100.00% 100.00% 0.00 pp (0.00%)
Sites with rows 8 / 15 8 / 15 0 (0.00%)
Sites meeting row contract 15 / 15 15 / 15 0 (0.00%)
Unexpected empty sites 0 0 0
Partial-row sites 0 0 0
Site outcomes extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 extracted: 7; HTTP error + rows: 1; empty: 3; timeout + empty: 4 —
Observed duration 19.90 s 19.87 s -0.04 s (-0.18%)
Estimated CPU 0.45 s 0.45 s +0.00 s (+0.22%)
Peak PSS 69.46 MiB 69.94 MiB +0.48 MiB (+0.69%)
Peak RSS 73.48 MiB 73.55 MiB +0.07 MiB (+0.10%)
Peak threads 21 21 0 (0.00%)
Mismatched sites 0 0 0
Timeout with items 0 0 0

Full HTML, JSON, CSV, logs, and page snapshots: workflow run and full spider-bench-results artifact.

The public-web A/B is informational. The exact HEAD fixture contract runs as a separate required CI check; timing and public-site content deltas remain non-blocking.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

CI Regression Report

Source CI run · source state at render: in_progress · artifacts: 6/6

Check Status Signal
Release regression ✅ HEAD/base failures 0/0; raw binary +0.002913%
Frontend differential ✅ 1,020/1,020 cases matched; 0 issues
Agent episodes ✅ 8/8 Moli episodes passed; 0 failures
Runtime/CDP contracts ✅ 26 contract cases; 0 failures
CDP smoke ✅ 118/118 groups passed; 1,754 scenarios
WebMainBench ✅ 545/545 completed; 0 unexpected failures
Release regression — ✅ HEAD/base failures 0/0; raw binary +0.002913%

Package and image size

Metric Base HEAD Delta Delta %
Raw binary 154.52 MiB 154.53 MiB +4.61 KiB +0.002913%
Stripped binary 106.93 MiB 106.94 MiB +4.00 KiB +0.003653%
gzip binary 53.41 MiB 53.42 MiB +2.97 KiB +0.005437%
Rootfs 161.43 MiB 161.43 MiB 0 B 0.00%
gzip rootfs 62.51 MiB 62.52 MiB +6.23 KiB +0.009739%

Startup latency and PSS

Case Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta
Serve ready 26.90 ms 27.55 ms +0.65 ms 4.62 MiB 4.73 MiB +112.50 KiB
CDP first page 48.83 ms 49.41 ms +0.58 ms 4.32 MiB 5.19 MiB +891.00 KiB
CDP warm page 12.04 ms 11.50 ms −0.54 ms 53.26 MiB 52.66 MiB −613.50 KiB
CLI about:blank 14.01 ms 13.67 ms −0.33 ms 4.08 MiB 4.58 MiB +512.00 KiB
CLI local JS 26.79 ms 24.68 ms −2.10 ms 3.75 MiB 4.95 MiB +1.21 MiB

Concurrency matrix

Concurrency Base p50 HEAD p50 Delta Base PSS HEAD PSS Delta HEAD failures Unstable B/H
1 24.59 ms 22.64 ms −1.95 ms 704.00 KiB 738.00 KiB +34.00 KiB 0 0/0
5 29.22 ms 25.25 ms −3.97 ms 12.84 MiB 13.36 MiB +535.00 KiB 0 0/0
10 26.29 ms 26.90 ms +0.61 ms 12.94 MiB 12.10 MiB −859.50 KiB 0 0/0
25 27.29 ms 26.85 ms −0.44 ms 12.98 MiB 12.87 MiB −113.00 KiB 0 0/0
100 27.01 ms 26.31 ms −0.70 ms 12.77 MiB 16.83 MiB +4.05 MiB 0 0/0
Frontend differential — ✅ 1,020/1,020 cases matched; 0 issues
Match DOM mismatch Diagnostic mismatch Moli error Reference error Infrastructure error Mismatched frames Duration
1,020 0 0 0 0 0 0 6m 53.27s
Agent episodes · Moli vs Chromium — ✅ 8/8 Moli episodes passed; 0 failures
Fast contract Episodes Passed Assertions Ready p50 Episode p50
Moli 8 8 47/47 4.37 ms 31.11 ms
Chromium 8 8 47/47 317.81 ms 94.93 ms
Operation p50 Chromium Moli Delta Delta %
navigate 44.65 ms 6.33 ms −38.32 ms −85.82%
observe 2.09 ms 0.94 ms −1.14 ms −54.71%
fill 3.14 ms 3.83 ms +0.69 ms +21.92%
click 6.39 ms 4.37 ms −2.02 ms −31.64%
Idle-resource episode Peak RSS Peak PSS Average CPU Peak CPU Peak processes Sampler
Moli 70.30 MiB 66.92 MiB 0.81% 12.00% 1 ✅
Chromium 1306.36 MiB 433.15 MiB 1.08% 27.99% 13 ⚠️ PSS partial
Runtime and CDP session contracts — ✅ 26 contract cases; 0 failures
Suite Cases Failures Median case p50 Median case p95 Median peak PSS p50
Synthetic fetch 13 0 36.85 ms 42.55 ms 867.00 KiB
Long-lived CDP session 13 0 23.39 ms 24.29 ms —
CDP smoke — ✅ 118/118 groups passed; 1,754 scenarios

Workers: 4 · cumulative group time: 559.80 s · failed groups: 0

Slowest group Scenarios Duration Status
scrollbar-visibility 22 28.16 s ✅
dom-input 62 28.00 s ✅
dom-input 62 27.98 s ✅
scrollbar-visibility 22 27.72 s ✅
fetch-resource-dispatch 72 27.04 s ✅
WebMainBench · 545 pages — ✅ 545/545 completed; 0 unexpected failures
Completed Successful Expected DNS failure Unexpected failures Panics Crashes Timeouts Empty output
545/545 544 1 0 0 0 0 0

Frozen HTML · Linux · --wait done · 45 seconds per page · no retries. Content quality is evaluated separately.

Diagnostics: webmainbench-results — every page's Markdown, stderr, and exit status. Source run and artifacts

All artifact fields are parsed by the trusted default-branch renderer; missing or invalid inputs remain visible as unavailable.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

Sequential Navigation Soak A/B

✅ HEAD completed the 200-navigation resilience and memory observation.

One browser process, one target, and one CDP session navigate CSDN → SegmentFault → Huaban → example.com repeatedly. This run issued 200 Page.navigate commands per binary.

Common ancestor 16861c2e39 → HEAD 622b0fb0b2; benchmark order: base-first; workflow: success.

Session resilience

Metric Base HEAD
Attempted / planned 200 / 200 200 / 200
Direct observable pass 197 / 200 192 / 200
Failures / recovered 3 / 3 8 / 8
Recovery failures 0 0
Lifecycle order violations 0 0
Network order violations 0 0
Wall time 668.0 s 615.6 s

A public-page failure is reported separately from an unrecoverable session. The soak requires all navigation attempts, zero failed recovery, zero lifecycle/network ordering violations, and complete resource evidence.

Process-tree memory

Metric Base HEAD Δ
Boundary samples 200 200 0
Boundary RSS samples 200 200 0
Boundary PSS samples 200 200 0
Periodic peak RSS 275.2 MiB 250.7 MiB -24.5 MiB
Periodic peak PSS 271.5 MiB 247.0 MiB -24.5 MiB
RSS · first 10 avg 171.6 MiB 181.1 MiB +9.5 MiB
RSS · last 10 avg 197.0 MiB 191.9 MiB -5.1 MiB
RSS · last − first window +25.3 MiB +10.8 MiB -14.6 MiB
RSS · warm slope / 100 nav +6.3 MiB +3.2 MiB -3.1 MiB
PSS · first 10 avg 168.3 MiB 177.5 MiB +9.2 MiB
PSS · last 10 avg 193.4 MiB 188.3 MiB -5.0 MiB
PSS · last − first window +25.0 MiB +10.8 MiB -14.2 MiB
PSS · warm slope / 100 nav +6.1 MiB +3.3 MiB -2.8 MiB
Peak file descriptors 66 66 0
Peak threads 32 32 0

HEAD memory by 50-navigation quarter

HEAD range Avg RSS Final RSS Peak RSS Avg PSS Final PSS Peak FD
1–50 183.3 MiB 153.7 MiB 225.0 MiB 179.5 MiB 149.9 MiB 60
51–100 190.2 MiB 131.5 MiB 228.1 MiB 186.5 MiB 128.0 MiB 59
101–150 190.4 MiB 161.8 MiB 226.0 MiB 186.7 MiB 158.1 MiB 61
151–200 191.8 MiB 228.4 MiB 230.4 MiB 188.3 MiB 224.9 MiB 58

Raw reports and per-navigation boundary samples: workflow run and full sequential-navigation-soak-results artifact.

Public-site timing and memory are observational. Use the A/B deltas and trend shape as evidence, not as a deterministic performance threshold.

@lanyue-llk
lanyue-llk force-pushed the fix/markdown-with-frames branch from 3b30348 to 622b0fb Compare November 13, 2026 12:53

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independent review of 622b0fb

No blocking findings

Checked against origin/main 885432b (merge-base 16861c2, which already contains #2836 / cbbcf11).

  • #2836 design. Followed. There is no DOM copy and no second traversal. LiveDom asks the same HtmlEmbeddedDocumentProvider (PageScriptHost) for each element, in the html2md walk that already runs (markdown_dump/live_dom.rs:87-109, :226-252). That provider validates the host handle, active state and the FrameOwnerStore current document, and it is the same gate the writer uses through the extracted embedded_documents_for_export (context_host/html_serialization.rs:59-71). sole_owner is read once and applied as in engine.rs:634. Nothing #2836 removed comes back: the Markdown with_frames argument #2836 dropped was ignored, and this one is honoured.
  • Correctness.
    • parent_node maps the inlined body back to its owner (live_dom.rs:172-176). Inherited display:none therefore hides a hidden frame's content, and HiddenChildFrame styles stay empty.
    • Child-document links use Document::base_url() only for documents this export actually inlined (live_dom.rs:160-170, visibility.rs:297). Top-document nodes keep the page base URL.
    • The new CLI test fails without the change: the srcdoc frame produces no text. It covers a nested frame, a child <base>, and unchanged output without the flag.
  • Default cost. With with_frames=false, or when no child Documents exist, the provider is None. is_projected() then reduces to the old has_shadow_roots check, and the native NativeDom path is used exactly as before. The only additions are one immutable _context_host borrow and early self.frames? returns.
  • Scope/merit. --with-frames is a documented CLI flag that --dump html and semantic_tree_text already honour; Markdown silently ignored it. Supporting it here is worthwhile in its own right, and the diff is small: 10 files, +132/-17.
  • CI. Nextest, Clippy, Format, Python, Node and Windows pass. The release builds and CDP smoke were still pending when I checked.

Non-blocking note: the body says "inlined under one owner at most, which also rules out cycles". That rule covers a Document claimed by two owners. It does not cover an owner whose recorded Document is its own owner document or the top document. The writer rejects both cases (engine.rs:792-793, CyclicEmbeddedDocument). Here, collect_node_ids would loop without bound. FrameOwnerStore cannot currently produce either record, so this is not a finding. If you want parity with the writer, a single guard in frame_root would do: document != host.document_handle() && owner_document(owner) != Some(document).

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.

moli fetch --dump markdown --with-frames omits iframe content and prints only "[Embedded content](src)"

1 participant