chore: emit CDP event only on CdpSession (#11393)

This commit is contained in:
Nikolay Vitkov 2023-11-16 09:31:41 +01:00 committed by GitHub
parent 8644744dce
commit 923434bd56
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -221,6 +221,12 @@ export class BidiConnection extends EventEmitter<BidiEvents> {
);
return;
case 'event':
if (isCdpEvent(object)) {
cdpSessions
.get(object.params.session)
?.emit(object.params.event, object.params.params);
return;
}
this.#maybeEmitOnContext(object);
// SAFETY: We know the method and parameter still match here.
this.emit(
@ -244,10 +250,6 @@ export class BidiConnection extends EventEmitter<BidiEvents> {
event.params.source.context !== undefined
) {
context = this.#browsingContexts.get(event.params.source.context);
} else if (isCdpEvent(event)) {
cdpSessions
.get(event.params.session)
?.emit(event.params.event, event.params.params);
}
context?.emit(event.method, event.params);
}