Is Firefox MV3 intentionally not supporting browser.runtime.onMessage in MV3 userScripts API? Why?
For Chrome, it supports both sending (browser.runtime.sendMessage) and receiving (browser.runtime.onMessage).
browser.runtime.onMessage can receive the browser.tabs.sendMessage from the background.
It means that it can perform the following communication between background and userScripts in the following method.
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/tabs/sendMessage
So the communication would be
userScripts browser.runtime.sendMessage → background browser.runtime.onMessage browser.runtime.onUserScriptMessage
In the above, there is sender information containing the tabId, frameId, documentId, etc.
We can store the sender information and sendMessage to the userScripts later. For example, we need click a button in our popup menu, to command the userScripts to run some actions which apply only on the current window current active tab.
background browser.tabs.sendMessage(tab.id, ...) → userScripts browser.runtime.onMessage
This is what Chrome MV3 is supporting.
Why Firefox MV3 only supports sending (browser.runtime.sendMessage)?
https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/API/userScripts#messaging
There is no clear description in MDN docs for my question. I don’t understand why MV3 userScripts API can send but not receive.