Confirmed users
157
edits
No edit summary |
No edit summary |
||
| Line 7: | Line 7: | ||
<h3>Content Process</h3> | <h3>Content Process</h3> | ||
For each tab the child process has a JS context/scope, which implements nsIContentFrameMessageManager and nsIDOMEventTarget. That scope is above the current top level content window, so capturing event listeners will be called first using event listeners added in that scope and event listeners added to bubble phase will be called after listeners in the content page. The current top level window can be accessed using <b>content</b> property. The scope has also the methods from nsIDOMEventTarget and the new methods from nsIContentFrameMessageManager: | For each tab the child process has a JS context/scope, which implements nsIContentFrameMessageManager and nsIDOMEventTarget. That scope is above the current top level content window, so capturing event listeners will be called first using event listeners added in that scope and event listeners added to bubble phase will be called after listeners in the content page. The current top level window can be accessed using <b>content</b> property, and <b>docShell</b> points to the nsIDocShell object. The scope has also the methods from nsIDOMEventTarget and the new methods from nsIContentFrameMessageManager: | ||
- <b>addMessageListener</b> adds a listeners for messages coming from chrome. First parameter is the name of the message, second one is the listener (a JS Function). | - <b>addMessageListener</b> adds a listeners for messages coming from chrome. First parameter is the name of the message, second one is the listener (a JS Function). | ||
| Line 40: | Line 40: | ||
{ | { | ||
<b>name</b>: %message name%, | <b>name</b>: %message name%, | ||
<b>target</b>: %the target of the message% | |||
<b>sync</b>: %true or false%, | <b>sync</b>: %true or false%, | ||
<b>json</b>: %json object or null% | <b>json</b>: %json object or null% | ||
} | } | ||
<b>target</b> is in chrome the xul:browser element which got the message and on content process side it is the global scope object (aka <b>TabChildGlobal</b>). | |||
When the CPOW support is added to the synchronous messages, the object will have also property <b>objects</b>. | When the CPOW support is added to the synchronous messages, the object will have also property <b>objects</b>. | ||
Message listeners can be either Javascript functions, which get message as the | |||
only parameter, or listeners can be objects which have <b>receiveMessage</b> function as a property. | |||
<h3>Examples</h3> | <h3>Examples</h3> | ||