I’m trying to send a message from a content script to an injected iframe that’s located in the extension’s file tree (using the polyfill). This is the extension’s layout
It goes like this:
-
content.js
addsui/bookpanel.html
as an iframe and waits for it to load -
bookpanel.html
includes the browser polyfill js (dist/browser-polyfill.min.js
) and starts listening for runtime messages once loaded (browser.runtime.onMessage.addListener(...
) -
content.js
then sends data usingbrowser.runtime.sendMessage
to the iframe
Here’s where I get the error
Error: Could not establish connection. Receiving end does not exist.
So it looks like the listener is unreachable. Funny thing is that it works in Chrome but not in Firefox. I’ve tried to add the page to the manifest as a background page, but is not a solution as all messages go to that instance instead of the ones loaded in the iframes.