4 https://bugzilla.mozilla.org/show_bug.cgi?id=229915
7 <title>Test for Bug
229915</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">
13 p
{ color: black
; background: transparent
; }
14 p
.prev
+ p
{ color: green
; }
15 p
.prev
~ p
{ background: white
; }
20 <a target=
"_blank" href=
"https://bugzilla.mozilla.org/show_bug.cgi?id=229915">Mozilla Bug
229915</a>
24 <p id=
"toinsertbefore">After testing, this should turn green.
</p>
28 <p id=
"toreplace">To be replaced.
</p>
29 <p id=
"replacecolor">After testing, this should turn green.
</p>
33 <p class=
"prev">Previous paragraph.
</p>
34 <p id=
"toremove">To be removed.
</p>
35 <p id=
"removecolor">After testing, this should turn green.
</p>
39 <div id=
"content" style=
"display: none">
43 <script class=
"testbody" type=
"text/javascript">
45 /** Test for Bug
229915 **/
47 const GREEN =
"rgb(0, 128, 0)";
48 const BLACK =
"rgb(0, 0, 0)";
49 const TRANSPARENT =
"transparent";
50 const WHITE =
"rgb(255, 255, 255)";
52 function make_prev() {
53 var result = document.createElement(
"p");
54 result.setAttribute(
"class",
"prev");
55 var t = document.createTextNode(
"Dynamically created previous paragraph.");
56 result.appendChild(t);
61 return getComputedStyle(document.getElementById(id),
"").color;
64 return getComputedStyle(document.getElementById(id),
"").backgroundColor;
70 is(color(
"toinsertbefore"), BLACK,
"initial state (insertion test)");
71 is(bg(
"toinsertbefore"), TRANSPARENT,
"initial state (insertion test)");
72 node = document.getElementById(
"toinsertbefore");
73 node.parentNode.insertBefore(make_prev(), node);
74 is(color(
"toinsertbefore"), GREEN,
"inserting should turn node green");
75 is(bg(
"toinsertbefore"), WHITE,
"inserting should turn background white");
78 is(color(
"replacecolor"), BLACK,
"initial state (replacement test)");
79 is(bg(
"replacecolor"), TRANSPARENT,
"initial state (replacement test)");
80 node = document.getElementById(
"toreplace");
81 node.parentNode.replaceChild(make_prev(), node);
82 is(color(
"replacecolor"), GREEN,
"replacing should turn node green");
83 is(bg(
"replacecolor"), WHITE,
"replacing should turn background white");
86 is(color(
"removecolor"), BLACK,
"initial state (removal test)");
87 is(bg(
"removecolor"), WHITE,
"initial state (removal test; no change)");
88 node = document.getElementById(
"toremove");
89 node.parentNode.removeChild(node);
90 is(color(
"removecolor"), GREEN,
"removing should turn node green");
91 is(bg(
"removecolor"), WHITE,
"removing should leave background");