To be sure I understand your case: you have a web page and in that
page you have an iframe with a src="chrome-extension://<some extension
id>/index.html". Correct?
I do this by the following steps:
In the web app, before the chrome iframe can load:
window.addEventListener('message'...)
Load the chrome frame (I do this by appending the 'iframe' element,
to be sure about order of calls).
In the chrome iframe, in the onload event handler,
window.addEventListener('message', ...
window.parent.postMessage("howdy", "*"); // broadcast howdy
Now we come back to the web-apps 'message' handler. The event we get
will have a 'source' property, that is the window object we use for
return messages back to the iframe.
In practice the code is more complex for two reasons:
1) You should verify that the message event.origin matches your
chrome-extension id to avoid being spoofed by another window,
2) You should target the message from the iframe to the enclosing
domain (event.origin) rather than '*". For this reason I send one
round of "introduction" messages before binding the handlers to the
message processing.
In case it helps, my code is here:
https://github.com/johnjbarton/crx2app
It's more complicated perhaps than you need, FWIW.
jjb