Closed Bug 675587 Opened 13 years ago Closed 13 years ago

document.location.hash="" executed as the first thing in the DOM doesn't work

Categories

(Core :: DOM: Navigation, defect, P2)

x86
macOS
defect

Tracking

()

RESOLVED FIXED
mozilla8

People

(Reporter: sebastian.razola, Assigned: bzbarsky)

Details

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.122 Safari/534.30

Steps to reproduce:

Visit the page below with #anything added to the URL

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8" />
  <title>Hash test</title>
  <script type="text/javascript">
    document.location.hash="";
  </script>
</head>
<body>
  <p>The hash won't be set to <b>#</b> in Firefox. (At least in Firefox 5.0.1)</p>
</body>
</html>


Actual results:

The stuff after the hash was not removed.


Expected results:

The URL should be stripped of everything after the hash. That's how it works in all other browsers I've tested and strangely also in Firefox, if I move the script tag to the bottom of the body.

Try visiting http://www.sebastianrazola.com/test.html#thisshouldberemoved
Doesn't behave as expected in Firefox Nightly either (8.0a1 (2011-07-31), OS X 10.6)
This is the change to the html referred to above that makes the document.location.hash work as in other browsers.
Component: General → DOM
Product: Firefox → Core
QA Contact: general → general
Component: DOM → Document Navigation
QA Contact: general → docshell
I have a fix for this; just testing it now.
Assignee: nobody → bzbarsky
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P2
Comment on attachment 549794 [details] [diff] [review]
Change the location on hash changes even if we cna't scroll right then.

r=me with typo in commit message fixed.
Attachment #549794 - Flags: review?(justin.lebar+bug) → review+
Yeah, I actually caught that right after posting the patch.
Whiteboard: [need landing]
Jens, thank you for reporting this bug!
The credit for finding and reporting it goes to Sebastian.

Thanks for the quick response and fix.
http://hg.mozilla.org/integration/mozilla-inbound/rev/158f91502fff
Flags: in-testsuite+
Whiteboard: [need landing]
Target Milestone: --- → mozilla8
http://hg.mozilla.org/mozilla-central/rev/158f91502fff
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.