4 <title>Touch Adjustment : HTML Label and form fields - bug
78801</title>
5 <script src=
"../resources/ahem.js"></script>
6 <script src=
"../resources/js-test.js"></script>
7 <script src=
"resources/touchadjustment.js"></script>
21 <a href=
"#myform" id=
"mylink">Do not click here
</a><br>
23 <label for=
"myinput" id=
"mylabel">Click here,
</label>
24 <span id=
"myspan">but not here.
</span>
25 <input type=
"text" id=
"myinput" value=
"To focus this."></input>
29 <p id='description'
></p>
30 <div id='console'
></div>
35 // Set up shortcut access to elements
37 ['sandbox', 'mylink', 'myform', 'myinput', 'mylabel', 'myspan'].forEach(function(a
) {
38 e
[a
] = document
.getElementById(a
);
41 function testDirectTouch(element
)
43 var touchpoint
= offsetTouchPoint(findAbsoluteBounds(element
), 'center', 0, 20, 30);
44 testTouchPoint(touchpoint
, element
, /* allowTextNodes */ false, /* disallowShadowDOM */ true);
47 function testIndirectTouch(element
, offset
)
49 // Touch just right of the element.
50 var touchpoint
= offsetTouchPoint(findAbsoluteBounds(element
), 'right', offset
, 30, 20);
51 testTouchPoint(touchpoint
, element
, /* allowTextNodes */ false, /* disallowShadowDOM */ true);
54 function testDirectTouches()
56 debug('Testing small direct hits.');
58 testDirectTouch(e
.mylink
);
59 testDirectTouch(e
.mylabel
);
60 testDirectTouch(e
.myinput
);
63 function testIndirectTouches()
65 debug('Testing indirect hits.');
67 testIndirectTouch(e
.mylink
, 10);
69 // This case is very borderline - there's not much reason to adjust
70 // left to the label instead of up to the link (it's closer to
71 // the label, but overlaps with more of the link).
72 testIndirectTouch(e
.mylabel
, 1);
74 testIndirectTouch(e
.myinput
, 10);
79 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestClickableNode
) {
80 description('Tests if labels are treated as clickable if the input they control is.');
82 testIndirectTouches();
83 e
.sandbox
.style
.display
= 'none';