allowWindowMessaging()
Caution: Dangerous action
API available only to content scripts
Unlocks the transmission of messages to and from window
(top frame of loaded page) contexts in the tab where it is called.
webext-bridge
by default won't transmit any payload to or from window
contexts for security reasons.
This method can be called from a content script (in top frame of tab), which opens a gateway for messages.
Once again, window
= the top frame of any tab. That means allowing window messaging without checking origin first will let JavaScript loaded at https://evil.com
talk with your extension and possibly give indirect access to things you won't want to, like history
API. You're expected to ensure the safety and privacy of your extension's users.
namespace
Required | string
Can be a domain name reversed like com.github.facebook.react_devtools
or any uuid
. Call setNamespace
in window
context with same value, so that webext-bridge
knows which payload belongs to which extension (in case there are other extensions using webext-bridge
in a tab). Make sure namespace string is unique enough to ensure no collisions happen.