fix: handle frame manager init without unhandled rejection (#10902)

This commit is contained in:
Alex Rudenko 2023-09-13 19:51:58 +02:00 committed by GitHub
parent 4b8d20d0ed
commit ea14834fdf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 9 deletions

View File

@ -238,19 +238,16 @@ export class FrameManager extends EventEmitter<FrameManagerEvents> {
async initialize(client: CDPSession): Promise<void> { async initialize(client: CDPSession): Promise<void> {
try { try {
const networkInit = this.#networkManager.addClient(client);
const result = await Promise.all([
client.send('Page.enable'),
client.send('Page.getFrameTree'),
]);
const {frameTree} = result[1];
this.#handleFrameTree(client, frameTree);
await Promise.all([ await Promise.all([
this.#networkManager.addClient(client),
client.send('Page.enable'),
client.send('Page.getFrameTree').then(({frameTree}) => {
this.#handleFrameTree(client, frameTree);
}),
client.send('Page.setLifecycleEventsEnabled', {enabled: true}), client.send('Page.setLifecycleEventsEnabled', {enabled: true}),
client.send('Runtime.enable').then(() => { client.send('Runtime.enable').then(() => {
return this.#createIsolatedWorld(client, UTILITY_WORLD_NAME); return this.#createIsolatedWorld(client, UTILITY_WORLD_NAME);
}), }),
networkInit,
]); ]);
} catch (error) { } catch (error) {
// The target might have been closed before the initialization finished. // The target might have been closed before the initialization finished.

View File

@ -4088,7 +4088,7 @@
{ {
"testIdPattern": "[coverage.spec] Coverage specs JSCoverage resetOnNavigation should report scripts across navigations when disabled", "testIdPattern": "[coverage.spec] Coverage specs JSCoverage resetOnNavigation should report scripts across navigations when disabled",
"platforms": ["darwin", "linux", "win32"], "platforms": ["darwin", "linux", "win32"],
"parameters": ["chrome", "new-headless", "cdp", "tabTarget"], "parameters": ["cdp", "chrome", "new-headless", "tabTarget"],
"expectations": ["FAIL"] "expectations": ["FAIL"]
} }
] ]