tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

setHTMLUnsafe-xml.html (1355B)


      1 <!DOCTYPE html>
      2 <link rel=author href="mailto:jarhar@chromium.org">
      3 <link rel=help href="https://github.com/whatwg/html/pull/9538">
      4 <script src="/resources/testharness.js"></script>
      5 <script src="/resources/testharnessreport.js"></script>
      6 
      7 <script>
      8 test(() => {
      9  const xmlDoc = document.implementation.createDocument(null, 'root', null);
     10  assert_equals(xmlDoc.contentType, 'application/xml');
     11  // Intentionally unclosed and misnested tags
     12  xmlDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
     13  assert_equals(xmlDoc.documentElement.innerHTML,
     14    '<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
     15    'Element.setHTMLUnsafe should use the HTML parser in XML documents.');
     16 }, 'setHTMLUnsafe should still parse HTML even in XML documents.');
     17 
     18 test(() => {
     19  const svgDoc = document.implementation.createDocument('http://www.w3.org/2000/svg', 'root', null);
     20  assert_equals(svgDoc.contentType, 'image/svg+xml');
     21  // Intentionally unclosed and misnested tags
     22  svgDoc.documentElement.setHTMLUnsafe('<p><foo><b><i>test</b></i>');
     23  assert_equals(svgDoc.documentElement.innerHTML,
     24    '<p xmlns="http://www.w3.org/1999/xhtml"><foo><b><i>test</i></b></foo></p>',
     25    'Element.setHTMLUnsafe should use the HTML parser in SVG documents.');
     26 }, 'setHTMLUnsafe should still parse HTML even in SVG documents.');
     27 </script>