Reputation: 627
I have a question. I have a panel in Firefox add-on and I would like to modify things on the page when it is closed. I created a listener on the panel and a content script close.js
that will modify the the page.
panel.port.on("close", function() {
panel.port.emit("close");
});
What I would like to know is how can I debug and verify that the message "close" has effectively been sent ? Because now it is not working but I have no possibility of checking what messages has been sent ?
Do I have to load close.js
as a contentScript when I create the panel ? Knowing that there are other scripts that modify the page that are not loaded when creating the panel...
Upvotes: 1
Views: 38
Reputation: 16508
What I would like to know is how can I debug and verify that the message "close" has effectively been sent ? Because now it is not working but I have no possibility of checking what messages has been sent ?
You can add addon.port.on("close", () => console.log("close message was sent to panel"))
to the content script for the panel. Seeing this message logged will verify that the panel is receiving the "close" message.
Do I have to load close.js as a contentScript when I create the panel ? Knowing that there are other scripts that modify the page that are not loaded when creating the panel...
All panel content scripts have to be added and loaded when the panel is created, there is no option to add a content script after the panel has been created.
Upvotes: 1