Skip to content

Add closed shadow DOM capture via CDP#135

Closed
aryanku-dev wants to merge 1 commit intomainfrom
feat/closed-shadow-dom-cdp
Closed

Add closed shadow DOM capture via CDP#135
aryanku-dev wants to merge 1 commit intomainfrom
feat/closed-shadow-dom-cdp

Conversation

@aryanku-dev
Copy link
Copy Markdown

Summary

  • Add expose_closed_shadow_roots() using CDP to discover and expose closed shadow roots
  • Add _walk_nodes() helper for CDP DOM tree traversal
  • Add 6 unit tests covering tree walking, non-Chromium skip, CDP errors

Ported from percy/percy-playwright#609

Test plan

  • Unit tests pass
  • Verify no regression on pages without shadow DOM

🤖 Generated with Claude Code

Use CDP to discover closed shadow roots before DOM serialization.
Closed shadow roots are inaccessible from JS (element.shadowRoot === null),
but CDP's DOM domain can pierce them. We resolve each closed shadow root
to a JS object and store it in a WeakMap that PercyDOM.serialize() reads.

- Add expose_closed_shadow_roots() using CDP session
- Add _walk_nodes() helper to traverse CDP DOM tree
- Skip iframe contentDocument nodes (cross-frame not yet supported)
- Non-fatal: catches exceptions for non-Chromium browsers and CDP errors
- Called after PercyDOM injection, before DOM serialization
- Add tests for walk_nodes, non-Chromium skip, CDP errors, closed roots

Ported from percy/percy-playwright#609

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@aryanku-dev aryanku-dev requested a review from a team as a code owner April 20, 2026 18:45
@aryanku-dev aryanku-dev deleted the feat/closed-shadow-dom-cdp branch April 20, 2026 18:46
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.

1 participant