Skip to content

@run-at document-start sometimes fires twice (history.replaceState) #1560

qufighter opened this Issue Jun 1, 2012 · 2 comments

2 participants


Originally detected on Facebook in Firefox 12 by Matt Kruse

Test scripts may be found here, the userscript has been separated below the HTML test page

Original test page may be here:

It was discovered that when Facebook calls history.replaceState that document-start scripts fire again.

"I also noticed that FB is calling replaceState with only two arguments, and no url."

Greasemonkey is injecting scripts and testing (aProgress.isLoadingDocument) before running scripts:

Related event documentation:

Additionally a sample of some of the code that may be triggering these problems can be found here

Whether or not this is a moz bug, a facebook bug, or a GM oversight is tbd, since the tab is not loading a new document when the history state is replaced, the URL did not change (in this case), yet the page seems to think it isLoadingDocument again.

When navigating a site, history.pushState and history.replaceState should not trigger a document-start script to run again. One of these passes the test and the other does not.

"history.replaceState() operates exactly like history.pushState() except that replaceState() modifies the current history entry instead of creating a new one."


#1565 may have changed this


The thread linked was from May 2012, when 0.9.20 was the live version. When I install 0.9.20 into Firefox 18.0.1, I see two alerts as described. When I install 1.7.1, I do not, I just see the first.

Closing this as obsolete; it was probably fixed by #1565 as mentioned above.

@arantius arantius closed this Jan 24, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.