Issue 363724 in chromium: window.location.replace with hash causes navigation when going back

49 views
Skip to first unread message

chro...@googlecode.com

unread,
Apr 15, 2014, 3:45:42 PM4/15/14
to chromi...@chromium.org
Status: Unconfirmed
Owner: ----
Labels: Cr-Content Pri-2 Via-Wizard Type-Bug OS-Mac

New issue 363724 by mark.cau...@escapemg.com: window.location.replace with
hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

UserAgent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_2)
AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.116 Safari/537.36

Example URL:
http://grooveshark.com/#!/artist/Cherub/1998868

Steps to reproduce the problem:
1. Visit an web app that uses # URLs for navigation
2. The web app must use window.location.replace with a # URL on the same
domain
3. Go Back in the history stack

What is the expected behavior?
The page should trigger a hashchange event and allow the web app to handle
the URL change without causing a redirect.

What went wrong?
A redirect occurs and the state of the web app is lost when going back to
the previous URL.

Does it occur on multiple sites: Yes

Is it a problem with a plugin? N/A

Did this work before? Yes Version 33 of Chrome

Does this work in other browsers? Yes

Chrome version: 34.0.1847.116 Channel: stable
OS Version: OS X 10.9.2
Flash Version: Shockwave Flash 11.8 r800

--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings

chro...@googlecode.com

unread,
Apr 15, 2014, 6:30:48 PM4/15/14
to chromi...@chromium.org
Updates:
Labels: Needs-Feedback

Comment #2 on issue 363724 by pucchaka...@chromium.org:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

Can you please check the video that i have attached while trying to
reproduce this issue on Mac osx 10.92 - 34.0.1847.116 (Official Build
260972) and let us know if we have missed anything.



Attachments:
363724 Video Recording.mov 4.3 MB

chro...@googlecode.com

unread,
Apr 15, 2014, 6:33:48 PM4/15/14
to chromi...@chromium.org

Comment #3 on issue 363724 by pucchaka...@chromium.org:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

I am seeing the same behavior on Safari too.

chro...@googlecode.com

unread,
Apr 15, 2014, 8:03:57 PM4/15/14
to chromi...@chromium.org

Comment #4 on issue 363724 by mark.cau...@escapemg.com:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

It looks like you went to the album page (which doesn't do
window.location.replace). For artists, we have to do a replace to ensure
that they wind up on their username (e.g. #!/cherubmusic).

You can tell when the entire page does refresh as the header/player
disappears momentarily.

chro...@googlecode.com

unread,
Apr 15, 2014, 8:10:10 PM4/15/14
to chromi...@chromium.org
Updates:
Labels: -Cr-Content -Type-Bug Cr-Blink-Loader Type-Bug-Regression

Comment #5 on issue 363724 by tk...@chromium.org: window.location.replace
with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

(No comment was entered for this change.)

chro...@googlecode.com

unread,
Apr 16, 2014, 5:21:38 AM4/16/14
to chromi...@chromium.org
Updates:
Cc: msrchan...@chromium.org

Comment #6 on issue 363724 by msrchan...@chromium.org:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

@mark: I have attached a video.
Followed comment# 1. There is problem with navigating to previous page.
Could you please observe the video and let me know if this is the issue you
are noticing.
Thanks in Advance.

Attachments:
363724.mov 5.9 MB

chro...@googlecode.com

unread,
Apr 16, 2014, 7:27:10 AM4/16/14
to chromi...@chromium.org

Comment #8 on issue 363724 by daniilko...@gmail.com:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

Here is another way to reproduce the issue:
https://productforums.google.com/forum/#!topic/chrome-ja/m2OTJr4GcJc

PS: Please use translate link to read message in English.

chro...@googlecode.com

unread,
Apr 16, 2014, 12:35:37 PM4/16/14
to chromi...@chromium.org

Comment #9 on issue 363724 by gustav....@gmail.com: window.location.replace
with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

Can reproduce on Windows 7 too. Worked fine with Chrome 33. Very annoying
in rich web applications that I'm developing.

chro...@googlecode.com

unread,
Apr 28, 2014, 2:59:26 AM4/28/14
to chromi...@chromium.org

Comment #14 on issue 363724 by jumpinja...@gmail.com:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

I've got a gist that should hopefully demonstrate this issue:

https://gist.github.com/jumpinjackie/11362959

Steps to reproduce:

1. Fire up devtools
2. Click any of the Foo/Bar/What/Home buttons
3. Click any of the Tack 1, 2, 3 or 4 params buttons (this uses
window.location.replace to tack on extra query string parameters)
4. Hit the back button

Expect:

DevTools will not break on the window unload handler and no error message
logged to the console.

Get:

DevTools will break on the window unload handler and an error message
logged to console.


This issue is causing absolute havoc with our backbone-based web app which
does many window.location.replace() url updates. Any back button press will
cause a page refresh instead of going back to the previous hash on the
history stack.

OS: Windows 7 SP1
Chrome Version: 34.0.1847.131 m
Does it affect other browsers: No. Tested on Firefox 28.0, IE 11, Safari
6.1.1 on Mac OSX 10.8.5, Mobile Safari on iOS 7.0.4

chro...@googlecode.com

unread,
Apr 30, 2014, 8:34:25 AM4/30/14
to chromi...@chromium.org

Comment #15 on issue 363724 by and...@powerednow.com:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

+1 for fixing this, it's causing all sorts of errors in our webapp too that
builds heavily on hash based navigation.

chro...@googlecode.com

unread,
Apr 30, 2014, 10:31:13 AM4/30/14
to chromi...@chromium.org

Comment #17 on issue 363724 by dan...@dekel.co.uk: window.location.replace
with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

+1, our web based app now refreshes the entire page each time the user
presses the back button. Started happening recently. Other browsers are
just fine (even IE)

chro...@googlecode.com

unread,
Apr 30, 2014, 1:37:48 PM4/30/14
to chromi...@chromium.org
Updates:
Status: Assigned
Owner: jap...@chromium.org
Labels: -Via-Wizard -OS-Mac -Needs-Feedback OS-All

Comment #19 on issue 363724 by jap...@chromium.org: window.location.replace
with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

I have an idea as to how this broke, so assigning to myself.

For the reporters: Repro steps are very helpful, but if you want to
maximize the odds of someone picking up your bug quickly, attach a minimal
webpage that reproduces the bug. It's much harder to resist fixing bugs
when the regression test is already mostly written :)

