summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/touchadjustment/touch-inlines.html
blob: f3c193fec7595e3f5e7dab3545c86510c51dfdc4 (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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE html>
<html>
<head>
    <title>Touch Adjustment : Inlines and line-breaks - bug 78801</title>
    <script src="../fast/js/resources/js-test-pre.js"></script>
    <script src="resources/touchadjustment.js"></script>
    <style>
        #sandbox { position: absolute; top: 0px; left: 0px; font: 16px Ahem; line-height: 20px }
    </style>
</head>
<body>

<div id=sandbox>
    <p style="width: 22em;">
    <a id="1" href="#1">some link</a><br>
    <a id="2" href="#2">some link breaking lines</a> and <a id="3" href="#3">link</a><br>
    hola mundo! <a id="4" href="#4">a split up link</a><br>
    hello world <a id="5" href="#5">some link also breaking</a><br>
    hi there <a id="6" href="#6">some link that is breaking multiple lines just for the very fun of it</a><br><br>
    </p>
</div>

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

<script>
    // Set up shortcut access to elements
    var e = {};
    ['sandbox', '1', '2', '3', '4', '5', '6'].forEach(function(a) {
        e[a] = document.getElementById(a);
    });

    function testDirectTouches()
    {
        debug('Test some direct hits.');
        testTouchPoint(touchPoint(30, 25, 10), e['1']);
        testTouchPoint(touchPoint(20, 65, 10), e['2']);
        testTouchPoint(touchPoint(220, 85, 10), e['4']);
        testTouchPoint(touchPoint(80, 195, 10), e['6']);
    }

    function testDirectMisses()
    {
        debug('Test a few direct misses.');
        // Hit 'and' betwen link 2 and 3
        testTouchPoint(touchPoint(120, 75, 6), null);
        // Hit 'hi there' above and to the left of link 6.
        testTouchPoint(touchPoint(72, 166, 6), null);
    }

    function testIndirectTouches()
    {
        debug('Test some indirect hits.');

        testTouchPoint(touchPoint(50, 60, 20), e['2']);
        testTouchPoint(touchPoint(172, 83, 20), e['3']);
        testTouchPoint(touchPoint(230, 74, 20), e['4']);
        testTouchPoint(touchPoint(30, 100, 20), e['4']);
        testTouchPoint(touchPoint(24, 170, 20), e['6']);

    }

    function runTests()
    {
        if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
            description('Tests touch-adjustment on inline links. Making sure we can hit over line-breaks, and can miss when tapping between parts of a line-broken link.');
            testDirectTouches();
            testDirectMisses();
            testIndirectTouches();
            e['sandbox'].style.display = 'none';
        }
    }
    runTests();
</script>
<script src="../fast/js/resources/js-test-post.js"></script>
</body>
</html>