Call this function to set up a connection between the extension's background scripts (or other privileged scripts, such as popup scripts or options page scripts) and any content scripts that belong to this extension and are running in the specified tab. This function returns a runtime.Port
object.
When this is called, the runtime.onConnect
event will be fired in any content script belonging to this extension that are running in the specified tab. The event listener will be passed another runtime.Port
object. The two sides can then use the Port
objects to exchange messages.
For more details, see connection-based messaging. You can message without creating a connection, for advice on choosing between the options, see Choosing between one-off messages and connection-based messaging.