For your information, I use this kind of communication in a extension
since it's the only way I found to reconstruct dependably Window
objects DOM (i.e. nested frames) in the background page without
relying on frame src. I cannot rely on frame src because I'm unable to
match a frame with a redirected (HTTP 300x) content
(document.location.href != frame.src).
Actually, reconstructing Window objects DOM is painful.
There should be a way to do this easily. For example, the Port class
could have "parentPort" (storing a reference to parent Window port)
and "childPorts" (storing references to frame Window ports)
properties.
I think also that Window.postMessage should be accessible in a content
script since it's a standard way to send messages between frames. The
"location.href="javascript:parent.postMessage('hi !','*')"; trick is
just ugly.
Regards,
Gildas.