Add helpers for message passing with extensions
In Tor Browser, we need to communicate with NoScript and HTTPSEverywhere extensions via message passing. Currently, we do it in a way that the background script of those extensions will receive the message via browser.runtime.onMessage
as if those messages came from some page of the same webextension.
In https://bugzilla.mozilla.org/show_bug.cgi?id=1583484 (79) the underlying message passing mechanism changed, which means we need to fix our code too. I think it's a good opportunity to refactor the code into a single place that is used both for noscript
(torbutton) and https-everywhere
(onion alias patch) message passing.