Bug 17080 - WebKit fails Acid3 HTML parsing test (missing DocType node)
Summary: WebKit fails Acid3 HTML parsing test (missing DocType node)
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Macintosh OS X 10.5
: P2 Normal
Assignee: Nobody
URL: http://acid3.acidtests.org/
Keywords: HasReduction
Depends on: 12751
Blocks: Acid3
  Show dependency treegraph
 
Reported: 2008-01-29 15:04 PST by Eric Seidel (no email)
Modified: 2008-02-20 14:51 PST (History)
2 users (show)

See Also:


Attachments
test case (310 bytes, text/html)
2008-01-30 22:39 PST, Robert Blaut
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Eric Seidel (no email) 2008-01-29 15:04:50 PST
WebKit fails Acid3 HTML parsing test

I believe the document in question is:

http://hixie.ch/tests/evil/acid/003/empty.html

The contents of which are:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"><html><head><title></title></head><body></body></html>

In the live dom viewer:
http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20HTML%20PUBLIC%20%22-%2F%2FW3C%2F%2FDTD%20HTML%204.0%2F%2FEN%22%3E%3Chtml%3E%3Chead%3E%3Ctitle%3E%3C%2Ftitle%3E%3C%2Fhead%3E%3Cbody%3E%3C%2Fbody%3E%3C%2Fhtml%3E

    function () {
      // test 72: HTML parsing, from Simon Pieters and Anne van Kesteren
      var doc = kungFuDeathGrip.childNodes[3].contentDocument;
      assert(doc, "missing document for test");
      try {
        // siblings
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><title></title><span></span><script type=\"text/javascript\"><\/script>");
        doc.close();
        assertEquals(doc.documentElement.childNodes.length, 2, "wrong number of children in HTML (first test)");
        assertEquals(doc.documentElement.firstChild.nodeName, "HEAD", "misplaced HEAD element (first test)");
        assertEquals(doc.documentElement.firstChild.childNodes.length, 1, "wrong number of children in HEAD (first test)");
        assertEquals(doc.documentElement.firstChild.firstChild.tagName, "TITLE (first test)");
        assertEquals(doc.documentElement.lastChild.nodeName, "BODY", "misplaced BODY element (first test)");
        assertEquals(doc.documentElement.lastChild.childNodes.length, 2, "wrong number of children in BODY (first test)");
        assertEquals(doc.documentElement.lastChild.firstChild.tagName, "SPAN", "misplaced SPAN element (first test)");
        assertEquals(doc.documentElement.lastChild.lastChild.tagName, "SCRIPT", "misplaced SCRIPT element (first test)");
        // parent/child
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><title></title><span><script type=\"text/javascript\"><\/script></span>");
        doc.close();
        assertEquals(doc.documentElement.childNodes.length, 2, "wrong number of children in HTML (second test)");
        assertEquals(doc.documentElement.firstChild.nodeName, "HEAD", "misplaced HEAD element (second test)");
        assertEquals(doc.documentElement.firstChild.childNodes.length, 1, "wrong number of children in HEAD (second test)");
        assertEquals(doc.documentElement.firstChild.firstChild.tagName, "TITLE (second test)");
        assertEquals(doc.documentElement.lastChild.nodeName, "BODY", "misplaced BODY element (second test)");
        assertEquals(doc.documentElement.lastChild.childNodes.length, 1, "wrong number of children in BODY (second test)");
        assertEquals(doc.documentElement.lastChild.firstChild.tagName, "SPAN", "misplaced SPAN element (second test)");
        assertEquals(doc.documentElement.lastChild.firstChild.firstChild.tagName, "SCRIPT", "misplaced SCRIPT element (second test)");
      } finally {
        // prepare the file for the next test
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"><head><title></title><style type=\"text/css\">img { height: 10px; }</style><body><p><img src=\"data:image/gif;base64,R0lGODlhAQABAID%2FAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D\" alt=\"\">");
        doc.close();
      }
      return 5;
    },
Comment 1 Robert Blaut 2008-01-30 00:39:38 PST
For me there is a bug in this test. Function assertEquals expected 3 arguments but actually got 2 of them:

