nsIJetpack 编辑
js/jetpack/nsIJetpack.idl
Scriptable This interface enables communication between the chrome process and a remote Jetpack process. 1.0 66 Introduced Gecko 2.0 Inherits from: nsISupports
Last changed in Gecko 2.0 (Firefox 4 / Thunderbird 3.3 / SeaMonkey 2.1)Method overview
void sendMessage(in AString aMessageName /* [optional] in jsval v1, [optional] in jsval v2, ... */); |
void registerReceiver(in AString aMessageName, in jsval aReceiver); |
void unregisterReceiver(in AString aMessageName, in jsval aReceiver); |
void unregisterReceivers(in AString aMessageName); |
void evalScript(in AString aScript); |
nsIVariant createHandle(); |
void destroy(); |
Methods
sendMessage()
This method asynchronously sends a message to the Jetpack process.
void sendMessage( in AString aMessageName, [optional] in jsval v1, Optional [optional] in jsval v2, Optional ... );
Parameters
aMessageName
- The name of the message to send.
v1, v2, ...
Optional- JavaScript values to send with the message; they must be either JSON-serializable types or handles.
registerReceiver()
This registers a callback to be triggered whenever the Jetpack process sends a particular message.
Note: Multiple callbacks may be registered for the same message; they will all be triggered.void registerReceiver( in AString aMessageName, in jsval aReceiver );
Parameters
aMessageName
- The name of the message from the Jetpack process on which the callback is triggered.
aReceiver
- A JavaScript function. The first argument passed to it is the name of the message, and all arguments following it are either JSON-serializable types or handles. If the message was sent synchronously from the Jetpack process via
callMessage()
, then the return value of this function is passed back to the Jetpack process.
unregisterReceiver()
This unregisters a callback previously registered with registerReceiver()
void unregisterReceiver( in AString aMessageName, in jsval aReceiver );
Parameters
aMessageName
- The name of the message on which the callback should no longer be triggered.
aReceiver
- The JavaScript function that should no longer be triggered.
unregisterReceivers()
This unregisters all callbacks previously registered with registerReceiver()
for a particular message.
void unregisterReceivers( in AString aMessageName );
Parameters
aMessageName
- The name of the message to unregister all callbacks from.
evalScript()
This asynchronously sends code to the Jetpack process for evaluation. The code will be evaluated using at least JavaScript 1.8.1.
When evaluated, the script's global scope will include all privileged APIs.
Individual lines of the form //@line 1 "foo.js"
can be used to specify filename and line number information for debugging purposes.
void evalScript( in AString aScript );
Parameters
aScript
- The full contents of the script to evaluate in the Jetpack process.
createHandle()
This creates an opaque handle that can transparently be exchanged between processes.
nsIVariant createHandle();
Parameters
None.
Return value
The new handle.
destroy()
This terminates the Jetpack process.
void destroy();
Parameters
None.
Special Messages
If an exception goes uncaught in the Jetpack process, it will be reported to the chrome process via a message with the name core:exception
. The message comes with one argument, which represents the exception object that was thrown.
Warning: bug 589308 prevents this message from being sent in some situations.
History
See bug 556846 for details.
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论