summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/touchadjustment/zoom-fatfinger.html
blob: 7dc7678e02c0585ef46916a1cc3d19abde10cc1b (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
<html>
<head>
    <script src="../resources/js-test.js"></script>
    <style>
        #div1 { position: absolute; left: 100px; top: 100px; width: 200px; height: 20px; }
    </style>
</head>
<body onload="runTests()">

<div id=div1></div>

<p id='description'></p>
<div id='console'></div>

<script>
    function testRoundTouch(x, y, radius)
    {
        var x = x - radius;
        var y = y - radius;
        var width = radius * 2;
        var height = radius * 2;
        var zoomableRect = internals.bestZoomableAreaForTouchPoint(x, y, width, height, document);
        return zoomableRect;
    }

    function testDirectTouches()
    {
        zoomableArea = testRoundTouch(200, 110, 20);
        shouldEvaluateTo('zoomableArea.top', 100);
        shouldEvaluateTo('zoomableArea.left', 100);
        shouldEvaluateTo('zoomableArea.width', 200);
        shouldEvaluateTo('zoomableArea.height', 20);

    }

    function runTests()
    {
        if (window.testRunner && window.internals && internals.bestZoomableAreaForTouchPoint) {
            description('Test that targetted area is picked even if the touch area is not fully contained.');
            testRunner.dumpAsText();
            testRunner.waitUntilDone();
            testDirectTouches();
            isSuccessfullyParsed();
            testRunner.notifyDone();
        }
    }
</script>
</body>
</html>