fix(connect): report all frames in existing page to the client (#8910)

This commit is contained in:
Yury Semikhatsky 2021-09-14 12:44:49 -07:00 committed by GitHub
parent 5f704edc6c
commit bdea9c74c4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 0 deletions

View file

@ -79,6 +79,10 @@ export class PageDispatcher extends Dispatcher<Page, channels.PageInitializer, c
page.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 {

View file

@ -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({