From df1753f4e1e95336892794fec7b9994e51f5e966 Mon Sep 17 00:00:00 2001 From: Peter Hedenskog Date: Mon, 11 Mar 2024 13:41:22 +0100 Subject: [PATCH] Add missing asyncs (#2094) --- lib/core/engine/command/bidi.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/core/engine/command/bidi.js b/lib/core/engine/command/bidi.js index 9c54dbbe2..a20f01e0f 100644 --- a/lib/core/engine/command/bidi.js +++ b/lib/core/engine/command/bidi.js @@ -28,7 +28,7 @@ export class Bidi { */ async onMessage(f) { if (this.browserName === 'firefox') { - const client = this.engineDelegate.getBidi(); + const client = await this.engineDelegate.getBidi(); const ws = await client.socket; ws.on('message', f); } else { @@ -38,11 +38,12 @@ export class Bidi { /** * Retrieves the raw client for Bidi. - * @example const bidi = commands.bidi.getRawClient(); - * @returns {Object} The raw Bidi client. + * @async + * @example const bidi = await commands.bidi.getRawClient(); + * @returns {Promise} A promise that resolves to the Bidi client. * @throws {Error} Throws an error if the browser is not supported. */ - getRawClient() { + async getRawClient() { if (this.browserName === 'firefox') { return this.engineDelegate.getBidi(); } else { @@ -59,9 +60,9 @@ export class Bidi { */ async subscribe(messageType) { if (this.browserName === 'firefox') { - const client = this.engineDelegate.getBidi(); + const client = await this.engineDelegate.getBidi(); return client.subscribe(messageType, [ - this.engineDelegate.getWindowHandle() + await this.engineDelegate.getWindowHandle() ]); } else { throw new Error('Bidi only supported in Firefox'); @@ -77,7 +78,7 @@ export class Bidi { */ async unsubscribe(messageType) { if (this.browserName === 'firefox') { - const client = this.engineDelegate.getBidi(); + const client = await this.engineDelegate.getBidi(); return client.unsubscribe(messageType, [ this.engineDelegate.getWindowHandle() ]); @@ -98,7 +99,7 @@ export class Bidi { async send(parameters) { if (this.browserName === 'firefox') { try { - const client = this.engineDelegate.getBidi(); + const client = await this.engineDelegate.getBidi(); return client.send(parameters); } catch (error) { log.error('Could not send to Bidi command %j', parameters);