WebChannel.jsm

TheWebChannel.jsm JavaScript code module provides an abstraction that uses the Message Manager and Custom Events APIs to create a two-way communication channel between chrome and content code for specific origins (using a specific origin passed to the constructor or a lookup with nsIPermissionManager while also ensuring the scheme is HTTPS).

Components.utils.import("resource://gre/modules/WebChannel.jsm");

Constructor

WebChannel(String webChannelId, nsIURI originOrPermission);

2nd argument is a valid origin that should be part of requests for this channel.

WebChannel(String webChannelId, string originOrPermission);

2nd argument is a permission for which the permission manager will be checked to determine if the request is allowed. Note that in addition to the permission manager check, the request must be made over https.

Method overview

listen(Function callback);

stopListening();

send(Object message, EventTarget target);

Attributes

id

String

WebChannel id

Methods

listen()

Registers the callback for messages on this channel. Registers the channel itself with the WebChannelBroker.