Notes
Following rules apply to destination being specified in sendMessage(msgId, data, destination) and openStream(channelId, initialData, destination)
- Specifying
devtoolsas destination fromcontent-scriptwill auto-route payload to inspectingdevtoolspage 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-scriptas destination fromdevtoolswill auto-route the message to inspected window's topcontent-scriptpage if listening. If page is loading, message will be queued up and delivered when page is ready and listening. - If
windowcontext (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, sinceBridgewill first deliver the payload tocontent-scriptusing rules above, and latter will take over and forward accordingly.content-script<->windowmessaging happens usingwindow.postMessageAPI. Therefore to avoid conflicts,Bridgerequires you to callsetNamespace(uuidOrReverseDomain)inside the said window script (injected or remote, doesn't matter). - Specifying
devtoolsorcontent-scriptorwindowfrombackgroundwill throw an error. When calling frombackground, destination must be suffixed with tab id. Likedevtools@745fordevtoolsinspecting tab id 745 orcontent-script@351for topcontent-scriptat tab id 351.