Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / scrolling / scrolling-apis-subpixel.html
blobc80f2e07ab938c805ee661264879e2215f0b2045
1 <!DOCTYPE html>
2 <style>
3 .spacer {
4 height: 1000px;
5 width: 1000px;
7 #scroller, body {
8 height: 100px;
9 width: 100px;
10 overflow: scroll;
13 </style>
14 <body class=scroller>
15 <div id=console></div>
17 <div id=scroller>
18 <div class=spacer></div>
19 </div>
20 <div class=spacer></div>
21 </body>
23 <script src="../../resources/js-test.js"></script>
24 <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');
46 window.scroll(0,0);
47 scrollOffset++;
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');
54 window.scroll(0,0);
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');
60 window.scroll(1,1);
61 window.scrollBy(scrollOffset - 1, scrollOffset - 1);
62 shouldBeCloseTo('window.scrollY', expectedScrollOffset, floatPrecision);
63 shouldBeCloseTo('window.scrollX', expectedScrollOffset, floatPrecision);
65 debug('');
68 function testPageZoom(zoom) {
69 debug('---- Testing page zoom = ' + zoom + ' ----');
70 eventSender.setPageZoomFactor(zoom);
71 testScroll(4, 4);
72 testScroll(4.5, 4.5);
75 debug("set PreferCompositingToLCDTextEnabled true");
76 window.internals.settings.setPreferCompositingToLCDTextEnabled(true);
77 testScroll(4.2, 4.2);
78 testPageZoom(2);
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
82 // through JS.
83 debug("set PreferCompositingToLCDTextEnabled false");
84 window.internals.settings.setPreferCompositingToLCDTextEnabled(false);
85 testScroll(4.2, 4);
86 testPageZoom(2);
87 </script>