Bug 149098 - Document.title does not behave according to specification
Summary: Document.title does not behave according to specification
Alias: None
Product: WebKit
Classification: Unclassified
Component: DOM (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Chris Dumez
URL: https://html.spec.whatwg.org/multipag...
Keywords: WebExposed
Depends on:
Reported: 2015-09-12 15:31 PDT by Chris Dumez
Modified: 2015-09-13 22:03 PDT (History)
2 users (show)

See Also:

Patch (17.28 KB, patch)
2015-09-12 18:16 PDT, Chris Dumez
rniwa: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Dumez 2015-09-12 15:31:05 PDT
Document.title does not behave according to specification:

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.
Comment 1 Chris Dumez 2015-09-12 18:16:12 PDT
Created attachment 261070 [details]
Comment 2 Ryosuke Niwa 2015-09-13 21:26:22 PDT
Comment on attachment 261070 [details]

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.
Comment 3 Chris Dumez 2015-09-13 22:03:41 PDT
Committed r189680: <http://trac.webkit.org/changeset/189680>