Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /xml/xml-innerHTML-unpaired-surrogate.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<meta charset="utf-8">
<title>Unpaired surrogate in XML innerHTML is not well-formed</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
function xhtml_document() {
return (new DOMParser()).parseFromString(
"application/xhtml+xml"
);
}
test(function() {
let doc = xhtml_document();
assert_throws_dom("SyntaxError", () => {
doc.documentElement.innerHTML = "\uD800";
});
}, "Lone high surrogate in XML innerHTML throws a SyntaxError");
test(function() {
let doc = xhtml_document();
doc.documentElement.innerHTML = "\uD83D\uDD25";
assert_equals(doc.documentElement.textContent, "\uD83D\uDD25");
}, "Valid surrogate pair in XML innerHTML is preserved");
</script>