<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>14867</bug_id>
          
          <creation_ts>2007-08-02 19:00:47 -0700</creation_ts>
          <short_desc>Fails to scroll to top of page when loading URL w/ empty reference fragment</short_desc>
          <delta_ts>2008-03-11 23:19:35 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Page Loading</component>
          <version>523.x (Safari 3)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://wiki.gamer.com.tw/wiki.php?n=PSU%3A%E5%A4%A2%E5%B9%BB%E4%B9%8B%E6%98%9F</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Darin Fisher (:fishd, Google)">fishd</reporter>
          <assigned_to name="Yuzhu Shen">yuzhu.shen</assigned_to>
          <cc>dstorey</cc>
    
    <cc>webkit</cc>
    
    <cc>yuzhu.shen</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>3108</commentid>
    <comment_count>0</comment_count>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2007-08-02 19:00:47 -0700</bug_when>
    <thetext>Fails to scroll to top of page when loading URL w/ empty reference fragment

Observed in the latest Safari3 as well as WebKit r24803.  IE and FF do not have this bug.

If you have a page w/ an anchor like &lt;a href=&quot;#&quot;&gt;, other browsers scroll to the top of the page, but WebKit does not.

This causes problems on pages like this:
http://wiki.gamer.com.tw/wiki.php?n=PSU%3A%E5%A4%A2%E5%B9%BB%E4%B9%8B%E6%98%9F

If you scroll down to the bottom of the page, there is an arrow button that is intended to take you back to the top of the page.  It is implemented using &lt;a href=&quot;#&quot;&gt;.

Simple test case coming up...</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3109</commentid>
    <comment_count>1</comment_count>
      <attachid>15813</attachid>
    <who name="Darin Fisher (:fishd, Google)">fishd</who>
    <bug_when>2007-08-02 19:01:25 -0700</bug_when>
    <thetext>Created attachment 15813
reduced test case</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>3059</commentid>
    <comment_count>2</comment_count>
    <who name="David Kilzer (:ddkilzer)">ddkilzer</who>
    <bug_when>2007-08-03 05:57:36 -0700</bug_when>
    <thetext>Expected behavior works in Firefox 2.0.0.6.  Does not work in Opera 9.21.

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73286</commentid>
    <comment_count>3</comment_count>
    <who name="Yuzhu Shen">yuzhu.shen</who>
    <bug_when>2008-03-10 22:05:48 -0700</bug_when>
    <thetext>With &lt;a href=&quot;#&quot;&gt;, WebKit interprets the fragment identifier as a null string.

And then WebKit searches the anchor node in two steps: (in bool FrameLoader::gotoAnchor(const String&amp; name))
1) searches any node whose id attribute is the same as the fragment identifier.
   If the fragment identifier is a null string, it returns directly.

2) searches in a set of &lt;a&gt; elements that have name attributes, using HTMLCollection::namedItem().
   It should be noted that namedItem() first searches for an object with a matching id attribute. If a match is not 
found, the method then searches for an object with a matching name attribute.

   Consider the following node:
   &lt;a name=&quot;anyname&quot;&gt;...&lt;/a&gt;
   Its id attribute is not specified (returned as a null string when querying it). If we are searching with a null 
fragment identifier, it will match this node, no matter what its name attribute is.

As a result, clicking the &quot;Goto Top&quot; link in the page below will bring you to the &quot;youwillgethere&quot; anchor but not the 
top of the page.

=======================================
...
&lt;a href=&quot;#&quot;&gt;Goto Top&lt;/a&gt;
...
...
&lt;a name=&quot;youwillgethere&quot;&gt;Oops!&lt;/a&gt;
...
=======================================

I will upload a patch soon.
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73289</commentid>
    <comment_count>4</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2008-03-10 23:36:11 -0700</bug_when>
    <thetext>As I tested today Webkit r30939 scrolls to the top. So the reported issue is absent in this build. But there is similar issue reported in bug 17714.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73291</commentid>
    <comment_count>5</comment_count>
    <who name="Yuzhu Shen">yuzhu.shen</who>
    <bug_when>2008-03-10 23:46:37 -0700</bug_when>
    <thetext>Yes, I tested with the newest version of the code and the problem disappears.

BTW, in case like this, shall I still submit a patch with only the test case and expeced result?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73304</commentid>
    <comment_count>6</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2008-03-11 06:26:42 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; Yes, I tested with the newest version of the code and the problem disappears.
&gt; 
&gt; BTW, in case like this, shall I still submit a patch with only the test case
&gt; and expeced result?
&gt; 

I think new layout tests are always welcome :)
</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73428</commentid>
    <comment_count>7</comment_count>
    <who name="Yuzhu Shen">yuzhu.shen</who>
    <bug_when>2008-03-11 19:50:33 -0700</bug_when>
    <thetext>I have uploaded a patch for bug 17714 and it has been reviewed. This two bugs are related, please refer to my comments in bug 17714 for details. And the test case for bug 17714 covers the situation described in this bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>73433</commentid>
    <comment_count>8</comment_count>
    <who name="Robert Blaut">webkit</who>
    <bug_when>2008-03-11 23:19:35 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; I have uploaded a patch for bug 17714 and it has been reviewed. This two bugs
&gt; are related, please refer to my comments in bug 17714 for details. And the test
&gt; case for bug 17714 covers the situation described in this bug.
&gt; 

So I mark the bug as FIXED since original reported bug is not visible any more and the test case for it is available in related bug 17714. 
</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>15813</attachid>
            <date>2007-08-02 19:01:25 -0700</date>
            <delta_ts>2007-08-02 19:01:25 -0700</delta_ts>
            <desc>reduced test case</desc>
            <filename>reduced.html</filename>
            <type>text/html</type>
            <size>235</size>
            <attacher name="Darin Fisher (:fishd, Google)">fishd</attacher>
            
              <data encoding="base64">PGh0bWw+CjxoZWFkPgo8c3R5bGU+CmRpdiB7IGhlaWdodDogNTAwcHg7IH0KPC9zdHlsZT4KPC9o
ZWFkPgo8Ym9keT4KClNjcm9sbCBkb3duIHRvIHRoZSBib3R0b20gb2YgdGhlIHBhZ2UKPGRpdj48
L2Rpdj4KPGEgbmFtZT0iQSI+QTwvYT4KPGRpdj48L2Rpdj4KPGEgaHJlZj0iIyI+Q2xpY2sgaGVy
ZSB0byBnbyB0byB0aGUgVE9QIG9mIHRoZSBwYWdlPC9hPgo8ZGl2PjwvZGl2PgoKPC9ib2R5Pgo8
L2h0bWw+Cg==
</data>

          </attachment>
      

    </bug>

</bugzilla>