fix(webdriver): emit CDP events (#12058)

This commit is contained in:
Nikolay Vitkov 2024-03-08 15:15:05 +01:00 committed by GitHub
parent e1a9b85bbe
commit 9afe4246bb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View File

@ -471,6 +471,7 @@ export class BidiFrame extends Frame {
targetId: this._id, targetId: this._id,
flatten: true, flatten: true,
}); });
await this.browsingContext.subscribe([Bidi.ChromiumBidi.BiDiModule.Cdp]);
return new BidiCdpSession(this, sessionId); return new BidiCdpSession(this, sessionId);
} }

View File

@ -539,6 +539,14 @@ export class BrowsingContext extends EventEmitter<{
}); });
} }
@throwIfDisposed<BrowsingContext>(context => {
// SAFETY: Disposal implies this exists.
return context.#reason!;
})
async subscribe(events: string[]): Promise<void> {
await this.#session.subscribe(events, [this.id]);
}
[disposeSymbol](): void { [disposeSymbol](): void {
this.#reason ??= this.#reason ??=
'Browsing context already closed, probably because the user context closed.'; 'Browsing context already closed, probably because the user context closed.';

View File

@ -163,9 +163,10 @@ export class Session
// SAFETY: By definition of `disposed`, `#reason` is defined. // SAFETY: By definition of `disposed`, `#reason` is defined.
return session.#reason!; return session.#reason!;
}) })
async subscribe(events: string[]): Promise<void> { async subscribe(events: string[], contexts?: string[]): Promise<void> {
await this.send('session.subscribe', { await this.send('session.subscribe', {
events, events,
contexts,
}); });
} }