http://desktop.nostdal.org/~lnostdal/test.html ..and a copy here: <html> <head> </head> <body onload="var before = history.length; window.location.replace('#blah'); var after = history.length; if(before != after) alert(before + ' != ' + after); "> <a href="test.html">again..</a> <p/> (also, it seems i need to click twice on the link for it to trigger a reload .. which isn't the case in FF) </body> </html> ..works as expected (does not add history entry) under FF, Opera and IE
Here is another test-case: http://desktop.nostdal.org/~lnostdal/test2.html ..and the code for it: <html> <head> </head> <body> <button onclick="window.location.replace('#' + new Date().getTime());"> clicking me should not add a history entry </button> </body> </html> ..works as expected (does not add history entry) under FF and IE.
I was asked to cite some "real world" examples, and I'll try, but this is somewhat hard because I haven't cared about adding web-kit support for my web-apps at all because of this exact bug. It's a chicken-and-egg problem; there are no real world examples (for web-kit!) because there can't _be_ no real world examples because of this bug .. but ok: http://groups.google.com/group/symbolicweb ..in particular in the examples which illustrate history; `history' and `checkbox'. http://varefalne.no/ ..history and back-button. I'm not sure these even work good enough in web-kit to show this bug in action; again for the same reason that adding web-kit support has been pointless because of this bug.
To be clear, this bug concerns history entries only, and not reloads. When only the fragment part of the location is changed (e.g. from "#foo" to "#bar") using location.replace, a history entry should not be added. The test case provided by larsnostdal is an edge case where the fragment is completely removed (including the "#"). Whether or not a server request occurs when the '#' is completely removed is debatable; I believe Mozilla is the only major browser that does the reload in the edge case.