We have tabId: "this" for this purpose:
however it only works between extension pages because:
-
only extension pages can use chrome.tab without intermediary steps
-
the current logic only handles "this" by comparing the sender to the current context, but this could be trivially changed:
on send:
if isContentScript && tabId === "this"
send to background
on background receive:
if tabId === "this"
forward to this.trace[0].tab.id
|
// Set "this" tab to the current tabId |
|
if (to.tabId === "this" && thisTarget.tabId === from.tab?.id) { |
|
to.tabId = thisTarget.tabId; |
|
} |
We have
tabId: "this"for this purpose:however it only works between extension pages because:
only extension pages can use chrome.tab without intermediary steps
the current logic only handles
"this"by comparing the sender to the current context, but this could be trivially changed:webext-messenger/source/thisTarget.ts
Lines 68 to 71 in ed302a0