Title: [238377] trunk
- Revision
- 238377
- Author
- commit-qu...@webkit.org
- Date
- 2018-11-19 12:42:53 -0800 (Mon, 19 Nov 2018)
Log Message
Setting document.title should have no effect for non SVG/HTML documents
https://bugs.webkit.org/show_bug.cgi?id=191643
Patch by Rob Buis <rb...@igalia.com> on 2018-11-19
Reviewed by Chris Dumez.
LayoutTests/imported/w3c:
* web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt: Added.
* web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html: Added.
Source/WebCore:
Setting document.title should have no effect for non SVG/HTML documents,
see https://html.spec.whatwg.org/multipage/dom.html#document.title.
Behavior matches Firefox and Chrome.
Test: imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html
* dom/Document.cpp:
(WebCore::Document::setTitle):
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/imported/w3c/ChangeLog (238376 => 238377)
--- trunk/LayoutTests/imported/w3c/ChangeLog 2018-11-19 16:49:43 UTC (rev 238376)
+++ trunk/LayoutTests/imported/w3c/ChangeLog 2018-11-19 20:42:53 UTC (rev 238377)
@@ -1,3 +1,13 @@
+2018-11-19 Rob Buis <rb...@igalia.com>
+
+ Setting document.title should have no effect for non SVG/HTML documents
+ https://bugs.webkit.org/show_bug.cgi?id=191643
+
+ Reviewed by Chris Dumez.
+
+ * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt: Added.
+ * web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html: Added.
+
2018-11-18 Yusuke Suzuki <yusukesuz...@slowstart.org>
Unreviewed, rolling in the rest of r237254
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt (0 => 238377)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg-expected.txt 2018-11-19 20:42:53 UTC (rev 238377)
@@ -0,0 +1,4 @@
+
+PASS Should not be able to set document title in XML document
+PASS Should not be able to set document title in XML document with html:title element
+
Added: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html (0 => 238377)
--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html 2018-11-19 20:42:53 UTC (rev 238377)
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<link rel="author" title="Rob Buis" href=""
+<link rel="help" href=""
+<script src=""
+<script src=""
+<div id="log"></div>
+<script>
+
+function newXMLDocument() {
+ return document.implementation.createDocument(null, "xml", null);
+}
+
+test(function() {
+ var doc = newXMLDocument();
+ assert_equals(doc.title, "");
+ doc.title = "fail";
+ assert_equals(doc.title, "");
+}, "Should not be able to set document title in XML document");
+
+test(function() {
+ var doc = newXMLDocument();
+ doc.documentElement.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "html:title"));
+ assert_equals(doc.title, "");
+ doc.title = "fail";
+ assert_equals(doc.title, "");
+}, "Should not be able to set document title in XML document with html:title element");
+</script>
Modified: trunk/Source/WebCore/ChangeLog (238376 => 238377)
--- trunk/Source/WebCore/ChangeLog 2018-11-19 16:49:43 UTC (rev 238376)
+++ trunk/Source/WebCore/ChangeLog 2018-11-19 20:42:53 UTC (rev 238377)
@@ -1,3 +1,20 @@
+2018-11-19 Rob Buis <rb...@igalia.com>
+
+ Setting document.title should have no effect for non SVG/HTML documents
+ https://bugs.webkit.org/show_bug.cgi?id=191643
+
+ Reviewed by Chris Dumez.
+
+ Setting document.title should have no effect for non SVG/HTML documents,
+ see https://html.spec.whatwg.org/multipage/dom.html#document.title.
+
+ Behavior matches Firefox and Chrome.
+
+ Test: imported/w3c/web-platform-tests/html/dom/documents/dom-tree-accessors/document.title-not-in-html-svg.html
+
+ * dom/Document.cpp:
+ (WebCore::Document::setTitle):
+
2018-11-19 Wenson Hsieh <wenson_hs...@apple.com>
Dragging image with a border-image larger than the image element crashes
Modified: trunk/Source/WebCore/dom/Document.cpp (238376 => 238377)
--- trunk/Source/WebCore/dom/Document.cpp 2018-11-19 16:49:43 UTC (rev 238376)
+++ trunk/Source/WebCore/dom/Document.cpp 2018-11-19 20:42:53 UTC (rev 238377)
@@ -1580,33 +1580,23 @@
void Document::setTitle(const String& title)
{
- if (!m_titleElement) {
- if (isHTMLDocument() || isXHTMLDocument()) {
+ auto* element = documentElement();
+ if (is<SVGSVGElement>(element)) {
+ if (!m_titleElement) {
+ m_titleElement = SVGTitleElement::create(SVGNames::titleTag, *this);
+ element->insertBefore(*m_titleElement, element->firstChild());
+ }
+ m_titleElement->setTextContent(title);
+ } else if (is<HTMLElement>(element)) {
+ if (!m_titleElement) {
auto* headElement = head();
if (!headElement)
return;
m_titleElement = HTMLTitleElement::create(HTMLNames::titleTag, *this);
headElement->appendChild(*m_titleElement);
- } else if (isSVGDocument()) {
- auto* element = documentElement();
- if (!is<SVGSVGElement>(element))
- return;
- m_titleElement = SVGTitleElement::create(SVGNames::titleTag, *this);
- element->insertBefore(*m_titleElement, element->firstChild());
}
- } else if (!isHTMLDocument() && !isXHTMLDocument() && !isSVGDocument()) {
- // FIXME: What exactly is the point of this? This seems like a strange moment
- // in time to demote something from being m_titleElement, when setting the
- // value of the title attribute. Do we have test coverage for this?
- m_titleElement = nullptr;
+ m_titleElement->setTextContent(title);
}
-
- if (is<HTMLTitleElement>(m_titleElement.get()))
- downcast<HTMLTitleElement>(*m_titleElement).setTextContent(title);
- else if (is<SVGTitleElement>(m_titleElement.get()))
- downcast<SVGTitleElement>(*m_titleElement).setTextContent(title);
- else
- updateTitle({ title, TextDirection::LTR });
}
template<typename> struct TitleTraits;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes