Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
fix(connect): report all frames in existing page to the client (#8910)
Yury Semikhatskybdea9c74c494
diff --git a/src/dispatchers/pageDispatcher.ts b/src/dispatchers/pageDispatcher.tsindex eaa1914ee4..141fa4bfd4 100644--- a/src/dispatchers/pageDispatcher.ts+++ b/src/dispatchers/pageDispatcher.ts@@ -79,6 +79,10 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer, cpage.on(Page.Events.Video, (artifact: Artifact) => this._dispatchEvent('video', { artifact: existingDispatcher<ArtifactDispatcher>(artifact) }));if (page._video)this._dispatchEvent('video', { artifact: existingDispatcher<ArtifactDispatcher>(page._video) });+ // Ensure client knows about all frames.+ const frames = page._frameManager.frames();+ for (let i = 1; i < frames.length; i++)+ this._onFrameAttached(frames[i]);}page(): Page {diff --git a/tests/chromium/chromium.spec.ts b/tests/chromium/chromium.spec.tsindex f7b61149ed..9e48957b99 100644--- a/tests/chromium/chromium.spec.ts+++ b/tests/chromium/chromium.spec.ts@@ -147,6 +147,28 @@ playwrightTest('should connect to an existing cdp session twice', async ({ brows}});+playwrightTest('should connect to existing page with iframe and navigate', async ({ browserType, browserOptions, server }, testInfo) => {+ const port = 9339 + testInfo.workerIndex;+ const browserServer = await browserType.launch({+ ...browserOptions,+ args: ['--remote-debugging-port=' + port]+ });+ try {+ {+ const context1 = await browserServer.newContext();+ const page = await context1.newPage();+ await page.goto(server.PREFIX + '/frames/one-frame.html');+ }+ const cdpBrowser = await browserType.connectOverCDP(`http://localhost:${port}/`);+ const contexts = cdpBrowser.contexts();+ expect(contexts.length).toBe(1);+ await contexts[0].pages()[0].goto(server.EMPTY_PAGE);+ await cdpBrowser.close();+ } finally {+ await browserServer.close();+ }+});+playwrightTest('should connect to existing service workers', async ({browserType, browserOptions, server}, testInfo) => {const port = 9339 + testInfo.workerIndex;const browserServer = await browserType.launch({