feat(extensions): add chrome.tabs.connect API (#22457)

* feat(extensions): add chrome.tabs.connect API

* test(extensions): verify that chrome.tabs.connect port communication works
This commit is contained in:
John Kleinschmidt 2020-03-05 09:59:32 -05:00 committed by GitHub
parent d6701ff435
commit 0201b3e571
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 0 deletions

View file

@ -29,6 +29,14 @@ const testMap = {
chrome.runtime.sendMessage({ method: 'executeScript', args: [code] }, response => {
console.log(JSON.stringify(response))
})
},
connectTab (name) {
chrome.runtime.onConnect.addListener(port => {
port.onMessage.addListener(message => {
console.log([port.name, message].join())
})
})
chrome.runtime.sendMessage({ method: 'connectTab', args: [name] })
}
}