Skip to content

Commit

Permalink
Merge branch 'main' into firefox-basic-auth
Browse files Browse the repository at this point in the history
  • Loading branch information
soulgalore authored Mar 11, 2024
2 parents 4b3536b + df1753f commit 1a3ce30
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/core/engine/command/bidi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<Object>} 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 {
Expand All @@ -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');
Expand All @@ -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()
]);
Expand All @@ -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);
Expand Down

0 comments on commit 1a3ce30

Please sign in to comment.