Classes
Methods
getRawClient() → {Promise.<Object>}
Retrieves the raw client for Bidi.
Throws:
- Throws an error if the browser is not supported.
- Type
- Error
Returns:
A promise that resolves to the Bidi client.
- Type:
- Promise.<Object>
Example
const bidi = commands.bidi.getRawClient();(async) onMessage(f)
Add a fanction that will get the events that you subscribes.
Parameters:
| Name | Type | Description | 
|---|---|---|
| f | function | The callback function to handle incoming messages. The function will get an event passed on to it. Remember to subscribe to the event. | 
Throws:
- Throws an error if the method is called in a browser other than Firefox.
- Type
- Error
Example
await commands.bidi.onMessage(function(event) {
 const myEvent = JSON.parse(Buffer.from(event.toString()));
 console.log(myEvent);
});(async) send(parameters) → {Promise.<Object>}
Sends a command using Bidi.
Parameters:
| Name | Type | Description | 
|---|---|---|
| parameters | Object | The paramaters for the command. | 
Throws:
- Throws an error if the browser is not supported or if the command fails.
- Type
- Error
Returns:
A promise that resolves when the command has been sent.
- Type:
- Promise.<Object>
Example
const params = {
  method: 'script.addPreloadScript',
  params: {
    functionDeclaration: "function() {alert('hello')}"
   }
 };
await commands.bidi.send(params);(async) subscribe(messageType) → {Promise.<Object>}
Subscribe to a event.
Parameters:
| Name | Type | Description | 
|---|---|---|
| messageType | string | The type of message to subscribe to. | 
Throws:
- Throws an error if the method is called in a browser other than Firefox.
- Type
- Error
Returns:
A promise that resolves you have subscribed.
- Type:
- Promise.<Object>
Example
// Subscribe to requests before they are sent
await commands.bidi.subscribe('network.beforeRequestSent');(async) unsubscribe(messageType) → {Promise.<Object>}
Unsubscribe to an event.
Parameters:
| Name | Type | Description | 
|---|---|---|
| messageType | string | The type of message to unsubscribe to. | 
Throws:
- Throws an error if the method is called in a browser other than Firefox.
- Type
- Error
Returns:
A promise that resolves you have unsubscribed.
- Type:
- Promise.<Object>
Example
// Unsubscribe to requests before they are sent
await commands.bidi.unsubscribe('network.beforeRequestSent');