Closed Bug 361259 Opened 18 years ago Closed 12 years ago

pageshow event does not fire when changing from one tab to another. works in FF 1.5

Categories

(Firefox :: Tabbed Browser, defect)

defect
Not set
normal

Tracking

()

RESOLVED INVALID

People

(Reporter: alex_mozilla, Unassigned)

Details

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8
Build Identifier: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1) Gecko/20060601 Firefox/2.0 (Ubuntu-edgy)

The code below is a stripped down paraphrase of code in an extension.

Under FF 1.5, the pageshow event fires whenever the user changes the viewed tab, whether by clicking on the tab's tab or by using Control PgUp/PgDn.

Under FF 2.0, the event does not appear to fire when the tab is changed.

One must wonder, then, the best way to find out whether the tab has changed or not.

Extension may be required. But this problem may happen on a normal page, too.

Tested on a Linux box, but there is reason to suppose that this bug is true on a Windows box, too. (The extension's use of the pageshow event does not work on a FF 2.0 on the Windows box.)

var thingee = {
    onPageShow              :   function(e)
    {
      alert("huh");
    }
    
    };

window.addEventListener("pageshow", function(e) { thingee.onPageShow(e); },    true);


Reproducible: Always
I think pagehide/pageshow is meant to be similar to load/unload for pages that understand bfcache.  I don't think it's intented to fire when you switch tabs.
Moreover it would break extensions which depend on the current pageshow/pagehide behaviour (which is to mimic load/unload events in case the page is restored from bfcache). 

For instance, Firebug 1.0 depends on this.

As an alternative, you can register a nsIWebProgressListener listener on the tabbrowser element using addProgressListener(), which will call onLocationChange when the tab are switched.

This bug was reported using Firefox 3.0 or older, which is no longer supported. The bug has also not been changed in over 500 days and is still in UNCO.
Reporter, please retest this bug in Firefox 3.6.10 or later using a fresh profile, http://support.mozilla.com/en-US/kb/managing+profiles. If you still see this problem, please update the bug. If you no longer see the bug, please set the resolution to RESOLVED, WORKSFORME.

This is a mass search of unconfirmed bugs that have no activity on them, so if you feel a bug was marked in error, just remove the CLOSEME comment in the whiteboard within the next month.
Whiteboard: [CLOSEME 2010-11-15]
No reply, INCOMPLETE. Please retest with Firefox 3.6.12 or later and a new profile (http://support.mozilla.com/kb/Managing+profiles). If you continue to see this issue with the newest firefox and a new profile, then please comment on this bug.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → INCOMPLETE
Stealing this bug.

In current mozilla-inbound builds (2012-04-29), gBrowser::pageshow does not fire when switching tabs if the tab is already loaded.

If the tab has not been loaded, pageshow fires shortly after tabbrowser::DOMTitleChanged.

This makes it fantastically difficult to write an addon that keeps a page title in a modified state; the addon code will run the first time the page loads, but as soon as the user switches to a different tab and back again, the title is reverted and the addon code doesn't get a chance to fix it.

First load of a tab:

---
pageshow
DOMTitleChanged
load
pageshow
pageshow
pageshow
DOMTitleChanged
DOMTitleChanged
load
pageshow
DOMTitleChanged
load
pageshow
load
pageshow
---

Switch to about:home tab:

---
DOMTitleChanged
load
pageshow
---

Switch back to first tab:

---
---

Ruh roh.


https://developer.mozilla.org/En/Listening_to_events_in_Firefox_extensions says:

load 	Dispatched after the page—including images—has first finished loading.
unload 	Dispatched when the user has navigated away from the page.
pageshow 	Dispatched when a page is newly displayed.
pagehide 	Dispatched when a page is hidden.

The only alternative event that I could see applying here is "activate", but that doesn't fire on either gBrowser or tabbrowser.

Is this a bug, a gap in the event set, or am I missing an event?
Status: RESOLVED → REOPENED
Component: Extension Compatibility → Tabbed Browser
Ever confirmed: true
OS: Linux → All
QA Contact: extension.compatibility → tabbed.browser
Hardware: x86 → All
Resolution: INCOMPLETE → ---
Whiteboard: [CLOSEME 2010-11-15]
There's no such thing as "gBrowser::pageshow". pageshow is basically the same as the load event, modulo bfcache behavior. https://developer.mozilla.org/En/Using_Firefox_1.5_caching#pageshow_event
Status: REOPENED → RESOLVED
Closed: 14 years ago12 years ago
Resolution: --- → INVALID
You need to log in before you can comment on or make changes to this bug.