4 Test for bug
1363805: We only restyle as little as needed
6 <link rel=
"author" href=
"mailto:wpan@mozilla.com" title=
"Wei-Cheng Pan">
7 <script src=
"/tests/SimpleTest/SimpleTest.js"></script>
10 background-color: black;
13 background-color: gray;
25 function flushStyle () {
26 getComputedStyle(document
.body
).width
;
29 SimpleTest
.waitForExplicitFinish();
30 const utils
= SpecialPowers
.getDOMWindowUtils(window
);
31 const container
= document
.querySelector('#container');
32 const foo
= document
.querySelector('#foo');
33 const bar
= document
.querySelector('#bar');
36 let currentRestyleGeneration
= utils
.restyleGeneration
;
38 // No style changed, so we should not restyle.
39 getComputedStyle(foo
).backgroundColor
;
40 is(utils
.restyleGeneration
, currentRestyleGeneration
,
41 "Shouldn't restyle anything if no style changed");
43 // foo's parent has changed, must restyle.
44 container
.classList
.toggle('black');
45 getComputedStyle(foo
).backgroundColor
;
46 isnot(utils
.restyleGeneration
, currentRestyleGeneration
,
47 "Should have restyled something");
49 currentRestyleGeneration
= utils
.restyleGeneration
;
51 // The change of foo should not affect its parent.
52 foo
.classList
.toggle('black');
53 getComputedStyle(container
).backgroundColor
;
54 is(utils
.restyleGeneration
, currentRestyleGeneration
,
55 "Shouldn't restyle anything if no style changed");
57 // It should restyle for foo's later sibling.
58 getComputedStyle(bar
).backgroundColor
;
59 isnot(utils
.restyleGeneration
, currentRestyleGeneration
,
60 "Should have restyled something");