chore: expose Connection methods relevant for extension (#8594)

This commit is contained in:
Alex Rudenko 2022-06-28 14:48:29 +02:00 committed by GitHub
parent 79e11985ba
commit 468ea8fca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -66,7 +66,7 @@ export class Connection extends EventEmitter {
this.#delay = delay;
this.#transport = transport;
this.#transport.onmessage = this.#onMessage.bind(this);
this.#transport.onmessage = this.onMessage.bind(this);
this.#transport.onclose = this.#onClose.bind(this);
}
@ -81,6 +81,13 @@ export class Connection extends EventEmitter {
return this.#closed;
}
/**
* @internal
*/
get _sessions(): Map<string, CDPSession> {
return this.#sessions;
}
/**
* @param sessionId - The session id
* @returns The current CDP session if it exists
@ -126,7 +133,10 @@ export class Connection extends EventEmitter {
return id;
}
async #onMessage(message: string): Promise<void> {
/**
* @internal
*/
protected async onMessage(message: string): Promise<void> {
if (this.#delay) {
await new Promise(f => {
return setTimeout(f, this.#delay);