summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/scrolling/fractional-scroll-offset-document.html
blob: dd4090cdf6b9564b6fce456033561f5840035cc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<!DOCTYPE HTML>
<body style="width:30000px;height:30000px" onload="runTest()">
</body>

<script src="../../resources/js-test.js"></script>
<script>
description("Verifies that document scrolling supports fractional offset.");

var floatPrecision = 0.00001;
var useIntegerScrollOffset = false;
function checkScrollOffset(offset_x, offset_y)
{
    if (useIntegerScrollOffset) {
        offset_x = Math.floor(offset_x);
        offset_y = Math.floor(offset_y);
    }
    shouldBeCloseTo('document.scrollingElement.scrollTop', offset_y, floatPrecision);
    shouldBeCloseTo('document.scrollingElement.scrollLeft', offset_x, floatPrecision);
}

function scroll()
{
    window.scrollTo(0, 0);
    eventSender.gestureScrollBegin(100.1, 300.2);
    checkScrollOffset(0, 0);
    eventSender.gestureScrollUpdate(-20.5, -10.2);
    checkScrollOffset(20.5, 10.2);
    eventSender.gestureScrollUpdate(10.9, -20.9);
    checkScrollOffset(9.6, 31.1);
    eventSender.gestureScrollUpdate(100.4, 220.9);
    checkScrollOffset(0.0, 0.0);
    eventSender.gestureScrollEnd(0, 0);
}

function runTest()
{
    if (window.eventSender) {
      debug("set PreferCompositingToLCDTextEnabled true");
      window.internals.settings.setPreferCompositingToLCDTextEnabled(true);
      scroll();

      debug("set PreferCompositingToLCDTextEnabled false");
      window.internals.settings.setPreferCompositingToLCDTextEnabled(false);
      useIntegerScrollOffset = true;
      scroll();
    }
}

</script>
</html>