Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-xml.html - WPT Dashboard Interop Dashboard
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
test(() => {
const xmlDoc = document.implementation.createDocument(null, 'root', null);
assert_equals(xmlDoc.contentType, 'application/xml');
// Intentionally unclosed and misnested tags
xmlDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
assert_equals(xmlDoc.documentElement.innerHTML,
'Element.setHTMLUnsafe should use the HTML parser in XML documents.');
}, 'setHTMLUnsafe should still parse HTML even in XML documents.');
test(() => {
assert_equals(svgDoc.contentType, 'image/svg+xml');
// Intentionally unclosed and misnested tags
svgDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
assert_equals(svgDoc.documentElement.innerHTML,
'Element.setHTMLUnsafe should use the HTML parser in SVG documents.');
}, 'setHTMLUnsafe should still parse HTML even in SVG documents.');
</script>