<?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>5784</bug_id>
          
          <creation_ts>2005-11-20 09:16:49 -0800</creation_ts>
          <short_desc>Assertion failure in DocumentImpl::removeElementById() (idCount &gt; 0)</short_desc>
          <delta_ts>2005-12-26 14:08:35 -0800</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>DOM</component>
          <version>420+</version>
          <rep_platform>Mac</rep_platform>
          <op_sys>OS X 10.4</op_sys>
          <bug_status>VERIFIED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc>http://nontroppo.org/wiki/PatchingStartCom/edit</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="Alexey Proskuryakov">ap</reporter>
          <assigned_to name="Darin Adler">darin</assigned_to>
          <cc>mitz</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>24296</commentid>
    <comment_count>0</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2005-11-20 09:16:49 -0800</bug_when>
    <thetext>Running ToT from 12/11/2005

Steps to reproduce:
1. Open http://nontroppo.org/wiki/PatchingStartCom/edit (an &quot;Access not allowed&quot; page appears)
2. Close the window

Results: /Users/ap/WebKit/WebCore/khtml/xml/dom_docimpl.cpp:829: failed assertion `idCount &gt; 0&apos;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24317</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Proskuryakov">ap</who>
    <bug_when>2005-11-20 21:58:10 -0800</bug_when>
    <thetext>With current (November 21) ToT, the line numer is 842.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24352</commentid>
    <comment_count>2</comment_count>
      <attachid>4756</attachid>
    <who name="">mitz</who>
    <bug_when>2005-11-21 07:45:36 -0800</bug_when>
    <thetext>Created attachment 4756
Reduced testcase

The required ingredients for this bug are an &lt;html&gt; element with an id
attribute, and evaluating document.documentElement before closing the window.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24353</commentid>
    <comment_count>3</comment_count>
    <who name="">mitz</who>
    <bug_when>2005-11-21 08:38:23 -0800</bug_when>
    <thetext>An additional requirement for triggering the bug is to have something before the &lt;html&gt; tag (in the 
testcase, the &lt;!DOCTYPE&gt;). 

What happens is that if the first thing the parser sees is not &lt;html&gt;, it creates an implicit html element 
and inserts it into the document. When the real html element is encountered, it is not inserted into the 
document, so for example, document.getElementById(&quot;foo&quot;) returns null in the testcase, since the implicit 
html element doesn&apos;t have an id attribute. document.documentElement returns the &quot;explicit&quot; element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24354</commentid>
    <comment_count>4</comment_count>
      <attachid>4757</attachid>
    <who name="">mitz</who>
    <bug_when>2005-11-21 10:13:19 -0800</bug_when>
    <thetext>Created attachment 4757
Call updateId() when inserting id attribute

I was (partly) wrong. The attributes, including &quot;id&quot; are copied from the
explicit element to the implicit one, but insertAttribute() doesn&apos;t call
updateId() when necessary. This fixes the testcase and makes
document.getElementById(&apos;foo&apos;) return the html element.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>24421</commentid>
    <comment_count>5</comment_count>
      <attachid>4757</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-11-22 19:39:20 -0800</bug_when>
    <thetext>Comment on attachment 4757
Call updateId() when inserting id attribute

The change here is just right to fix the bug, but I&apos;m slightly concerned about
the effect this might have on performance. I&apos;m also annoyed about that
dom_elementimpl.h now includes the htmlnames.h header.

Perhaps a better change would be to use a different function in htmlparser.cpp
and leave this one as a simpler and faster function only to be used by
htmltokenizer.cpp. We could add an assertion that element is 0.

There&apos;s a chance that we could just use setAttribute in the two code paths
inside htmlparser.cpp, and in fact I think that skipping incDOMTreeVersion and
attributeChanged might be bad for those cases.

Lets look into a patch that involves making insertAttribute assert more and get
called less.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25523</commentid>
    <comment_count>6</comment_count>
      <attachid>4947</attachid>
    <who name="">mitz</who>
    <bug_when>2005-12-04 13:39:05 -0800</bug_when>
    <thetext>Created attachment 4947
Use setAttribute from htmlparser; add assert in insertAttribute</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25557</commentid>
    <comment_count>7</comment_count>
      <attachid>4947</attachid>
    <who name="Eric Seidel (no email)">eric</who>
    <bug_when>2005-12-05 02:29:59 -0800</bug_when>
    <thetext>Comment on attachment 4947
Use setAttribute from htmlparser; add assert in insertAttribute

The change looks good to me.  But I&apos;ll let darin, hyatt or maciej (those more
familiar with this code path) have the final say.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>25570</commentid>
    <comment_count>8</comment_count>
      <attachid>4947</attachid>
    <who name="Darin Adler">darin</who>
    <bug_when>2005-12-05 06:30:39 -0800</bug_when>
    <thetext>Comment on attachment 4947
Use setAttribute from htmlparser; add assert in insertAttribute

r=me</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="0"
              isprivate="0"
          >
            <attachid>4756</attachid>
            <date>2005-11-21 07:45:36 -0800</date>
            <delta_ts>2005-11-21 07:45:36 -0800</delta_ts>
            <desc>Reduced testcase</desc>
            <filename>htmlElementWithId.html</filename>
            <type>text/html</type>
            <size>324</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">PCFET0NUWVBFIGh0bWwgUFVCTElDICItLy9XM0MvL0RURCBYSFRNTCAxLjAgU3RyaWN0Ly9FTiIg
Imh0dHA6Ly93d3cudzMub3JnL1RSL3hodG1sMS9EVEQveGh0bWwxLXN0cmljdC5kdGQiPgo8aHRt
bCB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94aHRtbCIgeG1sOmxhbmc9ImVuIiBpZD0i
Zm9vIj4KPGhlYWQ+Cjx0aXRsZT5kb21fZG9jaW1wbC5jcHA6ODQyIGFzc2VydDwvdGl0bGU+Cjxz
Y3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0Ij4KZG9jdW1lbnQuZG9jdW1lbnRFbGVtZW50Owo8
L3NjcmlwdD4KPC9oZWFkPgo8Ym9keT4KPC9ib2R5Pgo8L2h0bWw+
</data>

          </attachment>
          <attachment
              isobsolete="1"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4757</attachid>
            <date>2005-11-21 10:13:19 -0800</date>
            <delta_ts>2005-12-04 13:39:05 -0800</delta_ts>
            <desc>Call updateId() when inserting id attribute</desc>
            <filename>5784_r1.patch</filename>
            <type>text/plain</type>
            <size>1101</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUva2h0bWwveG1sL2RvbV9lbGVtZW50aW1wbC5oCj09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNT
IGZpbGU6IC9jdnMvcm9vdC9XZWJDb3JlL2todG1sL3htbC9kb21fZWxlbWVudGltcGwuaCx2CnJl
dHJpZXZpbmcgcmV2aXNpb24gMS42MwpkaWZmIC1wIC11IC1yMS42MyBXZWJDb3JlL2todG1sL3ht
bC9kb21fZWxlbWVudGltcGwuaAotLS0gV2ViQ29yZS9raHRtbC94bWwvZG9tX2VsZW1lbnRpbXBs
LmgJMjEgTm92IDIwMDUgMDQ6MDE6NTggLTAwMDAJMS42MworKysgV2ViQ29yZS9raHRtbC94bWwv
ZG9tX2VsZW1lbnRpbXBsLmgJMjEgTm92IDIwMDUgMTg6MTU6MTggLTAwMDAKQEAgLTMxLDYgKzMx
LDcgQEAKICNpbmNsdWRlICJtaXNjL3NoYXJlZC5oIgogI2luY2x1ZGUgImNzcy9jc3NfdmFsdWVp
bXBsLmgiCiAjaW5jbHVkZSAiZG9tX3FuYW1lLmgiCisjaW5jbHVkZSAiaHRtbG5hbWVzLmgiCiAK
ICNpZmRlZiBfX09CSkNfXwogI2RlZmluZSBpZCBpZF9BVk9JRF9LRVlXT1JECkBAIC0zMTYsOSAr
MzE3LDExIEBAIHB1YmxpYzoKICAgICAvLyB1c2VkIGR1cmluZyBwYXJzaW5nOiBvbmx5IGluc2Vy
dHMgaWYgbm90IGFscmVhZHkgdGhlcmUKICAgICAvLyBubyBlcnJvciBjaGVja2luZyEKICAgICB2
b2lkIGluc2VydEF0dHJpYnV0ZShBdHRyaWJ1dGVJbXBsKiBuZXdBdHRyaWJ1dGUpIHsKLSAgICAg
ICAgaWYgKCFnZXRBdHRyaWJ1dGVJdGVtKG5ld0F0dHJpYnV0ZS0+bmFtZSgpKSkKKyAgICAgICAg
aWYgKCFnZXRBdHRyaWJ1dGVJdGVtKG5ld0F0dHJpYnV0ZS0+bmFtZSgpKSkgeworICAgICAgICAg
ICAgaWYgKGVsZW1lbnQgJiYgbmV3QXR0cmlidXRlLT5uYW1lKCkgPT0gSFRNTE5hbWVzOjppZEF0
dHIpCisgICAgICAgICAgICAgICAgZWxlbWVudC0+dXBkYXRlSWQobnVsbEF0b20sIG5ld0F0dHJp
YnV0ZS0+dmFsdWUoKSk7CiAgICAgICAgICAgICBhZGRBdHRyaWJ1dGUobmV3QXR0cmlidXRlKTsK
LSAgICAgICAgZWxzZQorICAgICAgICB9IGVsc2UKICAgICAgICAgICAgIG5ld0F0dHJpYnV0ZS0+
ZGVyZWYoKTsKICAgICB9CiAK
</data>
<flag name="review"
          id="876"
          type_id="1"
          status="-"
          setter="darin"
    />
          </attachment>
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>4947</attachid>
            <date>2005-12-04 13:39:05 -0800</date>
            <delta_ts>2005-12-05 06:30:39 -0800</delta_ts>
            <desc>Use setAttribute from htmlparser; add assert in insertAttribute</desc>
            <filename>5784_r2.patch</filename>
            <type>text/plain</type>
            <size>3528</size>
            <attacher>mitz</attacher>
            
              <data encoding="base64">SW5kZXg6IFdlYkNvcmUva2h0bWwvaHRtbC9odG1scGFyc2VyLmNwcAo9PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09ClJDUyBm
aWxlOiAvY3ZzL3Jvb3QvV2ViQ29yZS9raHRtbC9odG1sL2h0bWxwYXJzZXIuY3BwLHYKcmV0cmll
dmluZyByZXZpc2lvbiAxLjEyMwpkaWZmIC1wIC11IC1yMS4xMjMgV2ViQ29yZS9raHRtbC9odG1s
L2h0bWxwYXJzZXIuY3BwCi0tLSBXZWJDb3JlL2todG1sL2h0bWwvaHRtbHBhcnNlci5jcHAJMSBE
ZWMgMjAwNSAxMDozMjoxOSAtMDAwMAkxLjEyMworKysgV2ViQ29yZS9raHRtbC9odG1sL2h0bWxw
YXJzZXIuY3BwCTQgRGVjIDIwMDUgMjE6MTY6NTYgLTAwMDAKQEAgLTMzOSwxNSArMzM5LDEzIEBA
IGJvb2wgSFRNTFBhcnNlcjo6aGFuZGxlRXJyb3IoTm9kZUltcGwqIG4KICAgICAgICAgICAgICAg
ICAgICAgLy8gd2UgaGF2ZSBhbm90aGVyIDxIVE1MPiBlbGVtZW50Li4uLiBhcHBseSBhdHRyaWJ1
dGVzIHRvIGV4aXN0aW5nIG9uZQogICAgICAgICAgICAgICAgICAgICAvLyBtYWtlIHN1cmUgd2Ug
ZG9uJ3Qgb3ZlcndyaXRlIGFscmVhZHkgZXhpc3RpbmcgYXR0cmlidXRlcwogICAgICAgICAgICAg
ICAgICAgICBOYW1lZEF0dHJNYXBJbXBsICptYXAgPSBzdGF0aWNfY2FzdDxFbGVtZW50SW1wbCo+
KG4pLT5hdHRyaWJ1dGVzKHRydWUpOwotICAgICAgICAgICAgICAgICAgICBOY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2VkID0gIWJtYXAt
PmdldEF0dHJpYnV0ZUl0ZW0oaXQtPm5hbWUoKSk7Ci0gICAgICAgICAgICAgICAgICAgIGJtYXAt
Pmluc2VydEF0dHJpYnV0ZShpdC0+Y2xvbmUoZmFsc2UpKTsKKyAgICAgICAgICAgICAgICAgICAg
aWYgKCFibWFwLT5nZXRBdHRyaWJ1dGVJdGVtKGl0LT5uYW1lKCkpKQorICAgICAgICAgICAgICAg
ICAgICAgICAgZXhpc3RpbmdCb2R5LT5zZXRBdHRyaWJ1dGUoaXQtPm5hbWUoKSwgaXQtPnZhbHVl
KCkpOwogICAgICAgICAgICAgICAgIH0KLSAgICAgICAgICAgICAgICBpZiAoY2hhbmdlZCkKLSAg
ICAgICAgICAgICAgICAgICAgZG9jKCktPnJlY2FsY1N0eWxlKE5vZGVJbXBsOjpJbmhlcml0KTsK
ICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7CiAgICAgICAgICAgICB9CiAgICAgICAgICAg
ICBlbHNlIGlmICghY3VycmVudC0+aXNEb2N1bWVudE5vZGUoKSkKSW5kZXg6IFdlYkNvcmUva2h0
bWwveG1sL2RvbV9lbGVtZW50aW1wbC5oCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KUkNTIGZpbGU6IC9jdnMvcm9vdC9X
ZWJDb3JlL2todG1sL3htbC9kb21fZWxlbWVudGltcGwuaCx2CnJldHJpZXZpbmcgcmV2aXNpb24g
MS42NApkaWZmIC1wIC11IC1yMS42NCBXZWJDb3JlL2todG1sL3htbC9kb21fZWxlbWVudGltcGwu
aAotLS0gV2ViQ29yZS9raHRtbC94bWwvZG9tX2VsZW1lbnRpbXBsLmgJMSBEZWMgMjAwNSAxMDoz
MjoyNyAtMDAwMAkxLjY0CisrKyBXZWJDb3JlL2todG1sL3htbC9kb21fZWxlbWVudGltcGwuaAk0
IERlYyAyMDA1IDIxOjE3OjAxIC0wMDAwCkBAIC0zMTYsNiArMzE2LDcgQEAgcHVibGljOgogICAg
IC8vIHVzZWQgZHVyaW5nIHBhcnNpbmc6IG9ubHkgaW5zZXJ0cyBpZiBub3QgYWxyZWFkeSB0aGVy
ZQogICAgIC8vIG5vIGVycm9yIGNoZWNraW5nIQogICAgIHZvaWQgaW5zZXJ0QXR0cmlidXRlKEF0
dHJpYnV0ZUltcGwqIG5ld0F0dHJpYnV0ZSkgeworICAgICAgICBhc3NlcnQoIWVsZW1lbnQpOwog
ICAgICAgICBpZiAoIWdldEF0dHJpYnV0ZUl0ZW0obmV3QXR0cmlidXRlLT5uYW1lKCkpKQogICAg
ICAgICAgICAgYWRkQXR0cmlidXRlKG5ld0F0dHJpYnV0ZSk7CiAgICAgICAgIGVsc2UK
</data>
<flag name="review"
          id="956"
          type_id="1"
          status="+"
          setter="darin"
    />
          </attachment>
      

    </bug>

</bugzilla>