How to derive Tab element from document visibility event?

With the following:

document.addEventListener("visibilitychange", HandleVisibilityChange, false);

And this:

HandleVisibilityChange : function(event) {

}

How do I obtain the Tab element that the document is in?

Thanks

The short answer is you don’t.

The visibilitychange event is fired on the content document. It is for web pages to know when they are visible or not, and they don’t have access to the tab.

It will almost always be better for an addon to use a different event to work with, perhaps TabSelect. You certainly can find the tab for a particular content document, but the API isn’t really set up for this and it becomes a whole lot more complicated in multi-process Firefox.

There is a mechanism in multiprocess Firefox to detect visibilitychange events in the content process and to fire an event in the chrome process, but it has a special name and isn’t something you would normally want to listen for.

OK, thanks for the quick response.