How to postMessage from Firefox frame-script to a web page?

127 Views Asked by At

i'm adjusting my extension to Firefox multiprocess (e10s).

I want to send the webpage some data using a postMessage from the frame-script.

The Firefox documnatation says i should try to use 'content' object instead of the 'window' object. When trying to access the content page i get an error: .

// frame-script.js
addMessageListener("message_from_ext", function(message){
        try{
            var _message = {
                from: "content",
                to: "web",
                data: message
            };
            content.postMessage(_message, "*"); //getting <unavailable> on the content object
        }catch(e){
            console.log(e);
        }
});

how should i access the content object? should i load anything to my frame-script.js?

(I already succeeded in getting data from the webpage, and sending it to the extension and getting back other data from the extension)

1

There are 1 best solutions below

1
On

<unavailable> is not an error, it just means the console you have open cannot display the object properly because it lives in another process.

Open the browser content toolbox and use its console instead to view messages in the content process.