#447·Scrapling

Same-origin iframe documents are silently dropped from pierce_shadow snapshots — fix ready, PR welcome?

Author: ZeroCode00Created Sep 14, 2026Updated Sep 14, 2026

First — the new shadow-piercing snapshot on dev is really nicely done; the native-serialization approach is much cleaner than what I attempted in #441.

What happened: with pierce_shadow=True, same-origin iframe documents are not traversed, so their content is silently missing from the snapshot. I saw the note in the docs that this is intentional — but I wanted to flag it with concrete evidence, because in the wild this pattern is more common than it looks:

  • TinyMCE's official demo renders its entire editing surface in a same-origin srcdoc iframe (with a shadow root inside). On current dev with pierce_shadow=True, none of the ~1,750 characters of editor content is selectable — even though the srcdoc attribute text remains, which can mislead users into thinking the data is there. CKEditor 4's demo follows the same pattern.
  • On my synthetic nested-shadow page (13 extraction targets: light DOM, shadow depth 2–4, slots, shadow-inside-iframe, closed root), current dev reaches 11/13; the 2 misses are the iframe case and the closed root.

Environment: Python 3.13.15 (64-bit venv) on Windows 11 Pro 25H2, scrapling 0.4.15 from dev (6e64404), Playwright 1.62.0 with bundled Chromium and system Chrome (both reproduced).

The good news: same-origin frames don't require any architectural change — contentDocument is reachable from the main frame's context, so recursion stays inside the existing single-evaluate walker. I have a working implementation on top of your dev:

  • Frame documents are serialized into <iframe-document> siblings right after their <iframe> (iframes are raw-text in HTML parsing, so frame content can't be nested inside them);
  • Recursion covers frames-in-frames and shadow-inside-frame; cross-origin frames stay a documented boundary, skipped without errors;
  • Walker type checks are now realm-safe (instanceof fails across frame realms);
  • 55/55 tests pass (4 new + all existing shadow tests), validated live against the TinyMCE demo (patch: 1,754 chars reachable; without: 0).

Branch: ZeroCode00/Scrapling@feat/same-origin-iframe-snapshot, evidence pack with full test logs: branch docs/iframe-pr-notes.

Would you like me to send this as a PR against dev? Happy to adjust naming, placement, or scope however you prefer.

(AI disclosure: the implementation and tests were AI-assisted, under my direction and review; all numbers are from my local runs.)