Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

A way to determine that no tab is currently loading?

4 views
Skip to first unread message

neandr

unread,
May 30, 2011, 5:39:53 PM5/30/11
to
Here is a post Tom, the author of Reminderfox, wrote some days ago.
https://forums.mozilla.org/addons/viewtopic.php?f=7&t=3209

Maybe here are experts around to answer his question:

A way to determine that no tab is currently loading?
Hi there,
I'm trying to delay some activation code in my addon to only execute
after all tabs are finished loading. I'm not sure of the best way to do
this. I tried to add some onLoad listeners to get called when all
counted tabs finished loading, but in some cases there could be many
tabs but they are not all set to load at startup (depending on user
configuration).
So instead I thought, when my addon starts up it could just quickly scan
all tabs; if any were still in the process of loading, it would continue
to wait. Only when it determined that there were no tabs currently in a
state of loading would it execute the logic.

So my question is - is there a way to query across all tabs to see if
any are in a loading state?

Thanks
Tom

Neil

unread,
May 31, 2011, 4:48:59 AM5/31/11
to
neandr wrote:

> I'm trying to delay some activation code in my addon to only execute
> after all tabs are finished loading. I'm not sure of the best way to
> do this.

Session store sends out a "sessionstore-windows-restored" observer
notification when all tabs have finished loading.

--
Warning: May contain traces of nuts.

Tom

unread,
May 31, 2011, 9:33:54 AM5/31/11
to
On May 31, 4:48 am, Neil <n...@parkwaycc.co.uk> wrote:
> neandr wrote:
> > I'm trying to delay some activation code in my addon to only execute
> > after all tabs are finished loading. I'm not sure of the best way to
> > do this.
>
> Session store sends out a "sessionstore-windows-restored" observer
> notification when all tabs have finished loading.
>
> --

Thanks for the tip. I gave that a try and that event fires way too
early it seems (a known behavior I guess, as the documentation
mentions such a caveat). That seems to fire as soon as the browser
comes up, even though tabs are still loading.

So I'm not sure if there's an event that I can listen to with relative
accuracy; that's why I was looking into some sort of polling solution
where I could check the state of each tab myself, and check if it's
currently in a LOADING state. Does some API like that exist?

-Tom

Neil

unread,
Jun 1, 2011, 4:48:45 AM6/1/11
to
Neil wrote:

> neandr wrote:
>
>> I'm trying to delay some activation code in my addon to only execute
>> after all tabs are finished loading. I'm not sure of the best way to
>> do this.
>
> Session store sends out a "sessionstore-windows-restored" observer
> notification when all tabs have finished loading.

My bad, it sends it out when all windows have opened. But (unless you
set the preference to load all tabs immediately) it won't have even
started loading all tabs, let alone finished.

neandr

unread,
Jun 1, 2011, 5:10:48 AM6/1/11
to
There should be an event/observer with finishing loading. If you use the
"Reload current page" button as part of the url box it turns to a X with
red background and only after finishing loading it turns to the circled
arrow with white background.

Maybe the status of that button(s) could be polled somehow?
Anyone having an idea here?

Günter

Neil

unread,
Jun 1, 2011, 5:20:13 AM6/1/11
to
neandr wrote:

> There should be an event/observer with finishing loading. If you use
> the "Reload current page" button as part of the url box it turns to a
> X with red background and only after finishing loading it turns to the
> circled arrow with white background.
>
> Maybe the status of that button(s) could be polled somehow?

You could look at the browser's docShell.isLoadingDocument which will
tell you if it's currently busy (and you could then attach a web
progress listener or other event handler to notify when it stops) but
that won't help with tabs that haven't started loading yet.

0 new messages