Automatic update from web-platform-tests Test serialization of processing instructions in HTML For https://github.com/whatwg/html/pull/12654. Co-authored-by: Jon Surrell <sirreal@users.noreply.github.com> -- wpt-commits: 982cb52d1f024036bfe8722ee63e9ad869b5db24 wpt-pr: 57486
30 lines
1.0 KiB
HTML
30 lines
1.0 KiB
HTML
<!DOCTYPE html>
|
|
<title>ProcessingInstruction serialization in HTML</title>
|
|
<script src="/resources/testharness.js"></script>
|
|
<script src="/resources/testharnessreport.js"></script>
|
|
<script>
|
|
test(function() {
|
|
const pi = document.createProcessingInstruction("target", "");
|
|
const div = document.createElement("div");
|
|
div.appendChild(pi);
|
|
// There's a space because the spec does not special-case empty data.
|
|
assert_equals(div.innerHTML, "<?target ?>");
|
|
}, "PI with empty data");
|
|
|
|
test(function() {
|
|
const pi = document.createProcessingInstruction("target", "data");
|
|
const div = document.createElement("div");
|
|
div.appendChild(pi);
|
|
assert_equals(div.innerHTML, "<?target data?>");
|
|
}, "PI with non-empty data");
|
|
|
|
test(function() {
|
|
const parser = new DOMParser();
|
|
const xmlDoc = parser.parseFromString("<root><?target data?></root>", "text/xml");
|
|
const pi = xmlDoc.documentElement.firstChild;
|
|
const div = document.createElement("div");
|
|
div.appendChild(pi);
|
|
assert_equals(div.innerHTML, "<?target data?>");
|
|
}, "PI adopted from XML document");
|
|
</script>
|