Improve Node pre-insertion validation when the parent is a Document to match the specification: https://dom.spec.whatwg.org/#concept-node-ensure-pre-insertion-validity https://dom.spec.whatwg.org/#concept-node-replace This affects the following API: Node.insertBefore(), Node.appendChild(), Node.replaceChild(). WebKit current fails to do the following checks whenever the parent is a Document from pre-insertion validation: 1. If the inserted Node is a DocumentFragment, we should make sure it contains only one Element. -> This is because a Document can have only one child that is an Element. 2.a. If an Element is inserted, we should make sure it is not inserted before a DocumentType. 2.b. If a DocumentType is inserted, we should make sure it is not inserted after an Element. -> This is because the DocType must come before the optional Element child as per https://dom.spec.whatwg.org/#node-trees Firefox and Chrome already match the specification here.
rdar://problem/22560436
Created attachment 261093 [details] Patch
Comment on attachment 261093 [details] Patch Attachment 261093 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://webkit-queues.webkit.org/results/169071 New failing tests: userscripts/mixed-case-stylesheet.html
Created attachment 261096 [details] Archive of layout-test-results from ews104 for mac-mavericks-wk2 The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews. Bot: ews104 Port: mac-mavericks-wk2 Platform: Mac OS X 10.9.5
Created attachment 261097 [details] Patch
Comment on attachment 261097 [details] Patch r=me assuming all tests pass and there is no performance regression from this change (check Dromaeo & Speedometer).
(In reply to comment #6) > Comment on attachment 261097 [details] > Patch > > r=me assuming all tests pass and there is no performance regression from > this change > (check Dromaeo & Speedometer). Ok, I'll check the benchmarks before landing. I wasn't too worried because this change only affects inserting a direct child to the Document. You cannot insert a lot of those, especially Doctype / Element (just one of each).
Comment on attachment 261097 [details] Patch Clearing flags on attachment: 261097 Committed r189682: <http://trac.webkit.org/changeset/189682>
All reviewed patches have been landed. Closing bug.