Bug 15647

Summary: HEAD elements are not automatically generated in empty documents.
Product: WebKit Reporter: Kevin Decker <kdecker>
Component: DOMAssignee: Nobody <webkit-unassigned>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, webkit
Priority: P2 Keywords: HasReduction
Version: 523.x (Safari 3)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
test 1
none
test 2
none
test 2 none

Description Kevin Decker 2007-10-23 17:05:50 PDT
HEAD elements are not automatically generated in empty documents.

* STEPS TO REPRODUCE

1. Create an about:blank document.

Notice there's an auto generated body element, but not head element.  Having a auto generated head element matches behavior of other browsers and is important for a high profile email site.
Comment 1 Alexey Proskuryakov 2007-10-26 11:10:43 PDT
Created attachment 16884 [details]
test 1
Comment 2 Alexey Proskuryakov 2007-10-26 11:11:01 PDT
Created attachment 16885 [details]
test 2
Comment 3 Alexey Proskuryakov 2007-10-26 11:13:15 PDT
Created attachment 16886 [details]
test 2

Updated to work in Safari, not just in Firefox...
Comment 4 Robert Blaut 2008-03-04 15:40:04 PST
The problem is clearly visible in Live DOM Viewer: http://software.hixie.ch/utilities/js/live-dom-viewer/?%3C!DOCTYPE%20html%3E 

Gecko and Presto generate the head element.  Webkit in this case violates the HTML5 spec: http://www.whatwg.org/specs/web-apps/current-work/#before5
Comment 5 Alexey Proskuryakov 2009-09-01 15:54:03 PDT
This was fixed in <http://trac.webkit.org/changeset/43215>.

Test2 still fails, and this is because we don't create HTML and HEAD nodes immediately from document.write() - we create them when closing a document if they still don't exist. This is a difference with Firefox, but IE behaves the same.