Other browsers let you modify the innerHTML of a head element, but WebKit does not. Modifying the innerHTML of head elements is important for a high profile email site.
It's far worse than that. It is not possible to even add elements into the HEAD tag programmatically unless there is already at least one element inside that tag, AFAICT.
Steps to reproduce:
* Create an iframe element in the HTML.
* Populate the iframe by setting iframeelt.contentDocument.body.innerHTML = "...."
* Set var elt = iframeelt.contentDocument.getElementsByTagName('head');
* Note that the head element was correctly created implicitly.
* Try to add stuff to elt.
* Observe the DOM error 7 (NO_MODIFICATION_ALLOWED_ERR).
Also tried various other ways of loading the content, including putting a HEAD tag in the BODY, putting the LINK tags in the body where they should have been automatically moved into the HEAD, etc. Nothing worked.
This behavior makes it much, much more difficult to write any code that uses iframes and apply CSS styles to the content. Combine that with 31951 and it forced some really ugly workarounds. I eventually gave up and used the src attribute to load a real HTML file that contained a HEAD element with the tags I needed inside it, then blowing out the BODY.
> It's far worse than that. It is not possible to even add elements into the
> HEAD tag programmatically unless there is already at least one element inside
> that tag, AFAICT.
I made a test case from this description, but it works fine. I was able to successfully insert a LINK element inside an empty auto-created HEAD.
In any case, let's not discuss this here. Difficulties with manipulating HEAD content via DOM Core APIs would likely have a different cause than innerHTML, and this bug is about the latter. Please file a new bug if you have a test case that works in Firefox, but not in Safari.