Bug 20425 - window.location.replace seems to add history entries in this test case
: window.location.replace seems to add history entries in this test case
Status: UNCONFIRMED
: WebKit
WebCore Misc.
: 525.x (Safari 3.1)
: PC Linux
: P2 Normal
Assigned To:
: http://desktop.nostdal.org/~lnostdal/...
:
:
:
  Show dependency treegraph
 
Reported: 2008-08-18 03:35 PST by
Modified: 2010-07-19 00:05 PST (History)


Attachments


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2008-08-18 03:35:09 PST
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 From 2008-09-13 02:55:06 PST -------
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 From 2008-09-26 06:46:02 PST -------
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 From 2008-10-22 16:15:35 PST -------
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.