1 <html xmlns=
"http://www.w3.org/1999/xhtml">
3 https://bugzilla.mozilla.org/show_bug.cgi?id=75375
6 <title>Test for *-of-type selectors in Bug
75375</title>
7 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
8 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=75375">Mozilla Bug
75375</a>
12 <div id=
"content" style=
"display: none"
13 xmlns:
html=
"http://www.w3.org/1999/xhtml">
15 <p>This is a
<code>p
</code> element in the HTML namespace.
</p>
16 <p>This is a second
<code>p
</code> element in the HTML namespace.
</p>
17 <html:p>This is an
<code>html:p
</code> element in the HTML namespace.
</html:p>
18 <p xmlns=
"http://www.example.com/ns">This is a
<code>p
</code> element in the
<code>http://www.example.com/ns
</code> namespace.
</p>
19 <html:address>This is an
<code>html:address
</code> element in the HTML namespace.
</html:address>
20 <address xmlns=
"">This is a
<code>address
</code> element in no namespace.
</address>
21 <address xmlns=
"">This is a
<code>address
</code> element in no namespace.
</address>
22 <p xmlns=
"">This is a
<code>p
</code> element in no namespace.
</p>
26 <script class=
"testbody" type=
"text/javascript">
29 /** Test for *-of-type selectors in Bug
75375 **/
31 var HTML_NS =
"http://www.w3.org/1999/xhtml";
33 function setup_style_text() {
34 var result = document.createCDATASection(
"");
35 var style = document.createElementNS(HTML_NS,
"style");
36 style.appendChild(result);
37 document.getElementsByTagName(
"head")[
0].appendChild(style);
42 var styleText = setup_style_text();
46 var div = document.getElementById(
"content");
47 for (let i =
0; i < div.childNodes.length; ++i) {
48 var child = div.childNodes[i];
49 if (child.nodeType == Node.ELEMENT_NODE)
55 function test_selector(selector, match_indices, notmatch_indices)
58 styleText.data = selector +
" { z-index: " + zi +
" }";
60 for (i in match_indices) {
61 var e = elements[match_indices[i]];
62 is(getComputedStyle(e,
"").zIndex, String(zi),
63 "element " + match_indices[i] +
" matched " + selector);
65 for (i in notmatch_indices) {
66 var e = elements[notmatch_indices[i]];
67 is(getComputedStyle(e,
"").zIndex,
"auto",
68 "element " + notmatch_indices[i] +
" did not match " + selector);
80 test_selector(
":nth-of-type(1)", [
0,
3,
4,
5,
7], [
1,
2,
6]);
81 test_selector(
":nth-last-of-type(1)", [
2,
3,
4,
6,
7], [
0,
1,
5]);
82 test_selector(
":nth-last-of-type(-n+1)", [
2,
3,
4,
6,
7], [
0,
1,
5]);
83 test_selector(
":nth-of-type(even)", [
1,
6], [
0,
2,
3,
4,
5,
7]);
84 test_selector(
":nth-last-of-type(odd)", [
0,
2,
3,
4,
6,
7], [
1,
5]);
85 test_selector(
":nth-last-of-type(n+2)", [
0,
1,
5], [
2,
3,
4,
6,
7]);
86 test_selector(
":first-of-type", [
0,
3,
4,
5,
7], [
1,
2,
6]);
87 test_selector(
":last-of-type", [
2,
3,
4,
6,
7], [
0,
1,
5]);
88 test_selector(
":only-of-type", [
3,
4,
7], [
0,
1,
2,
5,
6]);