dynamic-math-tree-001.html (1907B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1173199 5 --> 6 <head> 7 <script src="/resources/testharness.js"></script> 8 <script src="/resources/testharnessreport.js"></script> 9 </head> 10 <body> 11 <div id="testnodes"><span>hi</span> there <!-- mon ami --></div> 12 <script type="application/javascript"> 13 const mathmlNS = "http://www.w3.org/1998/Math/MathML"; 14 let t = document.getElementById('testnodes'); 15 16 test(function() { 17 t.innerHTML = null; 18 t.appendChild(document.createElementNS(mathmlNS, "math:math")); 19 assert_equals(t.firstChild.namespaceURI, mathmlNS); 20 t.firstChild.textContent = "<foo>"; 21 assert_equals(t.innerHTML, "<math:math><foo></math:math>"); 22 }, "Writing '<foo>' element in a dynamically created MathML element."); 23 24 test(function() { 25 t.innerHTML = null; 26 t.appendChild(document.createElementNS(mathmlNS, "math")); 27 assert_equals(t.firstChild.namespaceURI, mathmlNS); 28 t.firstChild.appendChild(document.createElementNS(mathmlNS, "script")); 29 assert_equals(t.firstChild.firstChild.namespaceURI, mathmlNS); 30 t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 31 assert_equals(t.innerHTML, 32 '<math><script>1&2<3>4 \u003C/script></math>'); 33 }, "Writing '<script>' element in a dynamically created MathML element."); 34 35 test(function() { 36 t.innerHTML = null; 37 t.appendChild(document.createElementNS(mathmlNS, "math")); 38 assert_equals(t.firstChild.namespaceURI, mathmlNS); 39 t.firstChild.appendChild(document.createElementNS(mathmlNS, "style")); 40 assert_equals(t.firstChild.firstChild.namespaceURI, mathmlNS); 41 t.firstChild.firstChild.textContent = "1&2<3>4\xA0"; 42 assert_equals(t.innerHTML, 43 '<math><style>1&2<3>4 \u003C/style></math>'); 44 }, "Writing '<style>' element in a dynamically created MathML element."); 45 </script> 46 </body> 47 </html>