Some progress has been made on the bug. I looked at Greasemonkey's code and saw that it (basically) uses event.target.defaultView.location.href in the DomContentLoaded handler to identify the URL of the page that fired the event. However, that is not always accurate. In the case of this bad event, href points to the page you're going back to, but event.target.documentURI points to the page backed out of. This makes Greasemonkey apply the script again when it shouldn't. So, it looks like the bug can be fixed by comparing documentURI against the regular expressions instead.
The jury is still out on if the event should fire or not. "During a page transition, there are two documents that are "live" (in the sense of script possibly running on them) at the same time; they will generally have different URIs, and will have different inner windows (script global objects) but share a single outer window (navigation context). The defaultView property returns the _outer_ window. So a situation in which doc.documentURI != doc.defaultView.location.href is normal during a page transition. If Greasemonkey is really trying to tell the "document location" for the document which fired DOMContentLoaded, it needs to be looking at the document, not the window." On Feb 23, 7:45 pm, Fracture <[email protected]> wrote: > Thanks for the quick reply, Anthony. > > I've filed a bug at bugzilla.mozilla.org about this issue. > > https://bugzilla.mozilla.org/show_bug.cgi?id=548145 > > On Feb 23, 5:31 pm, Anthony Lieuallen <[email protected]> wrote: > > > On 02/23/10 16:41, Fracture wrote: > > > > I'm guessing that Firefox/Greasemonkey doesn't fully destroy the old > > > page environment until the next page is drawn, so when you go back to > > > the old page, it loads it from memory/cache > > > This is called "fastback". > > > > another load event is > > > fired, and Greasemonkey applies the script again. Perhaps this is a > > > bug in Firefox itself, and the extra load event should not be fired. > > > Yes, it shouldn't fire DOMContentLoaded if it didn't load the DOM (but > > rather restore the fastback cached version). > > -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/greasemonkey-users?hl=en.
