3 <script src=
"../../resources/js-test.js"></script>
5 <div id=
"sheet-container"></div>
6 <div><!-- Extra divs so it's clear when we're doing a full document recalc -->
18 <div class=
"foo">foo
</div>
19 <div class=
"foo">foo
</div>
20 <div class=
"foo">foo
</div>
21 <div class=
"bar">bar
</div>
22 <div class=
"bar">bar
</div>
23 <div class=
"bar">bar
</div>
24 <div class=
"baz">baz
</div>
25 <div class=
"baz">baz
</div>
26 <div class=
"baz">baz
</div>
28 // Add and remove sheets in the same run.
29 document
.documentElement
.offsetTop
;
30 var sheetContainer
= document
.getElementById('sheet-container');
31 sheetContainer
.innerHTML
= '<style>.foo { color: green; }</style><style>.bar { color: red; }</style>'
32 // 6 elements + documentElement + body get recalced.
34 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "8");
36 document
.documentElement
.offsetTop
;
37 sheetContainer
.innerHTML
= '<style>.baz { color: blue; }</style>'
39 // 9 elements + documentElement + body get recalced.
41 shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "10");
43 shouldBe("getComputedStyle(document.querySelector('.foo')).color", '"rgb(0, 0, 0)"');
44 shouldBe("getComputedStyle(document.querySelector('.baz')).color", '"rgb(0, 0, 255)"');
45 shouldBe("getComputedStyle(document.querySelector('.bar')).color", '"rgb(0, 0, 0)"');