I am trying to create 2 GeckoSessions to represent two tabs.
I have a web extension with a background script. I want to send a separate message to each tab’s content script, but for that I need to know the tab id (I don’t want to send the messages to all tabs because each tab can have the same page loaded).
What would be the best way to get the tab id of each GeckoSession object?
tabId is not currently exposed to the GeckoView API. The normal way this would be done is opening a port directly from the content script calling
connectNative, which triggers an
onConnect on the
MessageDelegate. You can then hold on onto the
Port objects in Java and send messages directly to the content script, there’s an example here: https://mozilla.github.io/geckoview/consumer/docs/web-extensions#connection-based-messaging