summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/touchadjustment/disabled-formelements.html
blob: b015dbe98930024f45a0c6f8ea54804caad1f3ef (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
<!DOCTYPE html>
<html>
<head>
    <title>Touch Adjustment : Disabled form elements - bug 92093</title>
    <script src="../fast/js/resources/js-test-pre.js"></script>
    <script src="resources/touchadjustment.js"></script>
    <style type="text/css">
        #sandbox {
            position: absolute;
            left: 0px;
            top: 0px;
            width: 600px;
            height: 600px;
        }
    </style>
</head>

<body id="body">

<div id=sandbox>
    <form id="form">
        <label for="input1" id="label1">Label</label> <input type="text" id="input1" value="Disabled input" disabled></input><br>
        <label for="input2" id="label2">Label</label> <input type="text" id="input2" value="Enabled input"></input>
    </form>
</div>

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

<script>
    // Set up shortcut access to elements
    var e = {};
    ['sandbox', 'form,', 'label1', 'label2', 'input1', 'input2'].forEach(function(a) {
        e[a] = document.getElementById(a);
    });

    function testDirectTouches()
    {
        // Quick sanity check.
        debug('Test we can hit the form elements directly.');

        testTouchPoint(touchPoint(16, 8, 5), null);
        testTouchPoint(touchPoint(16, 38, 5), e.label2);
        testTouchPoint(touchPoint(60, 8, 5), null);
        testTouchPoint(touchPoint(60, 38, 5), e.input2);
    }

    function testAdjustedTouches()
    {
        debug('Test indirect touches are adjusted to the enabled form elements.');
        testTouchPoint(touchPoint(16, 25, 10), e.label2);
        testTouchPoint(touchPoint(16, 20, 15), e.label2);
        testTouchPoint(touchPoint(16, 16, 20), e.label2);

        testTouchPoint(touchPoint(60, 25, 10), e.input2);
        testTouchPoint(touchPoint(60, 20, 15), e.input2);
        testTouchPoint(touchPoint(60, 16, 20), e.input2);
    }

    function runTests()
    {
        if (window.testRunner && window.internals && internals.touchNodeAdjustedToBestClickableNode) {
            description(document.title);
            testDirectTouches();
            testAdjustedTouches();
            e.sandbox.style.display = 'none';
        }
    }

    runTests();
</script>


</body>
</html>