assertEquals(doc.documentElement.firstChild.firstChild.tagName, "TITLE (first test)");
Comment 2 Eric Seidel (no email) 2008-01-30 01:22:54 PST
the 3rd argument to assertEquals is optional.
Comment 3 Robert Blaut 2008-01-30 01:45:10 PST
(In reply to comment #2)
> the 3rd argument to assertEquals is optional.
> 

I know that this argument are optional, but for me this test in this state is incorrect. Look at &#8211; current value: tagName "TITLE" is compared to expected result: "TITLE (second test)". No browser passes this test ;)
Comment 4 Eric Seidel (no email) 2008-01-30 02:18:36 PST
Ok, I agree, it makes no sense for the tagName to ever be "TITLE (first test)"  passing this on to Hixie to fix the test.
Comment 5 Ian 'Hixie' Hickson 2008-01-30 11:43:03 PST
fixed the test
Comment 6 Eric Seidel (no email) 2008-01-30 13:46:48 PST
Now we fail at:
Test 72: expected: 2, got: 1 - wrong number of children in #document (first test)
Comment 7 Eric Seidel (no email) 2008-01-30 13:48:42 PST
The test has been updated slightly:

    function () {
      // test 72: HTML parsing, from Simon Pieters and Anne van Kesteren
      var doc = kungFuDeathGrip.childNodes[3].contentDocument;
      assert(doc, "missing document for test");
      try {
        // siblings
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\"><title><\/title><span><\/span><script type=\"text/javascript\"><\/script>");
        doc.close();
        assertEquals(doc.childNodes.length, 2, "wrong number of children in #document (first test)");
        assertEquals(doc.firstChild.name, "HTML", "name wrong (first test)");
        assertEquals(doc.firstChild.publicId, "-//W3C//DTD HTML 4.0 Transitional//EN", "publicId wrong (first test)");
        if ((doc.firstChild.systemId != null) && (doc.firstChild.systemId != ""))
          fail("systemId wrong (first test)");
        assertEquals(doc.firstChild.internalSubset, null, "internalSubset wrong (first test)");
        assertEquals(doc.documentElement.childNodes.length, 2, "wrong number of children in HTML (first test)");
        assertEquals(doc.documentElement.firstChild.nodeName, "HEAD", "misplaced HEAD element (first test)");
        assertEquals(doc.documentElement.firstChild.childNodes.length, 1, "wrong number of children in HEAD (first test)");
        assertEquals(doc.documentElement.firstChild.firstChild.tagName, "TITLE", "misplaced TITLE element (first test)");
        assertEquals(doc.documentElement.lastChild.nodeName, "BODY", "misplaced BODY element (first test)");
        assertEquals(doc.documentElement.lastChild.childNodes.length, 2, "wrong number of children in BODY (first test)");
        assertEquals(doc.documentElement.lastChild.firstChild.tagName, "SPAN", "misplaced SPAN element (first test)");
        assertEquals(doc.documentElement.lastChild.lastChild.tagName, "SCRIPT", "misplaced SCRIPT element (first test)");
        // parent/child
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\"><title><\/title><span><script type=\"text/javascript\"><\/script><\/span>");
        doc.close();
        assertEquals(doc.childNodes.length, 2, "wrong number of children in #document (first test)");
        assertEquals(doc.firstChild.name, "HTML", "name wrong (second test)");
        assertEquals(doc.firstChild.publicId, "-//W3C//DTD HTML 4.01 Transitional//EN", "publicId wrong (second test)");
        assertEquals(doc.firstChild.systemId, "http://www.w3.org/TR/html4/loose.dtd", "systemId wrong (second test)");
        assertEquals(doc.firstChild.internalSubset, null, "internalSubset wrong (second test)");
        assertEquals(doc.documentElement.childNodes.length, 2, "wrong number of children in HTML (second test)");
        assertEquals(doc.documentElement.firstChild.nodeName, "HEAD", "misplaced HEAD element (second test)");
        assertEquals(doc.documentElement.firstChild.childNodes.length, 1, "wrong number of children in HEAD (second test)");
        assertEquals(doc.documentElement.firstChild.firstChild.tagName, "TITLE", "misplaced TITLE element (second test)");
        assertEquals(doc.documentElement.lastChild.nodeName, "BODY", "misplaced BODY element (second test)");
        assertEquals(doc.documentElement.lastChild.childNodes.length, 1, "wrong number of children in BODY (second test)");
        assertEquals(doc.documentElement.lastChild.firstChild.tagName, "SPAN", "misplaced SPAN element (second test)");
        assertEquals(doc.documentElement.lastChild.firstChild.firstChild.tagName, "SCRIPT", "misplaced SCRIPT element (second test)");
      } finally {
        // prepare the file for the next test
        doc.open();
        doc.write("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"><head><title><\/title><style type=\"text/css\">img { height: 10px; }<\/style><body><p><img src=\"data:image/gif;base64,R0lGODlhAQABAID%2FAMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw%3D%3D\" alt=\"\">");
        doc.close();
      }
      return 5;
    },
Comment 8 Eric Seidel (no email) 2008-01-30 13:52:50 PST
It looks like this test depends on bug 12751.
Comment 9 Ian 'Hixie' Hickson 2008-01-30 16:27:18 PST
Yeah, sorry. ;-)
Comment 10 Robert Blaut 2008-01-30 22:39:40 PST
Created attachment 18810 [details]
test case
Comment 11 Dave Hyatt 2008-02-20 14:51:47 PST
Fixed.