Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
qufighter opened this Issue · 2 comments

2 participants

@qufighter

Originally detected on Facebook in Firefox 12 by Matt Kruse
http://groups.google.com/group/greasemonkey-users/browse_thread/thread/322c7e5478cae4e5

Test scripts may be found here, the userscript has been separated below the HTML test page
https://gist.github.com/2849384

Original test page may be here: http://socialfixer.com/temp/replacestate.html

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: https://github.com/greasemonkey/greasemonkey/blob/master/content/browser.js#L29

Related event documentation: https://developer.mozilla.org/En/XUL/Method/AddTabsProgressListener

Additionally a sample of some of the code that may be triggering these problems can be found here https://gist.github.com/2837089

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."
https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history

@arantius
Collaborator

#1565 may have changed this

@arantius
Collaborator

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
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.