summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/syntax/parsing/math-parse03.html
blob: a3dbdc4e61aad00648c6b9ac34e22c08cbea12ce (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<!DOCTYPE html>
<html>
<head>
<title>math in html: parsing</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<h1>math in html: parsing</h1>

<div id="log"></div>

<div>
<div><MATH id="m1"><Mtext/></math></div>
<div id="d1"><math><MI MATHVARIANT="BOLD" /></math></div>
<div id="d2"><math><semantics DEFINITIONurl="www.example.org/FOO"><mi>a</mi><annotation-xml><foo/><bar/></annotation-xml></semantics></math></div>
<div><math id="m3span-mtext"><mtext><Span>x</Span></mtext></math></div>
<div><math id="m3span-mi"><mi><Span>x</Span></mi></math></div>
<div><math id="m3span-mrow"><mi><Span>x</Span></mrow></math></div>
<div><math id="m3p-mtext"><mtext><P>x</P></mtext></math></div>
<div><math id="m3p-mi"><mi><P>x</P></mi></math></div>
<div id="d3p-mrow"><math><mrow><P>x</P><mi>y</mi></mrow></math></div>
<div><math id="m4"><mtext><Undefinedelement>x</Undefinedelement></mtext></math></div>
<div><math id="m5"><mtext><mi>x</mi></mtext></math></div>
<div><math><semantics><mi>x</mi>
                      <annotation-xml><p id="p6default">x</p></annotation-xml>
           </semantics></math></div>
<div><math><semantics><mi>x</mi>
                      <annotation-xml encoding=text/html><p id="p6texthtml">x</p></annotation-xml>
           </semantics></math></div>
<div><math><semantics><mi>x</mi>
                      <annotation-xml encoding=TEXT/HTML><p id="p6uctexthtml">x</p></annotation-xml>
           </semantics></math></div>
<div><math><semantics><mi>x</mi>
                      <annotation-xml encoding=application/xhtml+xml><p id="p6applicationxhtmlxml">x</p></annotation-xml>
           </semantics></math></div>
<div><math><semantics><mi>x</mi>
                      <annotation-xml encoding=foo><p id="p6foo">x</p></annotation-xml>
           </semantics></math></div>
</div>
<script>
test(function() {
assert_equals(document.getElementById("m1"),document.getElementsByTagName("math")[0]);
},"MATH element name should be lowercased");

test(function() {
assert_equals(document.getElementById("d1").firstChild.firstChild.nodeName,"mi");
assert_equals(document.getElementById("d1").firstChild.firstChild.namespaceURI, "http://www.w3.org/1998/Math/MathML");
assert_true(document.getElementById("d1").firstChild.firstChild.hasAttribute("mathvariant"));
assert_equals(document.getElementById("d1").firstChild.firstChild.getAttribute("mathvariant"),"BOLD")
},"MI element name and mathvariant attribute name should be lowercased, attribute value unchanged");

test(function() {
assert_true(document.getElementById("d2").firstChild.firstChild.hasAttribute("definitionURL"));
assert_equals(document.getElementById("d2").firstChild.firstChild.getAttribute("definitionURL"),"www.example.org/FOO")
},"DEFINITIONurl attribute markup should produce a definitionURL attribute, attribute value unchanged");

test(function() {
assert_equals(document.getElementById("m3span-mtext").firstChild.firstChild.nodeName,"SPAN");
assert_equals(document.getElementById("m3span-mtext").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"html Span in mtext produces SPAN nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("m3span-mi").firstChild.firstChild.nodeName,"SPAN");
assert_equals(document.getElementById("m3span-mi").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"html Span in mi produces SPAN nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("m3span-mrow").firstChild.firstChild.nodeName,"SPAN");
assert_equals(document.getElementById("m3span-mrow").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"html Span in mrow produces SPAN nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("m3p-mtext").firstChild.firstChild.nodeName,"P");
assert_equals(document.getElementById("m3p-mtext").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"html P in mtext produces P nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("m3p-mi").firstChild.firstChild.nodeName,"P");
assert_equals(document.getElementById("m3p-mi").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"html P in mi produces P nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("d3p-mrow").childNodes.length ,3)
},"html P in mrow terminates the math: mrow,P,MI children of div");

test(function() {
assert_equals(document.getElementById("d3p-mrow").firstChild.childNodes.length ,1)
},"html P in mrow terminates the math: mrow child of math");

test(function() {
assert_equals(document.getElementById("d3p-mrow").firstChild.firstChild.childNodes.length ,0)
},"html P in mrow terminates the math: mrow empty");

test(function() {
assert_equals(document.getElementById("d3p-mrow").childNodes[0].nodeName,"math");
assert_equals(document.getElementById("d3p-mrow").childNodes[1].nodeName,"P");
assert_equals(document.getElementById("d3p-mrow").childNodes[2].nodeName,"MI");
},"html P in mrow terminates the math: math,P,MI children of div");

test(function() {
assert_equals(document.getElementById("m4").firstChild.firstChild.nodeName,"UNDEFINEDELEMENT");
assert_equals(document.getElementById("m4").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"Undefinedelement in mtext produces UNDEFINEDELEMENT nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("m5").firstChild.firstChild.nodeName,"MI");
assert_equals(document.getElementById("m5").firstChild.firstChild.namespaceURI,"http://www.w3.org/1999/xhtml")
},"mi in mtext produces MI nodename in XHTML namespace");

test(function() {
assert_equals(document.getElementById("p6default").parentNode.nodeName,"DIV")
},"p in annotation-xml moves to be child of DIV");

test(function() {
assert_equals(document.getElementById("p6texthtml").parentNode.nodeName,"annotation-xml")
},"p in annotation-xml encoding=text/html stays as child of annotation-xml");

test(function() {
assert_equals(document.getElementById("p6uctexthtml").parentNode.nodeName,"annotation-xml")
},"p in annotation-xml encoding=TEXT/HTML stays as child of annotation-xml");

test(function() {
assert_equals(document.getElementById("p6applicationxhtmlxml").parentNode.nodeName,"annotation-xml")
},"p in annotation-xml encoding=application/xhtml+xml stays as child of annotation-xml");

test(function() {
assert_equals(document.getElementById("p6foo").parentNode.nodeName,"DIV")
},"p in annotation-xml encoding=foo moves to be child of DIV");
</script>
</body>
</html>