Bug 20425 - window.location.replace seems to add history entries in this test case
Summary: window.location.replace seems to add history entries in this test case
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore Misc. (show other bugs)
Version: 525.x (Safari 3.1)
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL: http://desktop.nostdal.org/~lnostdal/...
Depends on:
Reported: 2008-08-18 03:35 PDT by Lars Rune Nøstdal
Modified: 2017-07-18 08:30 PDT (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Lars Rune Nøstdal 2008-08-18 03:35:09 PDT

..and a copy here:

  <body onload="var before = history.length;
                var after = history.length;
                if(before != after)
                  alert(before + ' != ' + after);
    <a href="test.html">again..</a>

    (also, it seems i need to click twice on the link for it to trigger a reload .. which isn't the case in FF)

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

..and the code for it:

    <button onclick="window.location.replace('#' + new Date().getTime());">
      clicking me should not add a history entry

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