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

@ -16,6 +16,13 @@ chrome.runtime.onMessage.addListener((message, sender, sendResponse) => {
chrome.tabs.executeScript(tabId, { code }, ([result]) => sendResponse(result))
break
}
case 'connectTab': {
const [name] = args
const port = chrome.tabs.connect(tabId, { name })
port.postMessage('howdy')
break
}
}
// Respond asynchronously
return true