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.
Created attachment 16884 [details] test 1
Created attachment 16885 [details] test 2
Created attachment 16886 [details] test 2 Updated to work in Safari, not just in Firefox...
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
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.