summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/webappapis/dynamic-markup-insertion/html-unsafe-methods/setHTMLUnsafe-xml.html
blob: d7211e97f1e2eaa25005cb3d7185fd459b5247a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<!DOCTYPE html>
<link rel=author href="mailto:jarhar@chromium.org">
<link rel=help href="https://github.com/whatwg/html/pull/9538">
<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,
    '<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
    'Element.setHTMLUnsafe should use the HTML parser in XML documents.');
}, 'setHTMLUnsafe should still parse HTML even in XML documents.');

test(() => {
  const svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'root', null);
  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,
    '<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
    'Element.setHTMLUnsafe should use the HTML parser in SVG documents.');
}, 'setHTMLUnsafe should still parse HTML even in SVG documents.');
</script>