2 <script src=
"../../resources/js-test.js"></script>
3 <div id=
"spanner"></div>
5 var styleCount
, layoutCount
;
7 function assertSyncLayout(sync
) {
8 if (window
.internals
) {
9 styleCount
= internals
.updateStyleAndReturnAffectedElementCount();
10 layoutCount
= internals
.needsLayoutCount();
11 // scrollTo should have synchronously updated style and layout
13 shouldBe("styleCount", "0");
14 shouldBe("layoutCount", "0");
16 shouldNotBe("styleCount", "0");
17 shouldNotBe("layoutCount", "0");
22 spanner
.style
.width
= "3000px";
23 spanner
.style
.height
= "3000px";
24 scrollTo({ left
: 0, top
: 1000});
25 assertSyncLayout(true);
26 shouldBe("window.scrollY", "1000");
28 scrollTo({ left
: 1000, top
: 1000});
29 assertSyncLayout(true);
30 shouldBe("window.scrollX", "1000");
32 spanner
.style
.height
= "2000px";
33 scrollTo({ left
: 0, top
: 0});
34 assertSyncLayout(false);
35 shouldBe("window.scrollY", "0");
37 spanner
.style
.height
= "1px";
38 scrollTo({ left
: 0 });
39 assertSyncLayout(true);
41 spanner
.style
.height
= "2px";
43 assertSyncLayout(true);
45 spanner
.style
.height
= "3px";
47 assertSyncLayout(true);