Closed Bug 465263 Opened 16 years ago Closed 16 years ago

[FIX]When location.hash equals empty, setting it as empty caused unexpected page reload

Categories

(Core :: DOM: Core & HTML, defect)

x86
Windows Vista
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla1.9.1b3

People

(Reporter: adonis.cuhk, Assigned: bzbarsky)

Details

(Keywords: fixed1.9.1)

Attachments

(2 files)

User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.0.4) Gecko/2008102920 Firefox/3.0.4

Tested also under:
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1b2pre) Gecko/20081116 Minefield/3.1b2pre

At page page.html, setting document.location.hash = '' caused page reload.
It should be considered as nothing changed before and after javascript execution since document.location.hash is always empty, but the page still reloads.


Reproducible: Always

Steps to Reproduce:
1. Go to https://bugzilla.mozilla.org/attachment.cgi?id=348507
2. Click on the only button
3. Notice that there comes the 2nd alert (attached to onload) after clicking the button
Actual Results:  
Page reloaded unexpectedly

Expected Results:  
Page doesn't reload, i.e. no second prompt in the testcase submitted

All of the major browsers including Internet Explorer 6 & 7, Safari 3.1.2, Opera 9.62 and Chrome 0.3.154.9 (latest stable versions at the moment) follow the above expected behavior.

changes to document.location.hash should not cause any page reload anyway, nothing to mention nothing changed.
Er, the |x = ...| should be |global.x = ...|.  Not that this affects the testcase.
Please ignore comment 1.  It was meant for a different bug.
Confirming.  I'll just do what Opera/IE do here.
Assignee: nobody → bzbarsky
Status: UNCONFIRMED → NEW
Component: General → DOM
Ever confirmed: true
Product: Firefox → Core
QA Contact: general → general
Summary: When location.hash equals empty, setting it as empty caused unexpected page reload (similar to 273158??) → [FIX]When location.hash equals empty, setting it as empty caused unexpected page reload
So the key is that IE/Opera treat hash='' the same as hash='#'.  We should just do the same, and this problem goes away.
Attached patch FixSplinter Review
The test just tests for the right final URL.  The reloading behavior will need to be tested in the tests for bug 273158 and bug 280215 once those exist.
Attachment #348651 - Flags: superreview?(jst)
Attachment #348651 - Flags: review?(jst)
FYI, just tested also in latest versions of Chrome and Safari which behave differently. Both browsers (may be just one) never append # after URL regardless of hash=='' or hash=='#'. This could affect whether reloading is needed under some situations. The problem is safari/chrome needs another round of "click here" to refresh when going from test.html#abc to test.html. It's better to fire this as a bug to safari/chrome instead.

For IE/Opera, yes they make hash='' equiv as hash='#'.
And I favor this way better than that of safari/chrome.

in fact, this bug crashed my app.
thanks a lot, bz. you responded really fast!!
Attachment #348651 - Flags: superreview?(jst)
Attachment #348651 - Flags: superreview+
Attachment #348651 - Flags: review?(jst)
Attachment #348651 - Flags: review+
Comment on attachment 348651 [details] [diff] [review]
Fix

Probably best to get beta baking on this....
Attachment #348651 - Flags: approval1.9.1b2?
Comment on attachment 348651 [details] [diff] [review]
Fix

Let's get this after beta 2 closes down ...
Attachment #348651 - Flags: approval1.9.1b2?
Attachment #348651 - Flags: approval1.9.1b2-
Attachment #348651 - Flags: approval1.9.1?
Attachment #348651 - Flags: approval1.9.1?
Attachment #348651 - Flags: approval1.9.1?
Comment on attachment 348651 [details] [diff] [review]
Fix

a191=beltzner
Attachment #348651 - Flags: approval1.9.1? → approval1.9.1+
Pushed http://hg.mozilla.org/mozilla-central/rev/9a8b28bbed23
Status: NEW → RESOLVED
Closed: 16 years ago
Flags: in-testsuite+
Resolution: --- → FIXED
Target Milestone: --- → mozilla1.9.1b3
Keywords: fixed1.9.1
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: