0
votes

The Story

I am developing a Safari Extension with a popover. No-matter how many tabs or windows I have open, only the first one that was loaded dispatches messages to Global.html

I have tried window.onfocus, document.addEventListener("visibilitychange"), safari.self.addEventListener("activate") on the Injected.js.

Windows/Tabs are responding to the above listeners, but only the first-loaded-tab will dispatch a message.

Goal

  1. User changes tab or window
  2. Target Page's Injected.js listens it is activated,
  3. Target Page's Injected.js dispatches message to Global.html
  4. Global.html receives message
  5. Global.html re-renders the Popover.html

Thanks everybody in advance.

Any idea is more than welcome.

1

1 Answers

0
votes

Solved

The problem was hiding inside global.html

I had declared: safari.application.activeBrowserWindow.activeTab.addEventListener("message", messageHandler, false); for listening to messages.

The problem with the above is that activeBrowserWindow.activeTab was linked to the first page that was loaded.

Solution safari.application.addEventListener("message", messageHandler, false)