summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/css/last-child-innerhtml.html
blob: da54c486b6f8dd1a5e21e7f3b1858e7b75ce2f61 (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
<html>
<head>
<script src="../../resources/js-test.js"></script>
<style>
div p:first-child {
  color: blue;
}
div p:last-child {
  color: purple;
}
</style>
<p id="description"></p>
<div id="threeChildren">
<p>a</p><p>b</p><p>c</p>
</div>
<div id="oneChild">
</div>
<div id="console"></div>
<script>
description("Check if replacing innerHTML handles :last-child properly.");
function replace(x) {
  x.innerHTML = "<p>1</p><p>2</p><p>3</p>";
}

var element = null;

debug("Replacing three children.");
replace(document.getElementById("threeChildren"));
element = document.getElementById("threeChildren").firstChild;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(0, 0, 255)'");
element = element.nextSibling;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(0, 0, 0)'");
element = element.nextSibling;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(128, 0, 128)'");

debug("Replacing one child.");
replace(document.getElementById("oneChild"));
element = document.getElementById("oneChild").firstChild;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(0, 0, 255)'");
element = element.nextSibling;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(0, 0, 0)'");
element = element.nextSibling;
shouldBe("getComputedStyle(element).getPropertyValue('color')", "'rgb(128, 0, 128)'");

document.getElementById("threeChildren").innerHTML = "";
document.getElementById("oneChild").innerHTML = "";
</script>
</body>