1

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?

Z T
  • 543
  • 1
  • 7
  • 26

1 Answers1

0

A GeckoSession's 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

Agi Sferro
  • 626
  • 3
  • 12