summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/domparsing
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /testing/web-platform/tests/domparsing
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'testing/web-platform/tests/domparsing')
-rw-r--r--testing/web-platform/tests/domparsing/DOMParser-parseFromString-html.html74
-rw-r--r--testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml-doctype.html27
-rw-r--r--testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml.html54
-rw-r--r--testing/web-platform/tests/domparsing/OWNERS4
-rw-r--r--testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html26
-rw-r--r--testing/web-platform/tests/domparsing/createContextualFragment.html131
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-01.xhtml28
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-03.xhtml59
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-04.html24
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-05.xhtml26
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-06.html19
-rw-r--r--testing/web-platform/tests/domparsing/innerhtml-07.html49
-rw-r--r--testing/web-platform/tests/domparsing/insert-adjacent.html38
-rw-r--r--testing/web-platform/tests/domparsing/insert_adjacent_html-xhtml.xhtml91
-rw-r--r--testing/web-platform/tests/domparsing/insert_adjacent_html.html94
-rw-r--r--testing/web-platform/tests/domparsing/insert_adjacent_html.js33
-rw-r--r--testing/web-platform/tests/domparsing/outerhtml-01.html15
-rw-r--r--testing/web-platform/tests/domparsing/outerhtml-02.html54
-rw-r--r--testing/web-platform/tests/domparsing/style_attribute_html.html52
-rw-r--r--testing/web-platform/tests/domparsing/xml-serialization.xhtml91
20 files changed, 989 insertions, 0 deletions
diff --git a/testing/web-platform/tests/domparsing/DOMParser-parseFromString-html.html b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-html.html
new file mode 100644
index 000000000..ec424423a
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-html.html
@@ -0,0 +1,74 @@
+<!doctype html>
+<title>DOMParser basic test of HTML parsing</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script>
+// |expected| should be an object indicating the expected type of node.
+function assert_node(actual, expected) {
+ assert_true(actual instanceof expected.type,
+ 'Node type mismatch: actual = ' + actual.nodeType + ', expected = ' + expected.nodeType);
+ if (typeof(expected.id) !== 'undefined')
+ assert_equals(actual.id, expected.id, expected.idMessage);
+ if (typeof(expected.nodeValue) !== 'undefined')
+ assert_equals(actual.nodeValue, expected.nodeValue, expected.nodeValueMessage);
+}
+
+var doc;
+setup(function() {
+ var parser = new DOMParser();
+ var input = '<html id="root"><head></head><body></body></html>';
+ doc = parser.parseFromString(input, 'text/html');
+});
+
+test(function() {
+ var root = doc.documentElement;
+ assert_node(root, { type: HTMLHtmlElement, id: 'root',
+ idMessage: 'documentElement id attribute should be root.' });
+}, 'Parsing of id attribute');
+
+test(function() {
+ assert_equals(doc.contentType, "text/html")
+}, 'contentType');
+
+test(function() {
+ assert_equals(doc.characterSet, "UTF-8")
+}, 'characterSet');
+
+test(function() {
+ assert_equals(doc.inputEncoding, "UTF-8")
+}, 'inputEncoding');
+
+test(function() {
+ assert_equals(doc.charset, "UTF-8")
+}, 'charset');
+
+test(function() {
+ var url = document.URL;
+ assert_equals(doc.documentURI, url,
+ 'The document must have a URL value equal to the URL of the active document.');
+ assert_equals(doc.URL, url,
+ 'The document must have a URL value equal to the URL of the active document.');
+}, 'URL value');
+
+test(function() {
+ assert_equals(doc.baseURI, document.URL);
+}, 'baseURI value');
+
+test(function() {
+ assert_equals(doc.location, null,
+ 'The document must have a location value of null.');
+}, 'Location value');
+
+test(function() {
+ var soup = "<!DOCTYPE foo></><foo></multiple></>";
+ var htmldoc = new DOMParser().parseFromString(soup, "text/html");
+ assert_equals(htmldoc.documentElement.localName, "html");
+ assert_equals(htmldoc.documentElement.namespaceURI, "http://www.w3.org/1999/xhtml");
+}, "DOMParser parses HTML tag soup with no problems");
+
+test(function() {
+ assert_throws(new TypeError(), function() {
+ new DOMParser().parseFromString("", "text/foo-this-is-invalid");
+ })
+}, "DOMParser throws on an invalid enum value")
+</script>
diff --git a/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml-doctype.html b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml-doctype.html
new file mode 100644
index 000000000..cd655acf9
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml-doctype.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<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>
+<div id="log"></div>
+<script>
+ test(function () {
+ var doc = new DOMParser().parseFromString('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"><html><div id="test"/></html>', 'application/xhtml+xml');
+ var div = doc.getElementById('test');
+ assert_equals(div, null); // If null, then this was a an error document (didn't parse the input successfully)
+ }, "Doctype parsing of System Id must fail on ommitted value");
+
+ test(function () {
+ var doc = new DOMParser().parseFromString('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" ""><html><div id="test"/></html>', 'application/xhtml+xml');
+ var div = doc.getElementById('test');
+ assert_not_equals(div, null); // If found, then the DOMParser didn't generate an error document
+ }, "Doctype parsing of System Id can handle empty string");
+
+ test(function () {
+ var doc = new DOMParser().parseFromString('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "x"><html><div id="test"/></html>', 'application/xhtml+xml');
+ var div = doc.getElementById('test');
+ assert_not_equals(div, null);
+ }, "Doctype parsing of System Id can handle a quoted value");
+
+</script>
diff --git a/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml.html b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml.html
new file mode 100644
index 000000000..c639c239d
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/DOMParser-parseFromString-xml.html
@@ -0,0 +1,54 @@
+<!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>
+<div id="log"></div>
+<script>
+function checkMetadata(doc, contentType) {
+ assert_true(doc instanceof Document, "Should be Document");
+ assert_equals(doc.URL, document.URL, "URL");
+ assert_equals(doc.documentURI, document.URL, "documentURI");
+ assert_equals(doc.baseURI, document.URL, "baseURI");
+ assert_equals(doc.characterSet, "UTF-8", "characterSet");
+ assert_equals(doc.charset, "UTF-8", "charset");
+ assert_equals(doc.inputEncoding, "UTF-8", "inputEncoding");
+ assert_equals(doc.contentType, contentType, "contentType");
+ assert_equals(doc.location, null, "location");
+}
+
+var allowedTypes = ["text/xml", "application/xml", "application/xhtml+xml", "image/svg+xml"];
+
+allowedTypes.forEach(function(type) {
+ test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo/>", type);
+ assert_true(doc instanceof Document, "Should be Document");
+ checkMetadata(doc, type);
+ assert_equals(doc.documentElement.namespaceURI, null);
+ assert_equals(doc.documentElement.localName, "foo");
+ assert_equals(doc.documentElement.tagName, "foo");
+ }, "Should parse correctly in type " + type);
+
+ test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo/>", type);
+ assert_false(doc instanceof XMLDocument, "Should not be XMLDocument");
+ }, "XMLDocument interface for correctly parsed document with type " + type);
+
+ test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo>", type);
+ checkMetadata(doc, type);
+ assert_equals(doc.documentElement.namespaceURI, "http://www.mozilla.org/newlayout/xml/parsererror.xml");
+ assert_equals(doc.documentElement.localName, "parsererror");
+ assert_equals(doc.documentElement.tagName, "parsererror");
+ }, "Should return an error document for XML wellformedness errors in type " + type);
+
+ test(function() {
+ var p = new DOMParser();
+ var doc = p.parseFromString("<foo>", type);
+ assert_false(doc instanceof XMLDocument, "Should not be XMLDocument");
+ }, "XMLDocument interface for incorrectly parsed document with type " + type);
+});
+</script>
diff --git a/testing/web-platform/tests/domparsing/OWNERS b/testing/web-platform/tests/domparsing/OWNERS
new file mode 100644
index 000000000..8aeebafa5
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/OWNERS
@@ -0,0 +1,4 @@
+@sideshowbarker
+@ChrisParis
+@deniak
+@jdm
diff --git a/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html b/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html
new file mode 100644
index 000000000..60932ee37
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/XMLSerializer-serializeToString.html
@@ -0,0 +1,26 @@
+<!DOCTYPE HTML>
+<meta charset=utf-8>
+<html>
+ <head>
+ <title>domparsing Test: XMLSerializer.serializeToString</title>
+ <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>
+ </body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/createContextualFragment.html b/testing/web-platform/tests/domparsing/createContextualFragment.html
new file mode 100644
index 000000000..ce7d81358
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/createContextualFragment.html
@@ -0,0 +1,131 @@
+<!doctype html>
+<title>createContextualFragment() tests</title>
+<div id=log></div>
+<script src=/resources/testharness.js></script>
+<script src=/resources/testharnessreport.js></script>
+<script>
+// We are not testing XML documents here, because apparently it's not clear
+// what we want to happen there. We also aren't testing the HTML parser in any
+// depth, just some basic sanity checks.
+
+// Exception-throwing
+test(function() {
+ var range = document.createRange();
+ range.detach();
+ range.createContextualFragment("");
+}, "Must not throw INVALID_STATE_ERR for a detached node.");
+
+test(function() {
+ var range = document.createRange();
+ assert_throws(new TypeError(), function() {
+ range.createContextualFragment();
+ });
+}, "Must throw TypeError when calling without arguments");
+
+test(function() {
+ // Simple test
+ var range = document.createRange();
+ range.selectNodeContents(document.body);
+
+ var fragment = "<p CLaSs=testclass> Hi! <p>Hi!";
+ var expected = document.createDocumentFragment();
+ var tmpNode = document.createElement("p");
+ tmpNode.setAttribute("class", "testclass");
+ tmpNode.appendChild(document.createTextNode(" Hi! "));
+ expected.appendChild(tmpNode);
+
+ tmpNode = document.createElement("p");
+ tmpNode.appendChild(document.createTextNode("Hi!"));
+ expected.appendChild(tmpNode);
+
+ var result = range.createContextualFragment(fragment);
+ assert_true(expected.isEqualNode(result),
+ "Unexpected result (collapsed Range)");
+
+ // Token test that the end node makes no difference
+ range.setEnd(document.body.getElementsByTagName("script")[0], 0);
+ result = range.createContextualFragment(fragment);
+ assert_true(expected.isEqualNode(result),
+ "Unexpected result (Range ends in <script>)");
+}, "Simple test with paragraphs");
+
+test(function() {
+ // This test based on https://bugzilla.mozilla.org/show_bug.cgi?id=585819,
+ // from a real-world compat bug
+ var range = document.createRange();
+ range.selectNodeContents(document.documentElement);
+ var fragment = "<span>Hello world</span>";
+ var expected = document.createDocumentFragment();
+ var tmpNode = document.createElement("span");
+ tmpNode.appendChild(document.createTextNode("Hello world"));
+ expected.appendChild(tmpNode);
+
+ var result = range.createContextualFragment(fragment);
+ assert_true(expected.isEqualNode(result),
+ "Unexpected result (collapsed Range)");
+
+ // Another token test that the end node makes no difference
+ range.setEnd(document.head, 0);
+ result = range.createContextualFragment(fragment);
+ assert_true(expected.isEqualNode(result),
+ "Unexpected result (Range ends in <head>)");
+}, "Don't auto-create <body> when applied to <html>");
+
+// Scripts should be run if inserted (that's what the "Unmark all scripts
+// . . ." line means, I'm told)
+var passed = false;
+test(function() {
+ assert_false(passed, "Sanity check");
+ var range = document.createRange();
+ range.selectNodeContents(document.documentElement);
+ var fragment = range.createContextualFragment("<script>passed = true</s" + "cript>");
+ assert_false(passed, "Fragment created but not yet added to document, should not have run");
+ document.body.appendChild(fragment);
+ assert_true(passed, "Fragment created and added to document, should run");
+}, "<script>s should be run when appended to the document (but not before)");
+
+// Now that we've established basic sanity, let's do equivalence tests. Those
+// are easier to write anyway.
+function testEquivalence(element1, fragment1, element2, fragment2) {
+ var range1 = element1.ownerDocument.createRange();
+ range1.selectNodeContents(element1);
+ var range2 = element2.ownerDocument.createRange();
+ range2.selectNodeContents(element2);
+
+ var result1 = range1.createContextualFragment(fragment1);
+ var result2 = range2.createContextualFragment(fragment2);
+
+ assert_true(result1.isEqualNode(result2), "Results are supposed to be equivalent");
+
+ // Throw in partial ownerDocument tests on the side, since the algorithm
+ // does specify that and we don't want to completely not test it.
+ if (result1.firstChild != null) {
+ assert_equals(result1.firstChild.ownerDocument, element1.ownerDocument,
+ "ownerDocument must be set to that of the reference node");
+ }
+ if (result2.firstChild != null) {
+ assert_equals(result2.firstChild.ownerDocument, element2.ownerDocument,
+ "ownerDocument must be set to that of the reference node");
+ }
+}
+
+var tests = [
+ ["<html> and <body> must work the same, 1", document.documentElement, "<span>Hello world</span>", document.body, "<span>Hello world</span>"],
+ ["<html> and <body> must work the same, 2", document.documentElement, "<body><p>Hello world", document.body, "<body><p>Hello world"],
+ ["Implicit <body> creation", document.documentElement, "<body><p>", document.documentElement, "<p>"],
+ ["Namespace generally shouldn't matter",
+ document.createElementNS("http://fake-namespace", "div"), "<body><p><span>Foo",
+ document.createElement("div"), "<body><p><span>Foo"],
+ ["<html> in a different namespace shouldn't be special",
+ document.createElementNS("http://fake-namespace", "html"), "<body><p>",
+ document.createElement("div"), "<body><p>"],
+ ["null should be stringified", document.createElement("span"), null, document.createElement("span"), "null"],
+ ["undefined should be stringified", document.createElement("span"), undefined, document.createElement("span"), "undefined"]/*,
+ // FIXME: Spec doesn't say what to do about non-Elements!
+ ["Text nodes?",
+ document.createTextNode("?"), "<span>",
+ document.createTextNode("?"), "<span>"]*/
+];
+
+generate_tests(testEquivalence, tests);
+</script>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-01.xhtml b/testing/web-platform/tests/domparsing/innerhtml-01.xhtml
new file mode 100644
index 000000000..432cfbf41
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-01.xhtml
@@ -0,0 +1,28 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>innerHTML in XHTML: getting while the document is in an invalid state</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
+<link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML"/>
+<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
+<link rel="help" href="http://www.whatwg.org/html5/#document.title"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script>
+test(function() {
+ document.documentElement.appendChild(document.createElement("test:test"));
+ assert_throws("INVALID_STATE_ERR", function() {
+ document.documentElement.innerHTML;
+ }, "getting element with \":\" in its local name");
+});
+test(function() {
+ document.title = "\f";
+ assert_throws("INVALID_STATE_ERR", function() {
+ document.getElementsByTagName("title")[0].innerHTML;
+ }, "Getting a Text node whose data contains characters that are not matched by the XML Char production");
+});
+</script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-03.xhtml b/testing/web-platform/tests/domparsing/innerhtml-03.xhtml
new file mode 100644
index 000000000..313531e49
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-03.xhtml
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>innerHTML in XHTML</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
+<link rel="help" href="http://html5.org/specs/dom-parsing.html#dom-innerhtml"/>
+<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script><![CDATA[
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createElement("xmp"))
+ .appendChild(document.createElement("span"))
+ .appendChild(document.createTextNode("<"));
+ assert_equals(el.innerHTML, "<xmp xmlns=\"http://www.w3.org/1999/xhtml\"><span>&lt;<\/span><\/xmp>");
+})
+test(function() {
+ var el = document.createElement("xmp");
+ el.appendChild(document.createElement("span"))
+ .appendChild(document.createTextNode("<"));
+ assert_equals(el.innerHTML, "<span xmlns=\"http://www.w3.org/1999/xhtml\">&lt;<\/span>");
+})
+test(function() {
+ var el = document.createElement("xmp");
+ el.appendChild(document.createTextNode("<"));
+ assert_equals(el.innerHTML, "&lt;");
+})
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createElement("br"));
+ assert_equals(el.innerHTML, "<br xmlns=\"http://www.w3.org/1999/xhtml\" />");
+})
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createElementNS("http://www.w3.org/1999/xhtml", "html:br"));
+ assert_equals(el.innerHTML, "<html:br xmlns:html=\"http://www.w3.org/1999/xhtml\" />");
+})
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createTextNode("<>\"'&"));
+ assert_equals(el.innerHTML, "&lt;&gt;\"'&amp;");
+})
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createTextNode("&lt;&gt;&quot;&apos;&amp;"));
+ assert_equals(el.innerHTML, "&amp;lt;&amp;gt;&amp;quot;&amp;apos;&amp;amp;");
+})
+test(function() {
+ var el = document.createElement("div");
+ el.appendChild(document.createTextNode("àו…\u00A0"));
+ assert_equals(el.innerHTML, "àו…\u00A0");
+})
+]]></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-04.html b/testing/web-platform/tests/domparsing/innerhtml-04.html
new file mode 100644
index 000000000..32c921d23
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-04.html
@@ -0,0 +1,24 @@
+<!DOCTYPE html>
+<title>innerHTML in HTML</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-innerHTML">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+function testIsChild(p, c) {
+ assert_equals(p.firstChild, c);
+ assert_equals(c.parentNode, p);
+}
+test(function() {
+ var p = document.createElement('p');
+ var b = p.appendChild(document.createElement('b'));
+ var t = b.appendChild(document.createTextNode("foo"));
+ testIsChild(p, b);
+ testIsChild(b, t);
+ assert_equals(t.data, "foo");
+ p.innerHTML = "";
+ testIsChild(b, t);
+ assert_equals(t.data, "foo");
+}, "innerHTML should leave the removed children alone.")
+</script>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-05.xhtml b/testing/web-platform/tests/domparsing/innerhtml-05.xhtml
new file mode 100644
index 000000000..da2d85159
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-05.xhtml
@@ -0,0 +1,26 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+<title>innerHTML in XHTML</title>
+<link rel="author" title="Simon Pieters" href="mailto:simonp@opera.com"/>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com"/>
+<link rel="help" href="http://html5.org/specs/dom-parsing.html#dom-innerhtml"/>
+<link rel="help" href="http://www.whatwg.org/html5/#xml-fragment-serialization-algorithm"/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<iframe src="data:text/xml,&lt;html xmlns='http://www.w3.org/1999/xhtml'>&lt;foo--/>&lt;/html>"></iframe>
+<script><![CDATA[
+var t = async_test();
+window.onload = t.step_func(function() {
+ var foo = window[0].document.documentElement.firstChild;
+ assert_throws('SyntaxError', function() {
+ foo.innerHTML = 'x<\/foo--><\!--y';
+ // This is ridiculous.
+ });
+ t.done();
+});
+]]></script>
+</body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-06.html b/testing/web-platform/tests/domparsing/innerhtml-06.html
new file mode 100644
index 000000000..81e9c57b5
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-06.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<title>math in html: innerHTML</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<h1>math in html: innerHTML</h1>
+<div id="log"></div>
+<div style="display:none">
+<div id="d1"><math><mi>x</mi></math></div>
+</div>
+<script>
+test(function() {
+ var math = document.getElementById("d1").firstChild;
+ assert_equals(math.innerHTML, "<mi>x</mi>");
+},"innerHTML defined on math.");
+</script>
diff --git a/testing/web-platform/tests/domparsing/innerhtml-07.html b/testing/web-platform/tests/domparsing/innerhtml-07.html
new file mode 100644
index 000000000..9e313a2cb
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/innerhtml-07.html
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<title>innerHTML and string conversion</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var p = document.createElement("p");
+ p.innerHTML = null;
+ assert_equals(p.innerHTML, "");
+ assert_equals(p.textContent, "");
+}, "innerHTML and string conversion: null.")
+
+test(function() {
+ var p = document.createElement("p");
+ p.innerHTML = undefined;
+ assert_equals(p.innerHTML, "undefined");
+ assert_equals(p.textContent, "undefined");
+}, "innerHTML and string conversion: undefined.")
+
+test(function() {
+ var p = document.createElement("p");
+ p.innerHTML = 42;
+ assert_equals(p.innerHTML, "42");
+ assert_equals(p.textContent, "42");
+}, "innerHTML and string conversion: number.")
+
+test(function() {
+ var p = document.createElement("p");
+ p.innerHTML = {
+ toString: function() { return "pass"; },
+ valueOf: function() { return "fail"; }
+ };
+ assert_equals(p.innerHTML, "pass");
+ assert_equals(p.textContent, "pass");
+}, "innerHTML and string conversion: toString.")
+
+test(function() {
+ var p = document.createElement("p");
+ p.innerHTML = {
+ toString: undefined,
+ valueOf: function() { return "pass"; }
+ };
+ assert_equals(p.innerHTML, "pass");
+ assert_equals(p.textContent, "pass");
+}, "innerHTML and string conversion: valueOf.")
+</script>
diff --git a/testing/web-platform/tests/domparsing/insert-adjacent.html b/testing/web-platform/tests/domparsing/insert-adjacent.html
new file mode 100644
index 000000000..f43ec406e
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/insert-adjacent.html
@@ -0,0 +1,38 @@
+<!doctype html>
+<title>insertAdjacentHTML</title>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<style>
+#element {
+ display: none;
+}
+</style>
+
+<div id="element"></div>
+<div id="log"></div>
+
+<script>
+function wrap(text) {
+ return '<h3>' + text + '</h3>';
+}
+
+var possiblePositions = {
+ 'beforebegin': 'previousSibling'
+ , 'afterbegin': 'firstChild'
+ , 'beforeend': 'lastChild'
+ , 'afterend': 'nextSibling'
+}
+
+var el = document.querySelector('#element');
+
+Object.keys(possiblePositions).forEach(function(position) {
+ var html = wrap(position);
+ test(function() {
+ el.insertAdjacentHTML(position, html);
+ var heading = document.createElement('h3');
+ heading.innerHTML = position;
+ assert_equals(el[possiblePositions[position]].nodeName, "H3");
+ assert_equals(el[possiblePositions[position]].firstChild.nodeType, Node.TEXT_NODE);
+ }, 'insertAdjacentHTML(' + position + ', ' + html + ' )');
+});
+</script>
diff --git a/testing/web-platform/tests/domparsing/insert_adjacent_html-xhtml.xhtml b/testing/web-platform/tests/domparsing/insert_adjacent_html-xhtml.xhtml
new file mode 100644
index 000000000..eadf10e2c
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/insert_adjacent_html-xhtml.xhtml
@@ -0,0 +1,91 @@
+<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="insert_adjacent_html.js"></script>
+</head>
+<body>
+<p id="display"></p><div id="content" style="display: none"></div><div id="content2" style="display: none"></div>
+<script><![CDATA[
+var script_ran = false;
+
+function testPositions(node, testDesc) {
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("beforeBegin", "\u003Cscript>script_ran = true;\u003C/script><i></i>");
+ assert_equals(node.previousSibling.localName, "i", "Should have had <i> as previous sibling");
+ assert_equals(node.previousSibling.previousSibling.localName, "script", "Should have had <script> as second previous child");
+ assert_false(script_ran, "script should not have run");
+ }, "beforeBegin " + node.id + " " + testDesc)
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("Afterbegin", "<b></b>\u003Cscript>script_ran = true;\u003C/script>");
+ assert_equals(node.firstChild.localName, "b", "Should have had <b> as first child");
+ assert_equals(node.firstChild.nextSibling.localName, "script", "Should have had <script> as second child");
+ assert_false(script_ran, "script should not have run");
+ }, "Afterbegin " + node.id + " " + testDesc);
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>script_ran = true;\u003C/script><u></u>");
+ assert_equals(node.lastChild.localName, "u", "Should have had <u> as last child");
+ assert_equals(node.lastChild.previousSibling.localName, "script", "Should have had <script> as penultimate child");
+ assert_false(script_ran, "script should not have run");
+ }, "BeforeEnd " + node.id + " " + testDesc)
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("afterend", "<a></a>\u003Cscript>script_ran = true;\u003C/script>");
+ assert_equals(node.nextSibling.localName, "a", "Should have had <a> as next sibling");
+ assert_equals(node.nextSibling.nextSibling.localName, "script", "Should have had <script> as second next sibling");
+ assert_false(script_ran, "script should not have run");
+ }, "afterend " + node.id + " " + testDesc)
+}
+
+var content = document.getElementById("content");
+testPositions(content, "without next sibling");
+testPositions(content, "again, with next sibling");
+
+test(function() {
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("bar", "foo")});
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegİn", "foo")});
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegın", "foo")});
+}, "Should throw when inserting with invalid position string");
+
+var parentElement = document.createElement("div");
+var child = document.createElement("div");
+child.id = "child";
+
+testThrowingNoParent(child, "null");
+testThrowingNoParent(document.documentElement, "a document");
+
+test(function() {
+ child.insertAdjacentHTML("afterBegin", "foo");
+ child.insertAdjacentHTML("beforeend", "bar");
+ assert_equals(child.textContent, "foobar");
+ parentElement.appendChild(child);
+}, "Inserting after being and before end should order things correctly");
+
+testPositions(child, "node not in tree but has parent");
+
+test(function() {
+ script_ran = false;
+ content.appendChild(parentElement); // must not run scripts
+ assert_false(script_ran, "script should not have run");
+}, "Should not run script when appending things which have descendant <script> inserted via insertAdjacentHTML");
+
+var content2 = document.getElementById("content2");
+testPositions(content2, "without next sibling");
+testPositions(content2, "test again, now that there's a next sibling");
+
+// XML-only:
+test(function() {
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforeend", "<p>")});
+});
+
+]]></script>
+<div id="log"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/insert_adjacent_html.html b/testing/web-platform/tests/domparsing/insert_adjacent_html.html
new file mode 100644
index 000000000..dfe624f03
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/insert_adjacent_html.html
@@ -0,0 +1,94 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+ <title>insertAdjacentHTML in HTML</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="insert_adjacent_html.js"></script>
+</head>
+<body>
+<p id="display"></p><div id="content" style="display: none"></div><div id="content2" style="display: none"></div>
+<script>
+var script_ran = false;
+
+function testPositions(node, testDesc) {
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("beforeBegin", "\u003Cscript>script_ran = true;\u003C/script><i></i>");
+ assert_equals(node.previousSibling.localName, "i", "Should have had <i> as previous sibling");
+ assert_equals(node.previousSibling.previousSibling.localName, "script", "Should have had <script> as second previous child");
+ assert_false(script_ran, "script should not have run");
+ }, "beforeBegin " + node.id + " " + testDesc)
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("Afterbegin", "<b></b>\u003Cscript>script_ran = true;\u003C/script>");
+ assert_equals(node.firstChild.localName, "b", "Should have had <b> as first child");
+ assert_equals(node.firstChild.nextSibling.localName, "script", "Should have had <script> as second child");
+ assert_false(script_ran, "script should not have run");
+ }, "Afterbegin " + node.id + " " + testDesc);
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("BeforeEnd", "\u003Cscript>script_ran = true;\u003C/script><u></u>");
+ assert_equals(node.lastChild.localName, "u", "Should have had <u> as last child");
+ assert_equals(node.lastChild.previousSibling.localName, "script", "Should have had <script> as penultimate child");
+ assert_false(script_ran, "script should not have run");
+ }, "BeforeEnd " + node.id + " " + testDesc)
+
+ test(function() {
+ script_ran = false;
+ node.insertAdjacentHTML("afterend", "<a></a>\u003Cscript>script_ran = true;\u003C/script>");
+ assert_equals(node.nextSibling.localName, "a", "Should have had <a> as next sibling");
+ assert_equals(node.nextSibling.nextSibling.localName, "script", "Should have had <script> as second next sibling");
+ assert_false(script_ran, "script should not have run");
+ }, "afterend " + node.id + " " + testDesc)
+}
+
+var content = document.getElementById("content");
+testPositions(content, "without next sibling");
+testPositions(content, "again, with next sibling");
+
+test(function() {
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("bar", "foo")});
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegİn", "foo")});
+ assert_throws("SYNTAX_ERR", function() {content.insertAdjacentHTML("beforebegın", "foo")});
+}, "Should throw when inserting with invalid position string");
+
+var parentElement = document.createElement("div");
+var child = document.createElement("div");
+child.id = "child";
+
+testThrowingNoParent(child, "null");
+testThrowingNoParent(document.documentElement, "a document");
+
+test(function() {
+ child.insertAdjacentHTML("afterBegin", "foo");
+ child.insertAdjacentHTML("beforeend", "bar");
+ assert_equals(child.textContent, "foobar");
+ parentElement.appendChild(child);
+}, "Inserting after being and before end should order things correctly");
+
+testPositions(child, "node not in tree but has parent");
+
+test(function() {
+ script_ran = false;
+ content.appendChild(parentElement); // must not run scripts
+ assert_false(script_ran, "script should not have run");
+}, "Should not run script when appending things which have descendant <script> inserted via insertAdjacentHTML");
+
+var content2 = document.getElementById("content2");
+testPositions(content2, "without next sibling");
+testPositions(content2, "test again, now that there's a next sibling");
+
+// HTML only
+test(function() {
+ document.body.insertAdjacentHTML("afterend", "<p>");
+ document.head.insertAdjacentHTML("beforebegin", "<p>");
+ assert_equals(document.getElementsByTagName("head").length, 1, "Should still have one head");
+ assert_equals(document.getElementsByTagName("body").length, 1, "Should still have one body");
+}, "Inserting kids of the <html> element should not do weird things with implied <body>/<head> tags")
+</script>
+<div id="log"></div>
+</body>
+</html>
diff --git a/testing/web-platform/tests/domparsing/insert_adjacent_html.js b/testing/web-platform/tests/domparsing/insert_adjacent_html.js
new file mode 100644
index 000000000..2451228d1
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/insert_adjacent_html.js
@@ -0,0 +1,33 @@
+function testThrowingNoParent(element, desc) {
+ test(function() {
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("afterend", "") }
+ );
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("beforebegin", "") }
+ );
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("afterend", "foo") }
+ );
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("beforebegin", "foo") }
+ );
+ }, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (text)");
+ test(function() {
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("afterend", "<!-- fail -->") }
+ );
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("beforebegin", "<!-- fail -->") }
+ );
+ }, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (comments)");
+ test(function() {
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("afterend", "<div></div>") }
+ );
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR",
+ function() { element.insertAdjacentHTML("beforebegin", "<div></div>") }
+ );
+ }, "When the parent node is " + desc + ", insertAdjacentHTML should throw for beforebegin and afterend (elements)");
+}
+
diff --git a/testing/web-platform/tests/domparsing/outerhtml-01.html b/testing/web-platform/tests/domparsing/outerhtml-01.html
new file mode 100644
index 000000000..2e8072e49
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/outerhtml-01.html
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<title>outerHTML: child of #document</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="http://html5.org/specs/dom-parsing.html#outerhtml">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ assert_throws("NO_MODIFICATION_ALLOWED_ERR", function() {
+ document.documentElement.outerHTML = "<html><p>FAIL: Should have thrown an error<\/p><\/html>";
+ })
+});
+</script>
+
diff --git a/testing/web-platform/tests/domparsing/outerhtml-02.html b/testing/web-platform/tests/domparsing/outerhtml-02.html
new file mode 100644
index 000000000..7b69fbf67
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/outerhtml-02.html
@@ -0,0 +1,54 @@
+<!DOCTYPE html>
+<title>outerHTML and string conversion</title>
+<link rel="author" title="Ms2ger" href="mailto:ms2ger@gmail.com">
+<link rel="help" href="http://domparsing.spec.whatwg.org/#extensions-to-the-element-interface">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<div id="log"></div>
+<script>
+test(function() {
+ var div = document.createElement("div");
+ var p = div.appendChild(document.createElement("p"));
+ p.outerHTML = null;
+ assert_equals(div.innerHTML, "");
+ assert_equals(div.textContent, "");
+}, "outerHTML and string conversion: null.")
+
+test(function() {
+ var div = document.createElement("div");
+ var p = div.appendChild(document.createElement("p"));
+ p.outerHTML = undefined;
+ assert_equals(div.innerHTML, "undefined");
+ assert_equals(div.textContent, "undefined");
+}, "outerHTML and string conversion: undefined.")
+
+test(function() {
+ var div = document.createElement("div");
+ var p = div.appendChild(document.createElement("p"));
+ p.outerHTML = 42;
+ assert_equals(div.innerHTML, "42");
+ assert_equals(div.textContent, "42");
+}, "outerHTML and string conversion: number.")
+
+test(function() {
+ var div = document.createElement("div");
+ var p = div.appendChild(document.createElement("p"));
+ p.outerHTML = {
+ toString: function() { return "pass"; },
+ valueOf: function() { return "fail"; }
+ };
+ assert_equals(div.innerHTML, "pass");
+ assert_equals(div.textContent, "pass");
+}, "outerHTML and string conversion: toString.")
+
+test(function() {
+ var div = document.createElement("div");
+ var p = div.appendChild(document.createElement("p"));
+ p.outerHTML = {
+ toString: undefined,
+ valueOf: function() { return "pass"; }
+ };
+ assert_equals(div.innerHTML, "pass");
+ assert_equals(div.textContent, "pass");
+}, "outerHTML and string conversion: valueOf.")
+</script>
diff --git a/testing/web-platform/tests/domparsing/style_attribute_html.html b/testing/web-platform/tests/domparsing/style_attribute_html.html
new file mode 100644
index 000000000..f7f057d2d
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/style_attribute_html.html
@@ -0,0 +1,52 @@
+<!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>
+
+var div;
+setup(function() {
+ var input = '<div style="color: red">Foo</div>';
+ var doc = (new DOMParser()).parseFromString(input, 'text/html');
+ div = doc.querySelector('div');
+});
+
+test(function() {
+ var style = div.style;
+ assert_equals(style.cssText, 'color: red;');
+ assert_equals(style.color, 'red');
+ assert_equals(div.getAttribute("style"), 'color: red',
+ 'Value of style attribute should match the string value that was set');
+}, 'Parsing of initial style attribute');
+
+test(function() {
+ var style = div.style;
+ div.setAttribute('style', 'color:: invalid');
+ assert_equals(style.cssText, '');
+ assert_equals(style.color, '');
+ assert_equals(div.getAttribute('style'), 'color:: invalid',
+ 'Value of style attribute should match the string value that was set');
+}, 'Parsing of invalid style attribute');
+
+test(function() {
+ var style = div.style;
+ div.setAttribute('style', 'color: green');
+ assert_equals(style.cssText, 'color: green;');
+ assert_equals(style.color, 'green');
+ assert_equals(div.getAttribute('style'), 'color: green',
+ 'Value of style attribute should match the string value that was set');
+}, 'Parsing of style attribute');
+
+test(function() {
+ var style = div.style;
+ style.backgroundColor = 'blue';
+ assert_equals(style.cssText, 'color: green; background-color: blue;',
+ 'Should not drop the existing style');
+ assert_equals(style.color, 'green',
+ 'Should not drop the existing style');
+ assert_equals(div.getAttribute('style'), 'color: green; background-color: blue;',
+ 'Should update style attribute');
+}, 'Update style.backgroundColor');
+
+</script>
diff --git a/testing/web-platform/tests/domparsing/xml-serialization.xhtml b/testing/web-platform/tests/domparsing/xml-serialization.xhtml
new file mode 100644
index 000000000..678523d1e
--- /dev/null
+++ b/testing/web-platform/tests/domparsing/xml-serialization.xhtml
@@ -0,0 +1,91 @@
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>XML serialization</title>
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+<div id="log"></div>
+<script><![CDATA[
+function serialize(node) {
+ var serializer = new XMLSerializer();
+ return serializer.serializeToString(node);
+}
+
+test(function() {
+ var dt = document.createComment("--");
+ assert_equals(serialize(dt), '<!------>');
+}, "Comment: containing --");
+
+test(function() {
+ var dt = document.createComment("- x");
+ assert_equals(serialize(dt), '<!--- x-->');
+}, "Comment: starting with -");
+
+test(function() {
+ var dt = document.createComment("x -");
+ assert_equals(serialize(dt), '<!--x --->');
+}, "Comment: ending with -");
+
+test(function() {
+ var dt = document.createComment("-->");
+ assert_equals(serialize(dt), '<!---->-->');
+}, "Comment: containing -->");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", "", "");
+ assert_equals(serialize(dt), '<!DOCTYPE html>');
+}, "DocumentType: empty public and system id");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", "a", "");
+ assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC "a">');
+}, "DocumentType: empty system id");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", "", "a");
+ assert_equals(serialize(dt), '<!DOCTYPE html SYSTEM "a">');
+}, "DocumentType: empty public id");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", "a", "b");
+ assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC "a" "b">');
+}, "DocumentType: non-empty public and system id");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", "'", "'");
+ assert_equals(serialize(dt), "<!DOCTYPE html PUBLIC \"'\" \"'\">");
+}, "DocumentType: 'APOSTROPHE' (U+0027)");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", '"', '"');
+ assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC """ """>');
+}, "DocumentType: 'QUOTATION MARK' (U+0022)");
+
+test(function() {
+ var dt = document.implementation.createDocumentType("html", '"\'', '\'"');
+ assert_equals(serialize(dt), '<!DOCTYPE html PUBLIC ""\'" "\'"">');
+}, "DocumentType: 'APOSTROPHE' (U+0027) and 'QUOTATION MARK' (U+0022)");
+
+test(function() {
+ var pi = document.createProcessingInstruction("a", "");
+ assert_equals(serialize(pi), "<?a ?>");
+}, "ProcessingInstruction: empty data");
+
+test(function() {
+ var pi = document.createProcessingInstruction("a", "b");
+ assert_equals(serialize(pi), "<?a b?>");
+}, "ProcessingInstruction: non-empty data");
+
+test(function() {
+ var pi = document.createProcessingInstruction("xml", "b");
+ assert_equals(serialize(pi), "<?xml b?>");
+}, "ProcessingInstruction: target contains xml");
+
+test(function() {
+ var pi = document.createProcessingInstruction("x:y", "b");
+ assert_equals(serialize(pi), "<?x:y b?>");
+}, "ProcessingInstruction: target contains a 'COLON' (U+003A)");
+]]></script>
+</body>
+</html>