Make a connection between different contexts inside the extension.
You can call this:
- in an extension's content scripts, to establish a connection with the extension's background scripts (or similarly privileged scripts, like popup scripts or options page scripts).
- in an extension's background scripts (or similarly privileged scripts), to establish a connection with a different extension.
Note that you can't use this function to connect an extension to its content scripts. To do this, use tabs.connect().
By default, this connection enables the extension to exchange messages with itself or any other extension (if extensionId is specified). However, the externally_connectable manifest key can be used to limit communication to specific extensions and enable communication with websites. Connections within the extension trigger the runtime.onConnect event, connections from other extensions or web pages trigger the runtime.onConnectExternal event.