DocType's publicId / systemId should not be nullable
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2016 00:57:18 +0000 (00:57 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 Jul 2016 00:57:18 +0000 (00:57 +0000)
commitd17753b5ca6947185610e7f16f134883ce94c131
tree2a0cc44f6b8313544bdee34b5d140f63456ea0be
parent995bcb03c0ed08cc364ca900e200e1bf4b72fc69
DocType's publicId / systemId should not be nullable
https://bugs.webkit.org/show_bug.cgi?id=159901

Reviewed by Benjamin Poulain.

LayoutTests/imported/w3c:

Rebaseline now that more checks regarding DocumentType serialization
are passing.

* web-platform-tests/domparsing/xml-serialization-expected.txt:

Source/WebCore:

DocType's publicId / systemId should not be nullable. While they were
not marked as nullable in our IDL, they could be stored as null Strings
in our implementation depending on how the Node was constructed. This
led to subtle bugs where String() != emptyString().

In particular, Node.isEqualNode() would return false when DocumentType
nodes would mismatch because of their publicId / systemId being null
instead of the emptyString.

Serialization would DocumentType nodes would also be wrong when
publicId / systemId were empty Strings instead of null strings. The
new behavior now matches:
- https://www.w3.org/TR/DOM-Parsing/#dfn-concept-serialize-doctype (steps 7-9)

To address these issues, we now always store publicId / systemId as
non-null Strings inside the DocumentType class.

Test: fast/dom/DocumentType/isEqualNode.html

* dom/DocumentType.cpp:
(WebCore::DocumentType::DocumentType):
* editing/MarkupAccumulator.cpp:
(WebCore::MarkupAccumulator::appendDocumentType):

LayoutTests:

Add test coverage for comparison of DocumentType nodes
using isEqualNode(). This tests used to fail and now passes.
The test passes in Firefox and Chrome as well.

* fast/dom/DocumentType/isEqualNode-expected.txt: Added.
* fast/dom/DocumentType/isEqualNode.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@203389 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/dom/DocumentType/isEqualNode-expected.txt [new file with mode: 0644]
LayoutTests/fast/dom/DocumentType/isEqualNode.html [new file with mode: 0644]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/domparsing/xml-serialization-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/dom/DocumentType.cpp
Source/WebCore/editing/MarkupAccumulator.cpp