Re-sync web-platform-tests/domparsing from upstream
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 17:48:31 +0000 (17:48 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Apr 2019 17:48:31 +0000 (17:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=196544

Reviewed by Alex Christensen.

Re-sync web-platform-tests/domparsing from upstream 3bfdeb8976fc5.

* web-platform-tests/domparsing/*: Updated
* web-platform-tests/interfaces/DOM-Parsing.idl: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@243813 268f45cc-cd09-0410-ab3c-d52691b4dbfc

20 files changed:
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-doctype.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/META.yml [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/OWNERS [deleted file]
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString-expected.txt
LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html-xhtml.xhtml
LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.js [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/style_attribute_html.html
LayoutTests/imported/w3c/web-platform-tests/domparsing/w3c-import.log
LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser.html [new file with mode: 0644]
LayoutTests/imported/w3c/web-platform-tests/interfaces/DOM-Parsing.idl [new file with mode: 0644]

index a2bea80..742a590 100644 (file)
@@ -1,3 +1,15 @@
+2019-04-03  Chris Dumez  <cdumez@apple.com>
+
+        Re-sync web-platform-tests/domparsing from upstream
+        https://bugs.webkit.org/show_bug.cgi?id=196544
+
+        Reviewed by Alex Christensen.
+
+        Re-sync web-platform-tests/domparsing from upstream 3bfdeb8976fc5.
+
+        * web-platform-tests/domparsing/*: Updated
+        * web-platform-tests/interfaces/DOM-Parsing.idl: Added.
+
 2019-04-03  Sihui Liu  <sihui_liu@apple.com>
 
         Blob type cannot be stored correctly in IDB when IDBObjectStore has autoIncrement and keyPath options
index 52261f2..cd655ac 100644 (file)
@@ -2,8 +2,8 @@
 <meta charset=utf-8>
 <title>HTML entities for various XHTML Doctype variants</title>
 <link rel=help href="http://w3c.github.io/html/xhtml.html#parsing-xhtml-documents">
-<script src="../../../../resources/testharness.js"></script>
-<script src="../../../../resources/testharnessreport.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
 <script>
   test(function () {
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror-expected.txt
new file mode 100644 (file)
index 0000000..4df8c4b
--- /dev/null
@@ -0,0 +1,19 @@
+
+FAIL DOMParser: <parsererror> element added on error, <span x:test="testing">1</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, < span>2</span> 
+FAIL DOMParser: <parsererror> element added on error, <span :test="testing">3</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, <span><em>4</span></em> 
+PASS DOMParser: <parsererror> element added on error, <span>5 
+PASS DOMParser: <parsererror> element added on error, 6</span> 
+PASS DOMParser: <parsererror> element added on error, <span>7< /span> 
+PASS DOMParser: <parsererror> element added on error, <span>8</ span> 
+PASS DOMParser: <parsererror> element added on error, <span novalue>9</span> 
+PASS DOMParser: <parsererror> element added on error, <span ="noattr">10</span> 
+FAIL DOMParser: <parsererror> element added on error, <span ::="test">11</span> assert_equals: expecting one parsererror expected 1 but got 0
+FAIL DOMParser: <parsererror> element added on error, <span xmlns:="urn:x-test:test">12</span> assert_equals: expecting one parsererror expected 1 but got 0
+PASS DOMParser: <parsererror> element added on error, <span xmlns:xmlns="">13</span> 
+PASS DOMParser: <parsererror> element added on error, <span data-test=testing>14</span> 
+PASS DOMParser: <parsererror> element added on error, 15<span 
+PASS DOMParser: <parsererror> element added on error, <8:test xmlns:8="urn:x-test:test">16</8:test> 
+PASS DOMParser: <parsererror> element added on error, <span xmlns:p1 xmlns:p2="urn:x-test:test"/>17 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror.html b/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror.html
new file mode 100644 (file)
index 0000000..9ecd0ed
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<title>DOMParser: &lt;parsererror> element added on error</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+const xhtml_prologue = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"' +
+                       ' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">\n' +
+                       '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">\n' +
+                       '<body>\n',
+      xhtml_epilogue = '</body>\n</html>\n';
+
+[
+  '<span x:test="testing">1</span>',                // undeclared 'x' namespace prefix
+  '< span>2</span>',                                // bad start tag
+  '<span :test="testing">3</span>',                 // empty namespace prefix
+  '<span><em>4</span></em>',                        // staggered tags
+  '<span>5',                                        // missing end </span> tag
+  '6</span>',                                       // missing start <span> tag
+  '<span>7< /span>',                                // bad end tag
+  '<span>8</ span>',                                // bad end tag
+  '<span novalue>9</span>',                         // missing attribute value
+  '<span ="noattr">10</span>',                      // missing attribute name
+  '<span ::="test">11</span>',                      // bad namespace prefix
+  '<span xmlns:="urn:x-test:test">12</span>',       // missing namespace prefix
+  '<span xmlns:xmlns="">13</span>',                 // invalid namespace prefix
+  '<span data-test=testing>14</span>',              // unquoted attribute value
+  '15<span',                                        // bad start tag
+  '<8:test xmlns:8="urn:x-test:test">16</8:test>',  // invalid namespace prefix
+  '<span xmlns:p1 xmlns:p2="urn:x-test:test"/>17',  // missing namespace URI
+].forEach(fragment => {
+  test(() => {
+    var document_string = xhtml_prologue + fragment + xhtml_epilogue;
+    var doc = (new DOMParser).parseFromString(document_string, "application/xhtml+xml");
+    var parsererrors = doc.getElementsByTagName("parsererror");
+    assert_equals(parsererrors.length, 1, 'expecting one parsererror');
+  }, document.title + ', ' + fragment);
+});
+</script>
index 1090c76..c639c23 100644 (file)
@@ -1,8 +1,8 @@
 <!DOCTYPE html>
 <title>DOMParser</title>
 <link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
-<script src="../../../../resources/testharness.js"></script>
-<script src="../../../../resources/testharnessreport.js"></script>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
 <div id="log"></div>
 <script>
 function checkMetadata(doc, contentType) {
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/META.yml b/LayoutTests/imported/w3c/web-platform-tests/domparsing/META.yml
new file mode 100644 (file)
index 0000000..72f66c4
--- /dev/null
@@ -0,0 +1,4 @@
+spec: https://w3c.github.io/DOM-Parsing/
+suggested_reviewers:
+  - ChrisParis
+  - jdm
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/OWNERS b/LayoutTests/imported/w3c/web-platform-tests/domparsing/OWNERS
deleted file mode 100644 (file)
index 892cbb2..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-@ChrisParis
-@jdm
index 3f8ca5e..181330b 100644 (file)
@@ -1,5 +1,24 @@
 domparsing_XMLSerializer_serializeToString
 
 
-PASS check  XMLSerializer.serializeToString method could parsing xmldoc to string 
+PASS check XMLSerializer.serializeToString method could parsing xmldoc to string 
+PASS Check if the default namespace is correctly reset. 
+FAIL Check if there is no redundant empty namespace declaration. assert_equals: expected "<root xmlns=\"urn:bar\"><outer xmlns=\"\"><inner>value1</inner></outer></root>" but got "<root xmlns=\"urn:bar\"><outer xmlns=\"\"><inner xmlns=\"\">value1</inner></outer></root>"
+FAIL Check if redundant xmlns="..." is dropped. assert_equals: expected "<root><child/></root>" but got "<root><child xmlns=\"\"/></root>"
+FAIL Check if inconsistent xmlns="..." is dropped. assert_equals: expected "<root xmlns=\"uri1\"><child xmlns=\"\"/><child2 xmlns=\"uri2\"/><child3/><child4 xmlns=\"uri4\"/><child5 xmlns=\"\"/></root>" but got "<root xmlns=\"uri1\"><child xmlns=\"FAIL1\"/><child2 xmlns=\"FAIL2\"/><child3 xmlns=\"FAIL3\"/><child4 xmlns=\"uri4\"/><child5 xmlns=\"\"/></root>"
+PASS Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix 
+FAIL Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix even if the prefix is assigned to another namespace. assert_equals: expected "<el1 xmlns:p=\"u1\" xmlns:q=\"u1\"><el2 xmlns:q=\"u2\" q:name=\"v\"/></el1>" but got "<el1 xmlns:p=\"u1\" xmlns:q=\"u1\"><el2 xmlns:q=\"u2\" q:name=\"v\" xmlns:q=\"u1\"/></el1>"
+PASS Check if the prefix of an attribute is replaced with another existing prefix mapped to the same namespace URI. 
+FAIL Check if the prefix of an attribute is NOT preserved in a case where neither its prefix nor its namespace URI is not already used. assert_equals: expected "<r xmlns:xx=\"uri\" xmlns:ns1=\"uri2\" ns1:name=\"value\"/>" but got "<r xmlns:xx=\"uri\" p:name=\"value\" xmlns:p=\"uri2\"/>"
+FAIL Check if the prefix of an attribute is replaced with a generated one in a case where the prefix is already mapped to a different namespace URI. assert_equals: expected "<r xmlns:xx=\"uri\" xmlns:ns1=\"uri2\" ns1:name=\"value\"/>" but got "<r xmlns:xx=\"uri\" NS1:name=\"value\" xmlns:NS1=\"uri2\"/>"
+FAIL check XMLSerializer.serializeToString escapes attribute values for roundtripping assert_in_array: value "<root attr=\"\t\"/>" not in array ["<root attr=\"&#9;\"/>", "<root attr=\"&#x9;\"/>"]
+FAIL Check if attribute serialization takes into account of following xmlns:* attributes assert_equals: expected "<root xmlns:ns1=\"uri1\" ns1:foobar=\"value1\" xmlns:p=\"uri2\"/>" but got "<root p:foobar=\"value1\" xmlns:p=\"uri1\" xmlns:p=\"uri2\"/>"
+FAIL Check if attribute serialization takes into account of the same prefix declared in an ancestor element assert_equals: expected "<root xmlns:p=\"uri1\"><child xmlns:ns1=\"uri2\" ns1:foobar=\"v\"/></root>" but got "<root xmlns:p=\"uri1\"><child NS1:foobar=\"v\" xmlns:NS1=\"uri2\"/></root>"
+FAIL Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace. assert_equals: expected "<root xmlns=\"u1\"><child xmlns:p=\"u1\"/></root>" but got "<root xmlns=\"u1\"><p:child xmlns:p=\"u1\"/></root>"
+FAIL Check if start tag serialization finds an appropriate prefix. assert_equals: expected "<root xmlns:p1=\"u1\"><child xmlns:p2=\"u1\"><p2:child2/></child></root>" but got "<root xmlns:p1=\"u1\"><child xmlns:p2=\"u1\"><child2 xmlns=\"u1\"/></child></root>"
+FAIL Check if start tag serialization takes into account of its xmlns:* attributes assert_equals: expected "<ns1:root xmlns:ns1=\"uri1\" xmlns:p=\"uri2\"/>" but got "<p:root xmlns:p=\"uri2\"/>"
+PASS Check if start tag serialization applied the original prefix even if it is declared in an ancestor element. 
+FAIL Check if generated prefixes match to "ns${index}". assert_equals: expected "<root><child1 xmlns:ns1=\"uri1\" ns1:attr1=\"value1\" xmlns:ns2=\"uri2\" ns2:attr2=\"value2\"/><child2 xmlns:ns3=\"uri3\" ns3:attr3=\"value3\"/></root>" but got "<root><child1 NS1:attr1=\"value1\" xmlns:NS1=\"uri1\" NS2:attr2=\"value2\" xmlns:NS2=\"uri2\"/><child2 NS3:attr3=\"value3\" xmlns:NS3=\"uri3\"/></root>"
+FAIL Check if "ns1" is generated even if the element already has xmlns:ns1. assert_equals: expected "<root xmlns:ns2=\"uri2\"><child xmlns:ns1=\"uri1\" xmlns:ns1=\"uri3\" ns1:attr1=\"value1\"/></root>" but got "<root xmlns:ns2=\"uri2\"><child xmlns:ns1=\"uri1\" NS1:attr1=\"value1\" xmlns:NS1=\"uri3\"/></root>"
+FAIL Check if no special handling for XLink namespace unlike HTML serializer. assert_equals: expected "<root xmlns:ns1=\"http://www.w3.org/1999/xlink\" ns1:href=\"v\"/>" but got "<root NS1:href=\"v\" xmlns:NS1=\"http://www.w3.org/1999/xlink\"/>"
 
index 4a7627a..cb8ed93 100644 (file)
 <html>
  <head>
   <title>domparsing Test: XMLSerializer.serializeToString</title>
-  <script src="../../../../resources/testharness.js"></script>
-  <script src="../../../../resources/testharnessreport.js"></script>
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
  </head>
  <body>
     <h1>domparsing_XMLSerializer_serializeToString</h1>
   <script>
-        function createXmlDoc(){
-            var input = '<?xml version="1.0" encoding="UTF-8"?><root><child1>value1</child1></root>';
-            var parser = new DOMParser();
-            var doc = parser.parseFromString(input, 'text/xml');
-            return doc;
-        }
-        test(function() {
-            var serializer = new XMLSerializer ();
-            var root = createXmlDoc().documentElement;
-            var xmlString=serializer.serializeToString(root);
-            assert_equals(xmlString, "<root><child1>value1</child1></root>");
-        }, 'check  XMLSerializer.serializeToString method could parsing xmldoc to string');
-  </script>
+const XMLNS_URI = 'http://www.w3.org/2000/xmlns/';
+
+function createXmlDoc(){
+  var input = '<?xml version="1.0" encoding="UTF-8"?><root><child1>value1</child1></root>';
+  var parser = new DOMParser();
+  return parser.parseFromString(input, 'text/xml');
+}
+
+// Returns the root element.
+function parse(xmlString) {
+  return (new DOMParser()).parseFromString(xmlString, 'text/xml').documentElement;
+}
+
+function serialize(node) {
+  return (new XMLSerializer()).serializeToString(node);
+}
+
+test(function() {
+  var root = createXmlDoc().documentElement;
+  assert_equals(serialize(root), '<root><child1>value1</child1></root>');
+}, 'check XMLSerializer.serializeToString method could parsing xmldoc to string');
+
+test(function() {
+  var root = createXmlDoc().documentElement;
+  var element = root.ownerDocument.createElementNS('urn:foo', 'another');
+  var child1 = root.firstChild;
+  root.replaceChild(element, child1);
+  element.appendChild(child1);
+  assert_equals(serialize(root), '<root><another xmlns="urn:foo"><child1 xmlns="">value1</child1></another></root>');
+}, 'Check if the default namespace is correctly reset.');
+
+test(function() {
+  var root = parse('<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>');
+  assert_equals(serialize(root), '<root xmlns="urn:bar"><outer xmlns=""><inner>value1</inner></outer></root>');
+}, 'Check if there is no redundant empty namespace declaration.');
+
+test(function() {
+  assert_equals(serialize(parse('<root><child xmlns=""/></root>')),
+                '<root><child/></root>');
+  assert_equals(serialize(parse('<root xmlns=""><child xmlns=""/></root>')),
+                '<root><child/></root>');
+  assert_equals(serialize(parse('<root xmlns="u1"><child xmlns="u1"/></root>')),
+                '<root xmlns="u1"><child/></root>');
+}, 'Check if redundant xmlns="..." is dropped.');
+
+test(function() {
+  const root = parse('<root xmlns="uri1"/>');
+  const child = root.ownerDocument.createElement('child');
+  child.setAttributeNS(XMLNS_URI, 'xmlns', 'FAIL1');
+  root.appendChild(child);
+  const child2 = root.ownerDocument.createElementNS('uri2', 'child2');
+  child2.setAttributeNS(XMLNS_URI, 'xmlns', 'FAIL2');
+  root.appendChild(child2);
+  const child3 = root.ownerDocument.createElementNS('uri1', 'child3');
+  child3.setAttributeNS(XMLNS_URI, 'xmlns', 'FAIL3');
+  root.appendChild(child3);
+  const child4 = root.ownerDocument.createElementNS('uri4', 'child4');
+  child4.setAttributeNS(XMLNS_URI, 'xmlns', 'uri4');
+  root.appendChild(child4);
+  const child5 = root.ownerDocument.createElement('child5');
+  child5.setAttributeNS(XMLNS_URI, 'xmlns', '');
+  root.appendChild(child5);
+  assert_equals(serialize(root), '<root xmlns="uri1"><child xmlns=""/><child2 xmlns="uri2"/><child3/><child4 xmlns="uri4"/><child5 xmlns=""/></root>');
+}, 'Check if inconsistent xmlns="..." is dropped.');
+
+test(function() {
+  let root = parse('<r xmlns:xx="uri"></r>');
+  root.setAttributeNS('uri', 'name', 'v');
+  assert_equals(serialize(root), '<r xmlns:xx="uri" xx:name="v"/>');
+
+  let root2 = parse('<r xmlns:xx="uri"><b/></r>');
+  let child = root2.firstChild;
+  child.setAttributeNS('uri', 'name', 'v');
+  assert_equals(serialize(root2), '<r xmlns:xx="uri"><b xx:name="v"/></r>');
+
+  let root3 = parse('<r xmlns:x0="uri" xmlns:x2="uri"><b xmlns:x1="uri"/></r>');
+  let child3 = root3.firstChild;
+  child3.setAttributeNS('uri', 'name', 'v');
+  assert_equals(serialize(root3),
+                '<r xmlns:x0="uri" xmlns:x2="uri"><b xmlns:x1="uri" x1:name="v"/></r>',
+                'Should choose the nearest prefix');
+}, 'Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix');
+
+test(function() {
+  let root = parse('<el1 xmlns:p="u1" xmlns:q="u1"><el2 xmlns:q="u2"/></el1>');
+  root.firstChild.setAttributeNS('u1', 'name', 'v');
+  assert_equals(serialize(root),
+                '<el1 xmlns:p="u1" xmlns:q="u1"><el2 xmlns:q="u2" q:name="v"/></el1>');
+  // Maybe this is a specification error.
+}, 'Check if an attribute with namespace and no prefix is serialized with the nearest-declared prefix even if the prefix is assigned to another namespace.');
+
+test(function() {
+  let root = parse('<r xmlns:xx="uri"></r>');
+  root.setAttributeNS('uri', 'p:name', 'v');
+  assert_equals(serialize(root), '<r xmlns:xx="uri" xx:name="v"/>');
+
+  let root2 = parse('<r xmlns:xx="uri"><b/></r>');
+  let child = root2.firstChild;
+  child.setAttributeNS('uri', 'p:name', 'value');
+  assert_equals(serialize(root2),
+                '<r xmlns:xx="uri"><b xx:name="value"/></r>');
+}, 'Check if the prefix of an attribute is replaced with another existing prefix mapped to the same namespace URI.');
+
+test(function() {
+  let root = parse('<r xmlns:xx="uri"></r>');
+  root.setAttributeNS('uri2', 'p:name', 'value');
+  assert_equals(serialize(root),
+                '<r xmlns:xx="uri" xmlns:ns1="uri2" ns1:name="value"/>');
+}, 'Check if the prefix of an attribute is NOT preserved in a case where neither its prefix nor its namespace URI is not already used.');
+
+test(function() {
+  let root = parse('<r xmlns:xx="uri"></r>');
+  root.setAttributeNS('uri2', 'xx:name', 'value');
+  assert_equals(serialize(root),
+                '<r xmlns:xx="uri" xmlns:ns1="uri2" ns1:name="value"/>');
+}, 'Check if the prefix of an attribute is replaced with a generated one in a case where the prefix is already mapped to a different namespace URI.');
+
+test(function() {
+  var root = parse('<root />');
+  root.setAttribute('attr', '\t');
+  assert_in_array(serialize(root), [
+    '<root attr="&#9;"/>', '<root attr="&#x9;"/>']);
+  root.setAttribute('attr', '\n');
+  assert_in_array(serialize(root), [
+    '<root attr="&#xA;"/>', '<root attr="&#10;"/>']);
+  root.setAttribute('attr', '\r');
+  assert_in_array(serialize(root), [
+    '<root attr="&#xD;"/>', '<root attr="&#13;"/>']);
+}, 'check XMLSerializer.serializeToString escapes attribute values for roundtripping');
+
+test(function() {
+  const root = (new Document()).createElement('root');
+  root.setAttributeNS('uri1', 'p:foobar', 'value1');
+  root.setAttributeNS(XMLNS_URI, 'xmlns:p', 'uri2');
+  assert_equals(serialize(root), '<root xmlns:ns1="uri1" ns1:foobar="value1" xmlns:p="uri2"/>');
+}, 'Check if attribute serialization takes into account of following xmlns:* attributes');
+
+test(function() {
+  const root = parse('<root xmlns:p="uri1"><child/></root>');
+  root.firstChild.setAttributeNS('uri2', 'p:foobar', 'v');
+  assert_equals(serialize(root), '<root xmlns:p="uri1"><child xmlns:ns1="uri2" ns1:foobar="v"/></root>');
+}, 'Check if attribute serialization takes into account of the same prefix declared in an ancestor element');
+
+test(function() {
+  assert_equals(serialize(parse('<root><child/></root>')), '<root><child/></root>');
+  assert_equals(serialize(parse('<root xmlns="u1"><p:child xmlns:p="u1"/></root>')), '<root xmlns="u1"><child xmlns:p="u1"/></root>');
+}, 'Check if start tag serialization drops element prefix if the namespace is same as inherited default namespace.');
+
+test(function() {
+  const root = parse('<root xmlns:p1="u1"><child xmlns:p2="u1"/></root>');
+  const child2 = root.ownerDocument.createElementNS('u1', 'child2');
+  root.firstChild.appendChild(child2);
+  assert_equals(serialize(root), '<root xmlns:p1="u1"><child xmlns:p2="u1"><p2:child2/></child></root>');
+}, 'Check if start tag serialization finds an appropriate prefix.');
+
+test(function() {
+  const root = (new Document()).createElementNS('uri1', 'p:root');
+  root.setAttributeNS(XMLNS_URI, 'xmlns:p', 'uri2');
+  assert_equals(serialize(root), '<ns1:root xmlns:ns1="uri1" xmlns:p="uri2"/>');
+}, 'Check if start tag serialization takes into account of its xmlns:* attributes');
+
+test(function() {
+  const root = (new Document()).createElement('root');
+  root.setAttributeNS(XMLNS_URI, 'xmlns:p', 'uri2');
+  const child = root.ownerDocument.createElementNS('uri1', 'p:child');
+  root.appendChild(child);
+  assert_equals(serialize(root), '<root xmlns:p="uri2"><p:child xmlns:p="uri1"/></root>');
+}, 'Check if start tag serialization applied the original prefix even if it is declared in an ancestor element.');
+
+test(function() {
+  const root = parse('<root><child1/><child2/></root>');
+  root.firstChild.setAttributeNS('uri1', 'attr1', 'value1');
+  root.firstChild.setAttributeNS('uri2', 'attr2', 'value2');
+  root.lastChild.setAttributeNS('uri3', 'attr3', 'value3');
+  assert_equals(serialize(root), '<root><child1 xmlns:ns1="uri1" ns1:attr1="value1" xmlns:ns2="uri2" ns2:attr2="value2"/><child2 xmlns:ns3="uri3" ns3:attr3="value3"/></root>');
+}, 'Check if generated prefixes match to "ns${index}".');
+
+test(function() {
+  const root = parse('<root xmlns:ns2="uri2"><child xmlns:ns1="uri1"/></root>');
+  root.firstChild.setAttributeNS('uri3', 'attr1', 'value1');
+  // According to 'DOM Parsing and Serialization' draft as of 2018-12-11,
+  // 'generate a prefix' result can conflict with an existing xmlns:ns* declaration.
+  assert_equals(serialize(root), '<root xmlns:ns2="uri2"><child xmlns:ns1="uri1" xmlns:ns1="uri3" ns1:attr1="value1"/></root>');
+}, 'Check if "ns1" is generated even if the element already has xmlns:ns1.');
+
+test(function() {
+  const root = (new Document()).createElement('root');
+  root.setAttributeNS('http://www.w3.org/1999/xlink', 'href', 'v');
+  assert_equals(serialize(root), '<root xmlns:ns1="http://www.w3.org/1999/xlink" ns1:href="v"/>');
+
+  const root2 = (new Document()).createElement('root');
+  root2.setAttributeNS('http://www.w3.org/1999/xlink', 'xl:type', 'v');
+  assert_equals(serialize(root2), '<root xmlns:xl="http://www.w3.org/1999/xlink" xl:type="v"/>');
+}, 'Check if no special handling for XLink namespace unlike HTML serializer.');
+
+</script>
  </body>
 </html>
index 8e2f4af..eadf10e 100644 (file)
@@ -1,8 +1,8 @@
 <html xmlns="http://www.w3.org/1999/xhtml">
 <head>
   <title>insertAdjacentHTML in HTML</title>
-  <script src="../../../../resources/testharness.js"></script>
-  <script src="../../../../resources/testharnessreport.js"></script>
+  <script src="/resources/testharness.js"></script>
+  <script src="/resources/testharnessreport.js"></script>
   <script src="insert_adjacent_html.js"></script>
 </head>
 <body>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any-expected.txt
new file mode 100644 (file)
index 0000000..3f78395
--- /dev/null
@@ -0,0 +1,38 @@
+
+PASS idl_test setup 
+PASS Partial interface Element: original interface defined 
+PASS Partial interface Range: original interface defined 
+PASS DOMParser interface: existence and properties of interface object 
+PASS DOMParser interface object length 
+PASS DOMParser interface object name 
+PASS DOMParser interface: existence and properties of interface prototype object 
+PASS DOMParser interface: existence and properties of interface prototype object's "constructor" property 
+PASS DOMParser interface: existence and properties of interface prototype object's @@unscopables property 
+PASS DOMParser interface: operation parseFromString(DOMString, SupportedType) 
+PASS DOMParser must be primary interface of new DOMParser() 
+PASS Stringification of new DOMParser() 
+PASS DOMParser interface: new DOMParser() must inherit property "parseFromString(DOMString, SupportedType)" with the proper type 
+PASS DOMParser interface: calling parseFromString(DOMString, SupportedType) on new DOMParser() with too few arguments must throw TypeError 
+PASS XMLSerializer interface: existence and properties of interface object 
+PASS XMLSerializer interface object length 
+PASS XMLSerializer interface object name 
+PASS XMLSerializer interface: existence and properties of interface prototype object 
+PASS XMLSerializer interface: existence and properties of interface prototype object's "constructor" property 
+PASS XMLSerializer interface: existence and properties of interface prototype object's @@unscopables property 
+PASS XMLSerializer interface: operation serializeToString(Node) 
+PASS XMLSerializer must be primary interface of new XMLSerializer() 
+PASS Stringification of new XMLSerializer() 
+PASS XMLSerializer interface: new XMLSerializer() must inherit property "serializeToString(Node)" with the proper type 
+PASS XMLSerializer interface: calling serializeToString(Node) on new XMLSerializer() with too few arguments must throw TypeError 
+PASS ShadowRoot interface: attribute innerHTML 
+PASS Element interface: attribute outerHTML 
+PASS Element interface: operation insertAdjacentHTML(DOMString, DOMString) 
+PASS Element interface: attribute innerHTML 
+PASS Element interface: document.createElement("div") must inherit property "outerHTML" with the proper type 
+PASS Element interface: document.createElement("div") must inherit property "insertAdjacentHTML(DOMString, DOMString)" with the proper type 
+PASS Element interface: calling insertAdjacentHTML(DOMString, DOMString) on document.createElement("div") with too few arguments must throw TypeError 
+PASS Element interface: document.createElement("div") must inherit property "innerHTML" with the proper type 
+PASS Range interface: operation createContextualFragment(DOMString) 
+PASS Range interface: new Range() must inherit property "createContextualFragment(DOMString)" with the proper type 
+PASS Range interface: calling createContextualFragment(DOMString) on new Range() with too few arguments must throw TypeError 
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.html b/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.js b/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.js
new file mode 100644 (file)
index 0000000..870c165
--- /dev/null
@@ -0,0 +1,19 @@
+// META: script=/resources/WebIDLParser.js
+// META: script=/resources/idlharness.js
+
+'use strict';
+
+// https://w3c.github.io/DOM-Parsing/
+
+idl_test(
+  ['DOM-Parsing'],
+  ['dom'],
+  idlArray => {
+    idlArray.add_objects({
+      DOMParser: ['new DOMParser()'],
+      Element: ['document.createElement("div")'],
+      Range: ['new Range()'],
+      XMLSerializer: ['new XMLSerializer()'],
+    })
+  }
+);
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker-expected.txt
new file mode 100644 (file)
index 0000000..14c2ed9
--- /dev/null
@@ -0,0 +1,27 @@
+
+PASS idl_test setup 
+PASS Partial interface Element: original interface defined 
+PASS Partial interface Range: original interface defined 
+PASS DOMParser interface: existence and properties of interface object 
+FAIL DOMParser must be primary interface of new DOMParser() assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: DOMParser"
+FAIL Stringification of new DOMParser() assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: DOMParser"
+FAIL DOMParser interface: new DOMParser() must not have property "parseFromString" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: DOMParser"
+PASS XMLSerializer interface: existence and properties of interface object 
+FAIL XMLSerializer must be primary interface of new XMLSerializer() assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: XMLSerializer"
+FAIL Stringification of new XMLSerializer() assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: XMLSerializer"
+FAIL XMLSerializer interface: new XMLSerializer() must not have property "serializeToString" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: XMLSerializer"
+PASS Node interface: existence and properties of interface object 
+PASS Document interface: existence and properties of interface object 
+PASS DocumentType interface: existence and properties of interface object 
+PASS DocumentFragment interface: existence and properties of interface object 
+PASS ShadowRoot interface: existence and properties of interface object 
+PASS Element interface: existence and properties of interface object 
+FAIL Element interface: document.createElement("div") must not have property "outerHTML" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: document"
+FAIL Element interface: document.createElement("div") must not have property "insertAdjacentHTML" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: document"
+FAIL Element interface: document.createElement("div") must not have property "innerHTML" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: document"
+PASS CharacterData interface: existence and properties of interface object 
+PASS Text interface: existence and properties of interface object 
+PASS AbstractRange interface: existence and properties of interface object 
+PASS Range interface: existence and properties of interface object 
+FAIL Range interface: new Range() must not have property "createContextualFragment" assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: Range"
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker.html b/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.worker.html
new file mode 100644 (file)
index 0000000..2382913
--- /dev/null
@@ -0,0 +1 @@
+<!-- This file is required for WebKit test infrastructure to run the templated test -->
\ No newline at end of file
index aba4f2e..f7f057d 100644 (file)
@@ -1,8 +1,8 @@
 <!doctype html>
 <meta charset=utf-8>
 <title>Style attribute in HTML</title>
-<script src=../../../../resources/testharness.js></script>
-<script src=../../../../resources/testharnessreport.js></script>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
 <script>
 
 var div;
index 9f8e8ac..9f7f101 100644 (file)
@@ -1,7 +1,7 @@
 The tests in this directory were imported from the W3C repository.
 Do NOT modify these tests directly in WebKit.
 Instead, create a pull request on the WPT github:
-       https://github.com/w3c/web-platform-tests
+       https://github.com/web-platform-tests/wpt
 
 Then run the Tools/Scripts/import-w3c-tests in WebKit to reimport
 
@@ -15,8 +15,12 @@ None
 ------------------------------------------------------------------------
 List of files:
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-html.html
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-doctype.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-internal-subset.html
-/LayoutTests/imported/w3c/web-platform-tests/domparsing/OWNERS
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml-parsererror.html
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/DOMParser-parseFromString-xml.html
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/META.yml
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/XMLSerializer-serializeToString.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/createContextualFragment.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-01.xhtml
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-03.xhtml
@@ -26,8 +30,12 @@ List of files:
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-07.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/innerhtml-mxss.sub.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/insert-adjacent.html
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html-xhtml.xhtml
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/insert_adjacent_html.js
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/interfaces.any.js
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/outerhtml-01.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/outerhtml-02.html
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/style_attribute_html.html
 /LayoutTests/imported/w3c/web-platform-tests/domparsing/xml-serialization.xhtml
+/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser.html
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser-expected.txt
new file mode 100644 (file)
index 0000000..c5968ee
--- /dev/null
@@ -0,0 +1,3 @@
+
+FAIL XML Dom Parse readyState Test assert_equals: expected "complete" but got "interactive"
+
diff --git a/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser.html b/LayoutTests/imported/w3c/web-platform-tests/domparsing/xmldomparser.html
new file mode 100644 (file)
index 0000000..9dac65d
--- /dev/null
@@ -0,0 +1,13 @@
+<!doctype html>
+<meta charset="utf-8">
+<title>XML Dom Parse readyState Test</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+    test(function () {
+        assert_equals(
+            (new DOMParser()).parseFromString("<html></html>", "text/xml").readyState,
+            "complete"
+        );
+    });
+</script>
diff --git a/LayoutTests/imported/w3c/web-platform-tests/interfaces/DOM-Parsing.idl b/LayoutTests/imported/w3c/web-platform-tests/interfaces/DOM-Parsing.idl
new file mode 100644 (file)
index 0000000..c5de42b
--- /dev/null
@@ -0,0 +1,39 @@
+// GENERATED CONTENT - DO NOT EDIT
+// Content was automatically extracted by Reffy into reffy-reports
+// (https://github.com/tidoust/reffy-reports)
+// Source: DOM Parsing and Serialization (https://w3c.github.io/DOM-Parsing/)
+
+[Constructor, Exposed=Window]
+interface DOMParser {
+  [NewObject] Document parseFromString(DOMString str, SupportedType type);
+};
+
+enum SupportedType {
+  "text/html",
+  "text/xml",
+  "application/xml",
+  "application/xhtml+xml",
+  "image/svg+xml"
+};
+
+[Constructor, Exposed=Window]
+
+interface XMLSerializer {
+  DOMString serializeToString(Node root);
+};
+
+interface mixin InnerHTML {
+  [CEReactions, TreatNullAs=EmptyString] attribute DOMString innerHTML;
+};
+
+Element includes InnerHTML;
+ShadowRoot includes InnerHTML;
+
+partial interface Element {
+  [CEReactions, TreatNullAs=EmptyString] attribute DOMString outerHTML;
+  [CEReactions] void insertAdjacentHTML(DOMString position, DOMString text);
+};
+
+partial interface Range {
+  [CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString fragment);
+};