Title: [195491] trunk
Revision
195491
Author
[email protected]
Date
2016-01-22 15:43:13 -0800 (Fri, 22 Jan 2016)

Log Message

DOMImplementation.createHTMLDocument("") should append an empty Text Node to the title Element
https://bugs.webkit.org/show_bug.cgi?id=153374

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline existing W3C DOM tests now that more checks are passing.

* web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt:
* web-platform-tests/dom/ranges/Range-selectNode-expected.txt:

Source/WebCore:

DOMImplementation.createHTMLDocument("") should append an empty Text
Node to the title Element as per the steps at:
- https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument (step 6)

Firefox and Chrome follow the specification here.

Previously, WebKit would rely on HTMLTitleElement.text setter which
does not create a Text Node if the title is the empty string, as per:
- https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text
- https://dom.spec.whatwg.org/#dom-node-textcontent

No new tests, already covered by existing test.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createHTMLDocument):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (195490 => 195491)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-01-22 23:37:23 UTC (rev 195490)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-01-22 23:43:13 UTC (rev 195491)
@@ -1,5 +1,17 @@
 2016-01-22  Chris Dumez  <[email protected]>
 
+        DOMImplementation.createHTMLDocument("") should append an empty Text Node to the title Element
+        https://bugs.webkit.org/show_bug.cgi?id=153374
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline existing W3C DOM tests now that more checks are passing.
+
+        * web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt:
+        * web-platform-tests/dom/ranges/Range-selectNode-expected.txt:
+
+2016-01-22  Chris Dumez  <[email protected]>
+
         Document.URL / Document.documentURI should return "about:blank" instead of empty string / null
         https://bugs.webkit.org/show_bug.cgi?id=153363
         <rdar://problem/22549736>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt (195490 => 195491)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt	2016-01-22 23:37:23 UTC (rev 195490)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt	2016-01-22 23:43:13 UTC (rev 195491)
@@ -1,5 +1,5 @@
 
-FAIL createHTMLDocument test 0: "","","" assert_equals: expected 1 but got 0
+PASS createHTMLDocument test 0: "","","" 
 PASS createHTMLDocument test 1: null,"null","null" 
 PASS createHTMLDocument test 2: undefined,undefined,"" 
 PASS createHTMLDocument test 3: "foo  bar baz","foo  bar baz","foo bar baz" 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-selectNode-expected.txt (195490 => 195491)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-selectNode-expected.txt	2016-01-22 23:37:23 UTC (rev 195490)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-selectNode-expected.txt	2016-01-22 23:43:13 UTC (rev 195491)
@@ -151,6 +151,10 @@
 PASS ****** foreign doc: title node, foreign doc's range, type 1 
 PASS ****** foreign doc: title node, XML doc's range, type 1 
 PASS ****** foreign doc: title node, detached range, type 1 
+PASS ******** foreign doc: #text node, current doc's range, type 3 
+PASS ******** foreign doc: #text node, foreign doc's range, type 3 
+PASS ******** foreign doc: #text node, XML doc's range, type 3 
+PASS ******** foreign doc: #text node, detached range, type 3 
 PASS **** foreign doc: body node, current doc's range, type 1 
 PASS **** foreign doc: body node, foreign doc's range, type 1 
 PASS **** foreign doc: body node, XML doc's range, type 1 

Modified: trunk/Source/WebCore/ChangeLog (195490 => 195491)


--- trunk/Source/WebCore/ChangeLog	2016-01-22 23:37:23 UTC (rev 195490)
+++ trunk/Source/WebCore/ChangeLog	2016-01-22 23:43:13 UTC (rev 195491)
@@ -1,3 +1,26 @@
+2016-01-22  Chris Dumez  <[email protected]>
+
+        DOMImplementation.createHTMLDocument("") should append an empty Text Node to the title Element
+        https://bugs.webkit.org/show_bug.cgi?id=153374
+
+        Reviewed by Ryosuke Niwa.
+
+        DOMImplementation.createHTMLDocument("") should append an empty Text
+        Node to the title Element as per the steps at:
+        - https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument (step 6)
+
+        Firefox and Chrome follow the specification here.
+
+        Previously, WebKit would rely on HTMLTitleElement.text setter which
+        does not create a Text Node if the title is the empty string, as per:
+        - https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text
+        - https://dom.spec.whatwg.org/#dom-node-textcontent
+
+        No new tests, already covered by existing test.
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createHTMLDocument):
+
 2016-01-17  Ada Chan  <[email protected]>
 
         Add a mode parameter to MediaControllerInterface::supportsFullscreen() and ChromeClient::supportsVideoFullscreen().

Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (195490 => 195491)


--- trunk/Source/WebCore/dom/DOMImplementation.cpp	2016-01-22 23:37:23 UTC (rev 195490)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp	2016-01-22 23:43:13 UTC (rev 195491)
@@ -35,6 +35,8 @@
 #include "FrameLoaderClient.h"
 #include "FTPDirectoryDocument.h"
 #include "HTMLDocument.h"
+#include "HTMLHeadElement.h"
+#include "HTMLTitleElement.h"
 #include "Image.h"
 #include "ImageDocument.h"
 #include "MainFrame.h"
@@ -51,6 +53,7 @@
 #include "Settings.h"
 #include "StyleSheetContents.h"
 #include "SubframeLoader.h"
+#include "Text.h"
 #include "TextDocument.h"
 #include "XMLNames.h"
 #include <wtf/NeverDestroyed.h>
@@ -58,6 +61,8 @@
 
 namespace WebCore {
 
+using namespace HTMLNames;
+
 typedef HashSet<String, CaseFoldingHash> FeatureSet;
 
 static void addString(FeatureSet& set, const char* string)
@@ -296,13 +301,17 @@
 
 Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
 {
-    Ref<HTMLDocument> doc = HTMLDocument::create(nullptr, URL());
-    doc->open();
-    doc->write("<!doctype html><html><body></body></html>");
-    if (!title.isNull())
-        doc->setTitle(title);
-    doc->setSecurityOriginPolicy(m_document.securityOriginPolicy());
-    return doc;
+    auto document = HTMLDocument::create(nullptr, URL());
+    document->open();
+    document->write("<!doctype html><html><head></head><body></body></html>");
+    if (!title.isNull()) {
+        auto titleElement = HTMLTitleElement::create(titleTag, document);
+        titleElement->appendChild(document->createTextNode(title));
+        ASSERT(document->head());
+        document->head()->appendChild(WTFMove(titleElement));
+    }
+    document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
+    return document;
 }
 
 Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to