From 101662765c26001e98edce9f20b2597c7f24ebb4 Mon Sep 17 00:00:00 2001 From: Ross Wollman Date: Mon, 16 Aug 2021 12:49:10 -0700 Subject: [PATCH] api(cdp): newCDPSession accepts frames, too (#8157) Without this, Playwright's CDP feature leaves unreachable targets (namely OOPIFs). This change allows for more advanced experimentation in user-land without relying on out-of-band CDP connections and clients. Now you can, for example, call `DOM.getDocument` on the page OR main frame, observe there is an iframe node with no `contentDocument` (i.e. OOPIF), make note of the referenced `frameId`, and then iterate of page.frames() calling `Target.getInfo` on each to link the Playwright Frame with the CDP `frameId` and then recurse. Relates #8113 --- docs/src/api/class-browsercontext.md | 9 +++--- src/client/browserContext.ts | 8 ++++-- src/dispatchers/browserContextDispatcher.ts | 5 +++- src/protocol/channels.ts | 6 ++-- src/protocol/protocol.yml | 3 +- src/protocol/validator.ts | 3 +- src/server/chromium/crBrowser.ts | 17 ++++++++--- tests/chromium/oopif.spec.ts | 15 ++++++++++ tests/chromium/session.spec.ts | 31 +++++++++++++++++++-- types/types.d.ts | 4 +-- 10 files changed, 81 insertions(+), 20 deletions(-) diff --git a/docs/src/api/class-browsercontext.md b/docs/src/api/class-browsercontext.md index 960d527374..97d29a1230 100644 --- a/docs/src/api/class-browsercontext.md +++ b/docs/src/api/class-browsercontext.md @@ -349,7 +349,7 @@ context.clear_permissions() ```csharp var context = await browser.NewContextAsync(); await context.GrantPermissionsAsync(new[] { "clipboard-read" }); -// Alternatively, you can use the helper class ContextPermissions +// Alternatively, you can use the helper class ContextPermissions // to specify the permissions... // do stuff ... await context.ClearPermissionsAsync(); @@ -589,7 +589,7 @@ await page.SetContentAsync("