chro...@googlecode.com

unread,
Apr 30, 2014, 9:31:02 PM4/30/14
to chromi...@chromium.org

Comment #20 on issue 363724 by bugdro...@chromium.org:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724#c20

The following revision refers to this bug:
http://src.chromium.org/viewvc/blink?view=rev&rev=173045

------------------------------------------------------------------
r173045 | jap...@chromium.org | 2014-05-01T00:42:48.953518Z

Changed paths:
A
http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/loader/back-after-same-document-location-replace-expected.txt?r1=173045&r2=173044&pathrev=173045
M
http://src.chromium.org/viewvc/blink/trunk/Source/core/loader/HistoryItem.cpp?r1=173045&r2=173044&pathrev=173045
M
http://src.chromium.org/viewvc/blink/trunk/Source/core/loader/FrameLoader.cpp?r1=173045&r2=173044&pathrev=173045
A
http://src.chromium.org/viewvc/blink/trunk/LayoutTests/fast/loader/back-after-same-document-location-replace.html?r1=173045&r2=173044&pathrev=173045
M
http://src.chromium.org/viewvc/blink/trunk/Source/core/loader/HistoryItem.h?r1=173045&r2=173044&pathrev=173045

location.replace() breaks same-document back/forward navigations.

For navigations that don't create a new entry in the back/forward list (like
location.replace), we don't create a new HistoryItem, we just update the
existing one. If the url changes, we currently update some id numbers as
well:
the item sequence number (which uniquely identifies the item), and the
document sequence number (which is common among history items that can be
navigated between without creating a new document). For a location.replace()
within the same document, we still need to change the item sequence number
(so that a back navigation is guaranteed to do something), but the document
sequence number should *not* update, so that a same-document navigation is
still possible.

BUG=363724
TEST=fast/loader/back-after-same-document-location-replace.html

Review URL: https://codereview.chromium.org/267613003
-----------------------------------------------------------------

chro...@googlecode.com

unread,
May 1, 2014, 3:58:03 PM5/1/14
to chromi...@chromium.org
Updates:
Labels: Merge-Requested M-34

Comment #21 on issue 363724 by jap...@chromium.org: window.location.replace
with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

This fix is pretty low-risk. Any chance we want this merged to M34, after
it's had a couple of days to bake?

chro...@googlecode.com

unread,
May 2, 2014, 1:13:09 AM5/2/14
to chromi...@chromium.org

Comment #22 on issue 363724 by jumpinja...@gmail.com:
window.location.replace with hash causes navigation when going back
http://code.google.com/p/chromium/issues/detail?id=363724

+1 For merging to M34. The faster this bug is squashed the better.
Reply all
Reply to author
Forward
0 new messages