15 <div id=console
></div>
18 <div class=spacer
></div>
20 <div class=spacer
></div>
23 <script src=
"../../resources/js-test.js"></script>
26 description("Verifies that scrolling APIs support fractional offsets.");
27 // Note we current support fractional scrolling only for the special case of
28 // browser zoom. When http://crbug.com/414283 is fixed, we should test
29 // other cases like device scale.
31 // FIXME: Make this smaller. crbug.com/414283.
32 var floatPrecision
= 0.01;
34 function testScroll(scrollOffset
, expectedScrollOffset
) {
36 debug('Scrolling DIV with scrollTop/scrollLeft');
37 scroller
.scrollTop
= scrollOffset
;
38 shouldBeCloseTo('scroller.scrollTop', expectedScrollOffset
, floatPrecision
);
39 scroller
.scrollLeft
= scrollOffset
;
40 shouldBeCloseTo('scroller.scrollLeft', expectedScrollOffset
, floatPrecision
);
42 // Note that the body element is a special case - we don't attempt to
43 // test it here as it's semantics are in flux (http://goo.gl/BFHtMR).
45 debug('Scrolling the document with window.scroll');
48 expectedScrollOffset
++;
49 window
.scroll(scrollOffset
, scrollOffset
);
50 shouldBeCloseTo('window.scrollY', expectedScrollOffset
, floatPrecision
);
51 shouldBeCloseTo('window.scrollX', expectedScrollOffset
, floatPrecision
);
53 debug('Scrolling the document with window.scrollTo');
55 window
.scrollTo(scrollOffset
, scrollOffset
);
56 shouldBeCloseTo('window.pageYOffset', expectedScrollOffset
, floatPrecision
);
57 shouldBeCloseTo('window.pageXOffset', expectedScrollOffset
, floatPrecision
);
59 debug('Scrolling the document with window.scrollBy');
61 window
.scrollBy(scrollOffset
- 1, scrollOffset
- 1);
62 shouldBeCloseTo('window.scrollY', expectedScrollOffset
, floatPrecision
);
63 shouldBeCloseTo('window.scrollX', expectedScrollOffset
, floatPrecision
);
68 function testPageZoom(zoom
) {
69 debug('---- Testing page zoom = ' + zoom
+ ' ----');
70 eventSender
.setPageZoomFactor(zoom
);
75 debug("set PreferCompositingToLCDTextEnabled true");
76 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(true);
80 // If there is no browser zoom, floating point scroll offsets are truncated.
81 // If there is browser zoom, we can still get fractional scroll offsets
83 debug("set PreferCompositingToLCDTextEnabled false");
84 window
.internals
.settings
.setPreferCompositingToLCDTextEnabled(false);