4 https://bugzilla.mozilla.org/show_bug.cgi?id=98997
7 <title>Test for Bug
98997</title>
8 <script type=
"text/javascript" src=
"/MochiKit/MochiKit.js"></script>
9 <script type=
"text/javascript" src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 <link rel=
"stylesheet" type=
"text/css" href=
"/tests/SimpleTest/test.css" />
11 <style type=
"text/css">
14 * This test does NOT test any of the cases where :empty and
15 * :-moz-only-whitespace differ. We should probably have some tests
18 div
.test
{ width: 200px; height: 30px; margin: 5px 0; }
19 div
.test
.to
, div
.test
.from:empty
{ background: orange
; }
20 div
.test
.to:empty
, div
.test
.from
{ background: green
; }
21 div
.test
.to
, div
.test
.from:-moz-only-whitespace
{ color: maroon
; }
22 div
.test
.to:-moz-only-whitespace
, div
.test
.from
{ color: navy
; }
27 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=98997">Mozilla Bug
98997</a>
29 <div class=
"test to" onclick=
"testReplaceChild(this, '')">x
</div>
30 <div class=
"test to" onclick=
"testReplaceChild(this, '')"><span>x
</span></div>
31 <div class=
"test to" onclick=
"testReplaceChild(this, '')">x
<!-- comment --></div>
32 <div class=
"test to" onclick=
"testRemoveChild(this)">x
</div>
33 <div class=
"test to" onclick=
"testRemoveChild(this)"><span>x
</span></div>
34 <div class=
"test to" onclick=
"testRemoveChild(this)">x
<!-- comment --></div>
35 <div class=
"test to" onclick=
"testChangeData(this, '')">x
</div>
36 <div class=
"test to" onclick=
"testChangeData(this, '')">x
<!-- comment --></div>
37 <div class=
"test to" onclick=
"testDeleteData(this)">x
</div>
38 <div class=
"test to" onclick=
"testDeleteData(this)">x
<!-- comment --></div>
39 <div class=
"test to" onclick=
"testReplaceData(this, '')">x
</div>
40 <div class=
"test to" onclick=
"testReplaceData(this, '')">x
<!-- comment --></div>
42 <div class=
"test from makeemptytext" onclick=
"testReplaceChild(this, 'x')"></div>
43 <div class=
"test from makeemptytext" onclick=
"testReplaceChild(this, 'x')"><!-- comment --></div>
44 <div class=
"test from" onclick=
"testReplaceChild(this, 'x')"><!-- comment --></div>
45 <div class=
"test from" onclick=
"testInsertBefore(this, 'x')"></div>
46 <div class=
"test from" onclick=
"testInsertBefore(this, 'x')"><!-- comment --></div>
47 <div class=
"test from" onclick=
"testAppendChild(this, 'x')"></div>
48 <div class=
"test from" onclick=
"testAppendChild(this, 'x')"><!-- comment --></div>
49 <div class=
"test from makeemptytext" onclick=
"testChangeData(this, 'x')"></div>
50 <div class=
"test from makeemptytext" onclick=
"testChangeData(this, 'x')"><!-- comment --></div>
51 <div class=
"test from makeemptytext" onclick=
"testAppendData(this, 'x')"></div>
52 <div class=
"test from makeemptytext" onclick=
"testAppendData(this, 'x')"><!-- comment --></div>
53 <div class=
"test from makeemptytext" onclick=
"testReplaceData(this, 'x')"></div>
54 <div class=
"test from makeemptytext" onclick=
"testReplaceData(this, 'x')"><!-- comment --></div>
57 <div id=
"content" style=
"display: none">
61 <script class=
"testbody" type=
"text/javascript">
63 /** Test for Bug
98997 **/
65 function testInsertBefore(elt, text) {
66 elt.insertBefore(document.createTextNode(text), elt.firstChild);
69 function testAppendChild(elt, text) {
70 elt.appendChild(document.createTextNode(text));
73 function testReplaceChild(elt, text) {
74 elt.replaceChild(document.createTextNode(text), elt.firstChild);
77 function testRemoveChild(elt) {
78 elt.removeChild(elt.firstChild);
81 function testChangeData(elt, text) {
82 elt.firstChild.data = text;
85 function testAppendData(elt, text) {
86 elt.firstChild.appendData(text);
89 function testDeleteData(elt) {
90 elt.firstChild.deleteData(
0, elt.firstChild.length);
93 function testReplaceData(elt, text) {
94 elt.firstChild.replaceData(
0, elt.firstChild.length, text);
97 var cnodes = document.getElementById(
"display").childNodes;
100 for (i =
0; i < cnodes.length; ++i) {
101 if (cnodes[i].nodeName ==
"DIV")
102 divs.push(cnodes[i]);
107 if (div.className.match(/makeemptytext/))
108 div.insertBefore(document.createTextNode(
""), div.firstChild);
111 const ORANGE =
"rgb(255, 165, 0)";
112 const MAROON =
"rgb(128, 0, 0)";
113 const GREEN =
"rgb(0, 128, 0)";
114 const NAVY =
"rgb(0, 0, 128)";
116 function color(div) {
117 return getComputedStyle(div,
"").color;
120 return getComputedStyle(div,
"").backgroundColor;
125 is(bg(div), ORANGE,
"should be orange");
126 is(color(div), MAROON,
"should be maroon");
131 var e = document.createEvent(
"MouseEvents");
132 e.initEvent(
"click", true, true);
133 div.dispatchEvent(e);
138 is(bg(div), GREEN,
"should be green");
139 is(color(div), NAVY,
"should be navy");