Changeset 195491 in webkit


Ignore:
Timestamp:
Jan 22, 2016 3:43:13 PM (8 years ago)
Author:
Chris Dumez
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:

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:

No new tests, already covered by existing test.

  • dom/DOMImplementation.cpp:

(WebCore::DOMImplementation::createHTMLDocument):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r195485 r195491  
     12016-01-22  Chris Dumez  <cdumez@apple.com>
     2
     3        DOMImplementation.createHTMLDocument("") should append an empty Text Node to the title Element
     4        https://bugs.webkit.org/show_bug.cgi?id=153374
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Rebaseline existing W3C DOM tests now that more checks are passing.
     9
     10        * web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt:
     11        * web-platform-tests/dom/ranges/Range-selectNode-expected.txt:
     12
    1132016-01-22  Chris Dumez  <cdumez@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/DOMImplementation-createHTMLDocument-expected.txt

    r195485 r195491  
    11
    2 FAIL createHTMLDocument test 0: "","","" assert_equals: expected 1 but got 0
     2PASS createHTMLDocument test 0: "","",""
    33PASS createHTMLDocument test 1: null,"null","null"
    44PASS createHTMLDocument test 2: undefined,undefined,""
  • trunk/LayoutTests/imported/w3c/web-platform-tests/dom/ranges/Range-selectNode-expected.txt

    r190174 r195491  
    152152PASS ****** foreign doc: title node, XML doc's range, type 1
    153153PASS ****** foreign doc: title node, detached range, type 1
     154PASS ******** foreign doc: #text node, current doc's range, type 3
     155PASS ******** foreign doc: #text node, foreign doc's range, type 3
     156PASS ******** foreign doc: #text node, XML doc's range, type 3
     157PASS ******** foreign doc: #text node, detached range, type 3
    154158PASS **** foreign doc: body node, current doc's range, type 1
    155159PASS **** foreign doc: body node, foreign doc's range, type 1
  • trunk/Source/WebCore/ChangeLog

    r195487 r195491  
     12016-01-22  Chris Dumez  <cdumez@apple.com>
     2
     3        DOMImplementation.createHTMLDocument("") should append an empty Text Node to the title Element
     4        https://bugs.webkit.org/show_bug.cgi?id=153374
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        DOMImplementation.createHTMLDocument("") should append an empty Text
     9        Node to the title Element as per the steps at:
     10        - https://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument (step 6)
     11
     12        Firefox and Chrome follow the specification here.
     13
     14        Previously, WebKit would rely on HTMLTitleElement.text setter which
     15        does not create a Text Node if the title is the empty string, as per:
     16        - https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text
     17        - https://dom.spec.whatwg.org/#dom-node-textcontent
     18
     19        No new tests, already covered by existing test.
     20
     21        * dom/DOMImplementation.cpp:
     22        (WebCore::DOMImplementation::createHTMLDocument):
     23
    1242016-01-17  Ada Chan  <adachan@apple.com>
    225
  • trunk/Source/WebCore/dom/DOMImplementation.cpp

    r194819 r195491  
    3636#include "FTPDirectoryDocument.h"
    3737#include "HTMLDocument.h"
     38#include "HTMLHeadElement.h"
     39#include "HTMLTitleElement.h"
    3840#include "Image.h"
    3941#include "ImageDocument.h"
     
    5254#include "StyleSheetContents.h"
    5355#include "SubframeLoader.h"
     56#include "Text.h"
    5457#include "TextDocument.h"
    5558#include "XMLNames.h"
     
    5861
    5962namespace WebCore {
     63
     64using namespace HTMLNames;
    6065
    6166typedef HashSet<String, CaseFoldingHash> FeatureSet;
     
    297302Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
    298303{
    299     Ref<HTMLDocument> doc = HTMLDocument::create(nullptr, URL());
    300     doc->open();
    301     doc->write("<!doctype html><html><body></body></html>");
    302     if (!title.isNull())
    303         doc->setTitle(title);
    304     doc->setSecurityOriginPolicy(m_document.securityOriginPolicy());
    305     return doc;
     304    auto document = HTMLDocument::create(nullptr, URL());
     305    document->open();
     306    document->write("<!doctype html><html><head></head><body></body></html>");
     307    if (!title.isNull()) {
     308        auto titleElement = HTMLTitleElement::create(titleTag, document);
     309        titleElement->appendChild(document->createTextNode(title));
     310        ASSERT(document->head());
     311        document->head()->appendChild(WTFMove(titleElement));
     312    }
     313    document->setSecurityOriginPolicy(m_document.securityOriginPolicy());
     314    return document;
    306315}
    307316
Note: See TracChangeset for help on using the changeset viewer.