outerHTML.html (1622B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>HTML Test: element.outerHTML to verify XML fragment serialization algorithm</title> 5 <link rel="author" title="Intel" href="http://www.intel.com/"> 6 <link rel="help" href="https://w3c.github.io/DOM-Parsing/#dfn-concept-serialize-xml"> 7 <link rel="help" href="https://w3c.github.io/DOM-Parsing/#widl-Element-outerHTML"> 8 <script src="/resources/testharness.js"></script> 9 <script src="/resources/testharnessreport.js"></script> 10 <script src="../../resources/common.js"></script> 11 </head> 12 <body> 13 <div id="log"></div> 14 <script> 15 test(function() { 16 var doc = document.implementation.createDocument(null, ""); 17 assert_equals(doc.contentType, "application/xml"); 18 var html_ns = "http://www.w3.org/1999/xhtml"; 19 const non_void_elements = HTML5_ELEMENTS.filter(el => !HTML5_VOID_ELEMENTS.includes(el)); 20 non_void_elements.forEach(function(ele) { 21 test(function() { 22 var e = doc.createElementNS(html_ns, ele); 23 assert_equals(e.outerHTML, 24 `<${ele} xmlns="${html_ns}"></${ele}>`, 25 ele + " node created." ); 26 }, "Node for " + ele); 27 }); 28 HTML5_VOID_ELEMENTS.forEach(function(ele) { 29 test(function() { 30 var e = doc.createElementNS(html_ns, ele); 31 assert_equals(e.outerHTML, 32 `<${ele} xmlns="${html_ns}" />`, 33 ele + " node created." ); 34 }, "Node for " + ele); 35 }); 36 }, document.title); 37 </script> 38 </body> 39 </html>