Notes
Following rules apply to destination
being specified in sendMessage(msgId, data, destination)
and openStream(channelId, initialData, destination)
- Specifying
devtools
as destination fromcontent-script
will auto-route payload to inspectingdevtools
page if open and listening. If devtools are not open, message will be queued up and delivered when devtools are opened and the user switches to your extension's devtools panel. - Specifying
content-script
as destination fromdevtools
will auto-route the message to inspected window's topcontent-script
page if listening. If page is loading, message will be queued up and delivered when page is ready and listening. - If
window
context (which could be a script injected by content script) are source or destination of any payload, transmission must be first unlocked by callingallowWindowMessaging(<namespace: string>)
inside that page's top content script, sinceBridge
will first deliver the payload tocontent-script
using rules above, and latter will take over and forward accordingly.content-script
<->window
messaging happens usingwindow.postMessage
API. Therefore to avoid conflicts,Bridge
requires you to callsetNamespace(uuidOrReverseDomain)
inside the said window script (injected or remote, doesn't matter). - Specifying
devtools
orcontent-script
orwindow
frombackground
will throw an error. When calling frombackground
, destination must be suffixed with tab id. Likedevtools@745
fordevtools
inspecting tab id 745 orcontent-script@351
for topcontent-script
at tab id 351.