From bbd60c68cc5c269f4d977fb4fe0b96b06dc8e106 Mon Sep 17 00:00:00 2001 From: Yury Semikhatsky Date: Mon, 21 Sep 2026 16:15:52 -0700 Subject: [PATCH 1/3] feat(content): add includeShadowRoots option to page.content() Fixes https://github.com/microsoft/playwright/issues/42794 --- docs/src/api/class-frame.md | 3 ++ docs/src/api/class-page.md | 3 ++ docs/src/api/params.md | 6 ++++ packages/playwright-client/types/types.d.ts | 22 +++++++++++-- .../playwright-core/src/client/channels.d.ts | 8 +++-- packages/playwright-core/src/client/frame.ts | 4 +-- packages/playwright-core/src/client/page.ts | 4 +-- .../playwright-core/src/server/channels.d.ts | 8 +++-- .../src/server/dispatchers/frameDispatcher.ts | 2 +- packages/playwright-core/src/server/frames.ts | 32 ++++++++++++++----- packages/playwright-core/types/types.d.ts | 22 +++++++++++-- packages/protocol/spec/frame.yml | 2 ++ packages/protocol/src/validator.ts | 4 ++- tests/page/page-set-content.spec.ts | 8 +++++ 14 files changed, 106 insertions(+), 22 deletions(-) diff --git a/docs/src/api/class-frame.md b/docs/src/api/class-frame.md index 791640f1b86ca..da217e1240fde 100644 --- a/docs/src/api/class-frame.md +++ b/docs/src/api/class-frame.md @@ -299,6 +299,9 @@ When all steps combined have not finished during the specified [`option: timeout Gets the full HTML contents of the frame, including the doctype. +### option: Frame.content.includeShadowRoots = %%-content-option-include-shadow-roots-%% +* since: v1.64 + ## async method: Frame.dblclick * since: v1.8 * discouraged: Use locator-based [`method: Locator.dblclick`] instead. Read more about [locators](../locators.md). diff --git a/docs/src/api/class-page.md b/docs/src/api/class-page.md index 750f8efc87ba0..5d8ee92ce1458 100644 --- a/docs/src/api/class-page.md +++ b/docs/src/api/class-page.md @@ -866,6 +866,9 @@ Defaults to `false`. Whether to run the Gets the full HTML contents of the page, including the doctype. +### option: Page.content.includeShadowRoots = %%-content-option-include-shadow-roots-%% +* since: v1.64 + ## method: Page.context * since: v1.8 - returns: <[BrowserContext]> diff --git a/docs/src/api/params.md b/docs/src/api/params.md index c107b8660ce2a..a9aeac44e7c22 100644 --- a/docs/src/api/params.md +++ b/docs/src/api/params.md @@ -7,6 +7,12 @@ When to consider operation succeeded, defaults to `load`. Events can be either: * `'networkidle'` - **DISCOURAGED** consider operation to be finished when there are no network connections for at least `500` ms. Don't use this method for testing, rely on web assertions to assess readiness instead. * `'commit'` - consider operation to be finished when network response is received and the document started loading. +## content-option-include-shadow-roots +- `includeShadowRoots` <[boolean]> + +When true, contents of open shadow roots are included as [declarative shadow DOM](https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_shadow_DOM#declaratively_with_html), +i.e. `