3

I have ported a Chrome/FireFox extension. One of the things that does not work is receiving message from background to a options page (safari-web-extension:///page.html)

I dont get a error message or any details back from the promise. Any idea where this goes wrong?

Background:

browser.tabs.sendMessage(tab.id, { message });

Options page:

browser.runtime.onMessage.addListener(message => {
        console.log(message);
});
Arnoud Kooi
  • 1,588
  • 4
  • 17
  • 25
  • hey, were you able to find solution for this? I'm facing the same challenge with Safari, a lot of my functionality depends on message passing and I'd hate to rewrite almost an entire extension to support safari. The listener works when I click on extension icon on top bar, so we can say the listener is added and it works only on user interaction, it's not instant like the chrome. Please let me know if you have found solution/workaround...tia – Gaurav Pingale Feb 19 '21 at 10:01

2 Answers2

0

Much better to use the long lived connections ports

https://developer.chrome.com/extensions/messaging#connect

Ziv Adler
  • 169
  • 2
  • 11
0

It looks like safari-web-extension pages receive background script messages but they don't seem to receive messages that are sent via chrome.tabs.sendMessage.

Bret
  • 883
  • 1
  • 9
  • 18