Bug 191643

Summary: Setting document.title should have no effect for non SVG/HTML documents
Product: WebKit Reporter: Rob Buis <rbuis>
Component: New BugsAssignee: Rob Buis <rwlbuis>
Status: RESOLVED FIXED    
Severity: Normal CC: cdumez, commit-queue, dbates, esprehn+autocc, ews-watchlist, kangil.han, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Other   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch
none
Patch none

Rob Buis
Reported 2018-11-14 11:27:17 PST
Setting document.title should have no effect for non SVG/HTML documents, see https://html.spec.whatwg.org/multipage/dom.html#document.title.
Attachments
Patch (2.28 KB, patch)
2018-11-14 11:32 PST, Rob Buis
no flags
Patch (4.30 KB, patch)
2018-11-16 07:55 PST, Rob Buis
no flags
Patch (4.08 KB, patch)
2018-11-16 09:50 PST, Rob Buis
no flags
Patch (4.74 KB, patch)
2018-11-16 10:27 PST, Rob Buis
no flags
Patch (6.11 KB, patch)
2018-11-19 02:49 PST, Rob Buis
no flags
Patch (6.10 KB, patch)
2018-11-19 10:44 PST, Rob Buis
no flags
Rob Buis
Comment 1 2018-11-14 11:32:50 PST
Rob Buis
Comment 2 2018-11-16 05:58:50 PST
Chromium bug is crbug.com/906038.
Rob Buis
Comment 3 2018-11-16 07:55:01 PST
Chris Dumez
Comment 4 2018-11-16 08:33:59 PST
Comment on attachment 355060 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355060&action=review > Source/WebCore/ChangeLog:11 > + Behavior matches Firefox. What's Chrome behavior? > Source/WebCore/dom/Document.cpp:1583 > + ASSERT(!m_titleElement || isHTMLDocument() || isXHTMLDocument() || isSVGDocument()); Not sure how useful this assertion is. > Source/WebCore/dom/Document.cpp:1597 > } else return; > Source/WebCore/dom/Document.cpp:1600 > if (is<HTMLTitleElement>(m_titleElement.get())) I think we can get rid of all these if checks and simply do: m_titleElement->setTextContent(title);
Rob Buis
Comment 5 2018-11-16 09:49:54 PST
Comment on attachment 355060 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355060&action=review >> Source/WebCore/ChangeLog:11 >> + Behavior matches Firefox. > > What's Chrome behavior? Same as WebKit. I am preparing a patch on chromium side to implement the new behavior (https://chromium-review.googlesource.com/c/chromium/src/+/1339959). >> Source/WebCore/dom/Document.cpp:1583 >> + ASSERT(!m_titleElement || isHTMLDocument() || isXHTMLDocument() || isSVGDocument()); > > Not sure how useful this assertion is. This is maybe the controversial (and optional) part of the patch. If you read the FIXME, it is clear we suspect the old code is not useful anymore (setting m_titleElement to nullptr). I think m_titleElement will only be set for html/svg/xhtml case, so no need to set it to nullptr for other document types (like xml). So to play it safe I wanted to keep the check as an ASSERT, but fine to leave it out of the patch as well. Or we can just keep setting m_titleElement to nullptr to play it safe, but it does look a bit silly. My feeling is to go for removing it. >> Source/WebCore/dom/Document.cpp:1597 >> } > > else > return; Done. >> Source/WebCore/dom/Document.cpp:1600 >> if (is<HTMLTitleElement>(m_titleElement.get())) > > I think we can get rid of all these if checks and simply do: > m_titleElement->setTextContent(title); I like it! Done.
Rob Buis
Comment 6 2018-11-16 09:50:38 PST
Chris Dumez
Comment 7 2018-11-16 09:52:16 PST
Comment on attachment 355069 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355069&action=review > LayoutTests/imported/w3c/ChangeLog:8 > + * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-10.html: Added. Aren't you missing the -expected.txt ? Unlike Blink, I believe WebKit still relies on them.
Rob Buis
Comment 8 2018-11-16 10:26:50 PST
Comment on attachment 355069 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355069&action=review >> LayoutTests/imported/w3c/ChangeLog:8 >> + * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-10.html: Added. > > Aren't you missing the -expected.txt ? Unlike Blink, I believe WebKit still relies on them. Well spotted, will fix.
Rob Buis
Comment 9 2018-11-16 10:27:45 PST
Chris Dumez
Comment 10 2018-11-16 10:30:01 PST
Comment on attachment 355072 [details] Patch r=me if the bots are happy.
Rob Buis
Comment 11 2018-11-19 02:49:16 PST
Rob Buis
Comment 12 2018-11-19 05:40:27 PST
(In reply to Chris Dumez from comment #10) > Comment on attachment 355072 [details] > Patch > > r=me if the bots are happy. Thanks Chris! Since your review, tkent has suggested another subtest and I had to change setTitle to make it work: https://chromium-review.googlesource.com/c/chromium/src/+/1339959 Basically I made setTitle exactly match the specification steps, which I think is not a bad thing. Can you have a quick check that the r=me still stands?
Chris Dumez
Comment 13 2018-11-19 09:08:31 PST
Comment on attachment 355261 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=355261&action=review > Source/WebCore/dom/Document.cpp:1590 > + } else if (element && element->isHTMLElement()) { is<HTMLElement>(element)
Rob Buis
Comment 14 2018-11-19 10:44:38 PST
WebKit Commit Bot
Comment 15 2018-11-19 12:43:01 PST
Comment on attachment 355286 [details] Patch Clearing flags on attachment: 355286 Committed r238377: <https://trac.webkit.org/changeset/238377>
WebKit Commit Bot
Comment 16 2018-11-19 12:43:03 PST
All reviewed patches have been landed. Closing bug.
Radar WebKit Bug Importer
Comment 17 2018-11-19 12:44:33 PST
Note You need to log in before you can comment on or make changes to this bug.