math-parse03.html (6657B)
1 <!DOCTYPE html> 2 <html> 3 <head> 4 <title>math in html: parsing</title> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 </head> 8 <body> 9 <h1>math in html: parsing</h1> 10 11 <div id="log"></div> 12 13 <div> 14 <div><MATH id="m1"><Mtext/></math></div> 15 <div id="d1"><math><MI MATHVARIANT="BOLD" /></math></div> 16 <div id="d2"><math><semantics DEFINITIONurl="www.example.org/FOO"><mi>a</mi><annotation-xml><foo/><bar/></annotation-xml></semantics></math></div> 17 <div><math id="m3span-mtext"><mtext><Span>x</Span></mtext></math></div> 18 <div><math id="m3span-mi"><mi><Span>x</Span></mi></math></div> 19 <div><math id="m3span-mrow"><mi><Span>x</Span></mrow></math></div> 20 <div><math id="m3p-mtext"><mtext><P>x</P></mtext></math></div> 21 <div><math id="m3p-mi"><mi><P>x</P></mi></math></div> 22 <div id="d3p-mrow"><math><mrow><P>x</P><mi>y</mi></mrow></math></div> 23 <div><math id="m4"><mtext><Undefinedelement>x</Undefinedelement></mtext></math></div> 24 <div><math id="m5"><mtext><mi>x</mi></mtext></math></div> 25 <div><math><semantics><mi>x</mi> 26 <annotation-xml><p id="p6default">x</p></annotation-xml> 27 </semantics></math></div> 28 <div><math><semantics><mi>x</mi> 29 <annotation-xml encoding=text/html><p id="p6texthtml">x</p></annotation-xml> 30 </semantics></math></div> 31 <div><math><semantics><mi>x</mi> 32 <annotation-xml encoding=TEXT/HTML><p id="p6uctexthtml">x</p></annotation-xml> 33 </semantics></math></div> 34 <div><math><semantics><mi>x</mi> 35 <annotation-xml encoding=application/xhtml+xml><p id="p6applicationxhtmlxml">x</p></annotation-xml> 36 </semantics></math></div> 37 <div><math><semantics><mi>x</mi> 38 <annotation-xml encoding=foo><p id="p6foo">x</p></annotation-xml> 39 </semantics></math></div> 40 </div> 41 <script> 42 test(function() { 43 assert_equals(document.getElementById("m1"),document.getElementsByTagName("math")[0]); 44 },"MATH element name should be lowercased"); 45 46 test(function() { 47 assert_equals(document.getElementById("d1").firstChild.firstChild.nodeName,"mi"); 48 assert_equals(document.getElementById("d1").firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML"); 49 assert_true(document.getElementById("d1").firstChild.firstChild.hasAttribute("mathvariant")); 50 assert_equals(document.getElementById("d1").firstChild.firstChild.getAttribute("mathvariant"),"BOLD") 51 },"MI element name and mathvariant attribute name should be lowercased, attribute value unchanged"); 52 53 test(function() { 54 assert_true(document.getElementById("d2").firstChild.firstChild.hasAttribute("definitionURL")); 55 assert_equals(document.getElementById("d2").firstChild.firstChild.getAttribute("definitionURL"),"www.example.org/FOO") 56 },"DEFINITIONurl attribute markup should produce a definitionURL attribute, attribute value unchanged"); 57 58 test(function() { 59 assert_equals(document.getElementById("m3span-mtext").firstChild.firstChild.nodeName,"SPAN"); 60 assert_equals(document.getElementById("m3span-mtext").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 61 },"html Span in mtext produces SPAN nodename in XHTML namespace"); 62 63 test(function() { 64 assert_equals(document.getElementById("m3span-mi").firstChild.firstChild.nodeName,"SPAN"); 65 assert_equals(document.getElementById("m3span-mi").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 66 },"html Span in mi produces SPAN nodename in XHTML namespace"); 67 68 test(function() { 69 assert_equals(document.getElementById("m3span-mrow").firstChild.firstChild.nodeName,"SPAN"); 70 assert_equals(document.getElementById("m3span-mrow").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 71 },"html Span in mrow produces SPAN nodename in XHTML namespace"); 72 73 test(function() { 74 assert_equals(document.getElementById("m3p-mtext").firstChild.firstChild.nodeName,"P"); 75 assert_equals(document.getElementById("m3p-mtext").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 76 },"html P in mtext produces P nodename in XHTML namespace"); 77 78 test(function() { 79 assert_equals(document.getElementById("m3p-mi").firstChild.firstChild.nodeName,"P"); 80 assert_equals(document.getElementById("m3p-mi").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 81 },"html P in mi produces P nodename in XHTML namespace"); 82 83 test(function() { 84 assert_equals(document.getElementById("d3p-mrow").childNodes.length ,3) 85 },"html P in mrow terminates the math: mrow,P,MI children of div"); 86 87 test(function() { 88 assert_equals(document.getElementById("d3p-mrow").firstChild.childNodes.length ,1) 89 },"html P in mrow terminates the math: mrow child of math"); 90 91 test(function() { 92 assert_equals(document.getElementById("d3p-mrow").firstChild.firstChild.childNodes.length ,0) 93 },"html P in mrow terminates the math: mrow empty"); 94 95 test(function() { 96 assert_equals(document.getElementById("d3p-mrow").childNodes[0].nodeName,"math"); 97 assert_equals(document.getElementById("d3p-mrow").childNodes[1].nodeName,"P"); 98 assert_equals(document.getElementById("d3p-mrow").childNodes[2].nodeName,"MI"); 99 },"html P in mrow terminates the math: math,P,MI children of div"); 100 101 test(function() { 102 assert_equals(document.getElementById("m4").firstChild.firstChild.nodeName,"UNDEFINEDELEMENT"); 103 assert_equals(document.getElementById("m4").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 104 },"Undefinedelement in mtext produces UNDEFINEDELEMENT nodename in XHTML namespace"); 105 106 test(function() { 107 assert_equals(document.getElementById("m5").firstChild.firstChild.nodeName,"MI"); 108 assert_equals(document.getElementById("m5").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml") 109 },"mi in mtext produces MI nodename in XHTML namespace"); 110 111 test(function() { 112 assert_equals(document.getElementById("p6default").parentNode.nodeName,"DIV") 113 },"p in annotation-xml moves to be child of DIV"); 114 115 test(function() { 116 assert_equals(document.getElementById("p6texthtml").parentNode.nodeName,"annotation-xml") 117 },"p in annotation-xml encoding=text/html stays as child of annotation-xml"); 118 119 test(function() { 120 assert_equals(document.getElementById("p6uctexthtml").parentNode.nodeName,"annotation-xml") 121 },"p in annotation-xml encoding=TEXT/HTML stays as child of annotation-xml"); 122 123 test(function() { 124 assert_equals(document.getElementById("p6applicationxhtmlxml").parentNode.nodeName,"annotation-xml") 125 },"p in annotation-xml encoding=application/xhtml+xml stays as child of annotation-xml"); 126 127 test(function() { 128 assert_equals(document.getElementById("p6foo").parentNode.nodeName,"DIV") 129 },"p in annotation-xml encoding=foo moves to be child of DIV"); 130 </script> 131 </body> 132 </html>