Methods
(static) makePath(uuid) → {string}
Produces a path, or a name, for the message listener handler that listens for a reply.
Parameters:
Name | Type | Description |
---|---|---|
uuid |
UUID | Unique identifier of the channel request. |
Returns:
Path to be used for nsIMessageListener.addMessageListener.
- Type
- string
addHandlers()
Add all necessary handlers for events and observer notifications.
removeHandlers()
Remove all registered handlers for events and observer notifications.
reply(uuid, obj)
Reply to an asynchronous request.
Passing an WebDriverError
prototype will cause the receiving
channel to throw this error.
Usage:
let channel = proxy.AsyncMessageChannel(
messageManager, sendAsyncMessage.bind(this));
// throws in requester:
channel.reply(uuid, new WebDriverError());
// returns with value:
channel.reply(uuid, "hello world!");
// returns with undefined:
channel.reply(uuid);
Parameters:
Name | Type | Description |
---|---|---|
uuid |
UUID | Unique identifier of the request. |
obj |
* | Message data to reply with. |
send(name, argsopt) → {Promise}
Send a message across the channel. The name of the function to call must be registered as a message listener.
Usage:
let channel = new AsyncMessageChannel(
messageManager, sendAsyncMessage.bind(this));
let rv = await channel.send("remoteFunction", ["argument"]);
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
name |
string | Function to call in the listener, e.g. for the message listener Marionette:foo8, use foo. |
|
args |
Array.<?> |
<optional> |
Argument list to pass the function. If args has a single entry that is an object, we assume it's an old style dispatch, and the object will passed literally. |
Throws:
-
-
If an unsupported reply type is received.
- Type
- TypeError
-
-
-
If an error is returned over the channel.
- Type
- WebDriverError
-
Returns:
A promise that resolves to the result of the command.
- Type
- Promise