Is it possible to communicate between two packaged apps in Firefox OS using postMessage, like the way when you post a messages from a parent to an Iframe:
var targetOrigin = document.location.protocol + '//' + document.location.host;
var otherWindow = document.getElementById("iframe").contentWindow;
otherWindow.postMessage("TestMessage", targetOrigin);
So my questions are:
The same origin policy (http://en.wikipedia.org/wiki/Same-origin_policy) prevents you from getting a reference to the window object and using postMessage to an app from a different origin. Each packaged app has its own origin.
There is a new API being developed to do what you're talking about in a safe way called the Inter-app Communications API (https://wiki.mozilla.org/WebAPI/Inter_App_Communication_Alt_proposal), but I think that is only currently only available for certified apps until it is a bit more stable.