Bug 20425

Summary: window.location.replace seems to add history entries in this test case
Product: WebKit Reporter: Lars Rune Nøstdal <larsnostdal>
Component: WebCore Misc.Assignee: Nobody <webkit-unassigned>
Status: UNCONFIRMED ---    
Severity: Normal CC: jaredjacobs, larsnostdal, sam, webkit
Priority: P2    
Version: 525.x (Safari 3.1)   
Hardware: PC   
OS: Linux   
URL: http://desktop.nostdal.org/~lnostdal/test.html

Description Lars Rune Nøstdal 2008-08-18 03:35:09 PDT
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
Comment 1 Lars Rune Nøstdal 2008-09-13 02:55:06 PDT
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.
Comment 2 Lars Rune Nøstdal 2008-09-26 06:46:02 PDT
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.
Comment 3 Jared Jacobs 2008-10-22 16:15:35 PDT
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.