Is Firefox MV3 intentionally not supporting `browser.runtime.onMessage` in MV3 userScripts API? Why?

Ahh, sorry I misunderstood what you were saying, @cyfung1031. You’re right, this is a discrepancy between what’s possible in Chrome and Firefox.

To answer the original question, yes, it looks like Firefox is intentionally not supporting browser.runtime.onMesssage. As @rob mentioned in this comment, Firefox collaboratively designed the User Scripts API with other browser vendors in the WebExtensions Community Group (WECG), and the design they created did not expose the runtime.onMesssage event to user scripts. When I spoke with a Firefox add-one engineer about this a bit ago, they confirmed that that’s the design Firefox implemented and intends to continue following.

Personally, I’m aligned with Firefox’s approach and I think Chrome’s implementation is a bug. I intend to final an issue on their repo to lay out my concerns. As I see it, the problem is that Chrome’s current implementation prevents an extension’s content scripts and background script from exchanging messages without exposing them to users scripts that have messaging enabled. This presents a material problem for extensions because user scripts are a less privileged context than content scripts and therefore shouldn’t have access to privileged communications between extension contexts. If we (the broader Web Extension community) want to allow extension contexts to send one-off messages to user scripts, I think extensions APIs should be expanded to explicitly provide that capability.