Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / css / invalidation / sibling-inserted.html
blobb035d7629d9cbb15b15395c210a573ef8ca32a40
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <style>
5 #t1 + div + div + #r1,
6 #t2 + div + div + #r2,
7 #t3 + div + div + #r3 { background-color: rgb(0, 128, 0); }
8 </style>
9 <div>
10 <div id="t1"></div>
11 <div id="i1"></div>
12 <div id="r1"></div>
13 <div></div>
14 </div>
15 <div>
16 <div id="i2"></div>
17 <div></div>
18 <div id="r2"></div>
19 <div></div>
20 </div>
21 <div>
22 <div id="t3"></div>
23 <div></div>
24 <div id="d3"></div>
25 <div></div>
26 <div id="r3"></div>
27 <div></div>
28 </div>
29 <script>
30 'use strict';
31 document.body.offsetTop;
33 test(function() {
34 assert_true(!!window.internals, "This test only works with internals exposed present");
35 }, "internals are exposed");
37 test(function() {
38 var i1 = document.getElementById('i1');
39 var r1 = document.getElementById('r1');
40 assert_equals(getComputedStyle(r1).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
42 i1.parentNode.insertBefore(document.createElement('div'), i1);
43 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 4, "Subtree style recalc");
44 assert_equals(getComputedStyle(r1).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
45 }, "Insert between siblings");
47 test(function() {
48 var i2 = document.getElementById('i2');
49 var r2 = document.getElementById('r2');
50 assert_equals(getComputedStyle(r2).backgroundColor, "rgba(0, 0, 0, 0)", "Background color should initially be transparent");
52 var t2 = document.createElement('div');
53 t2.id = 't2';
54 i2.parentNode.insertBefore(t2, i2);
55 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 5, "Subtree style recalc");
56 assert_equals(getComputedStyle(r2).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
57 }, "Insert before siblings");
59 test(function() {
60 var d3 = document.getElementById('d3');
61 var r3 = document.getElementById('r3');
62 assert_true(!!window.eventSender, "This test only works with eventSender present");
64 d3.parentNode.removeChild(d3);
65 assert_equals(internals.updateStyleAndReturnAffectedElementCount(), 3, "Subtree style recalc");
66 assert_equals(getComputedStyle(r3).backgroundColor, "rgb(0, 128, 0)", "Background color is green after class change");
67 }, "Remove between siblings");
69 </script>