Document.title does not behave according to specification: https://html.spec.whatwg.org/multipage/dom.html#document.title In particular, 1. Adding a title element to the Document does not always update the value returned by document.title even if the element if the first title element in the document. 2. The *first* title element in tree order is supposed to update the document title. However, in WebKit, it is the first title *added* to the document, even if it is not the first in tree order.
Created attachment 261070 [details] Patch
Comment on attachment 261070 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=261070&action=review > Source/WebCore/dom/Document.cpp:1579 > + if (isHTMLDocument() || isXHTMLDocument()) { > + m_titleElement = descendantsOfType<HTMLTitleElement>(*this).first(); > + } else if (isSVGDocument()) { Nit: we shouldn't have curly brackets around a single line statement.
Committed r189680: <http://trac.webkit.org/changeset/189680>