I have two content Scripts in main.js of Firefox Addon : contentScript A is inside 'panel' module (module A) contentScript B is inside 'page-mod' module (module B) How can they communicate or exchange messages ? I tried to do this by using the following steps : 1. sending message from contentScript A to AddonScript A 2. sending message from AddonScript A to AddonScript B by including module B in A 3. sending message from AddonScript B to contentScript B. However , it doesn't work (rather it does work intermittently , may be due to some errors in code). . Is this method ok ? Can any one please comment on any better method ? . Thanx
Due to how the SDK's security model, any communication between your panel and your page-mod need to be routed through the main add-on code itself. Here is an example that takes data from a form implemented in a Panel and sends it through the main script into a page-mod:
The key piece of code is this one:
You'll notice that, when the page-mod is attached, I set up the panel instance to catch the 'panel-message' event and then emit it directly into the current page-mod worker.