Last Comment Bug 675587 - document.location.hash="" executed as the first thing in the DOM doesn't work
: document.location.hash="" executed as the first thing in the DOM doesn't work
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: Document Navigation (show other bugs)
: unspecified
: x86 Mac OS X
: P2 normal (vote)
: mozilla8
Assigned To: Boris Zbarsky [:bz]
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-08-01 02:20 PDT by Sebastian
Modified: 2011-08-02 12:56 PDT (History)
6 users (show)
bzbarsky: in‑testsuite+
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
This is a working version (284 bytes, text/plain)
2011-08-01 04:17 PDT, Jens Nockert
no flags Details
Change the location on hash changes even if we cna't scroll right then. (3.27 KB, patch)
2011-08-01 07:44 PDT, Boris Zbarsky [:bz]
justin.lebar+bug: review+
Details | Diff | Splinter Review

Description Sebastian 2011-08-01 02:20:26 PDT
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
Comment 1 Jens Nockert 2011-08-01 02:51:21 PDT
Doesn't behave as expected in Firefox Nightly either (8.0a1 (2011-07-31), OS X 10.6)
Comment 2 Jens Nockert 2011-08-01 04:17:45 PDT
Created attachment 549757 [details]
This is a working version

This is the change to the html referred to above that makes the document.location.hash work as in other browsers.
Comment 3 Boris Zbarsky [:bz] 2011-08-01 07:18:43 PDT
I have a fix for this; just testing it now.
Comment 4 Boris Zbarsky [:bz] 2011-08-01 07:44:31 PDT
Created attachment 549794 [details] [diff] [review]
Change the location on hash changes even if we cna't scroll right then.
Comment 5 Justin Lebar (not reading bugmail) 2011-08-01 07:54:01 PDT
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.
Comment 6 Boris Zbarsky [:bz] 2011-08-01 08:04:31 PDT
Yeah, I actually caught that right after posting the patch.
Comment 7 Justin Lebar (not reading bugmail) 2011-08-01 08:40:26 PDT
Jens, thank you for reporting this bug!
Comment 8 Jens Nockert 2011-08-01 08:46:34 PDT
The credit for finding and reporting it goes to Sebastian.

Thanks for the quick response and fix.
Comment 10 Marco Bonardo [::mak] 2011-08-02 03:19:59 PDT
http://hg.mozilla.org/mozilla-central/rev/158f91502fff

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