Class: AsyncMessageChannel

proxy.AsyncMessageChannel()

Provides a transparent interface between chrome- and content space.

The AsyncMessageChannel is an abstraction of the message manager IPC architecture allowing calls to be made to any registered message listener in Marionette. The #send(...) method returns a promise that gets resolved when the message handler calls .reply(...).

Constructor

new AsyncMessageChannel()

Source:

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.

Source:
Returns:

Path to be used for nsIMessageListener.addMessageListener.

Type
string

addHandlers()

Add all necessary handlers for events and observer notifications.

Source:

removeHandlers()

Remove all registered handlers for events and observer notifications.

Source:

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.

Source:

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.

Source:
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