4 <title>Touch Adjustment : Adjust correctly for scroll offset - bug
86205</title>
5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/touchadjustment.js"></script>
8 #scrolloffsetcontainer {
16 #div0 { margin-left:
20px; height:
100px; box-sizing: border-box; }
17 #div1 { margin-left:
10px; height:
100px; box-sizing: border-box; }
22 <div id=scrolloffsetcontainer
>
24 <a id=a0
href=
"#div0">Link
0</a>
27 <a id=a1
href=
"#div1">Link
1</a>
31 <p id='description'
></p>
32 <div id='console'
></div>
37 // Set up shortcut access to elements
39 ['scrolloffsetcontainer', 'div0', 'div1', 'a0', 'a1'].forEach(function(a
) {
40 e
[a
] = document
.getElementById(a
);
43 function adjustedPointAtTouch(x
, y
, radius
)
47 var width
= radius
* 2;
48 var height
= radius
* 2;
49 var position
= internals
.touchPositionAdjustedToBestClickableNode(x
, y
, width
, height
, document
);
53 function testDirectTouches()
55 testTouchPoint(touchPoint(40, 130, 50), e
.a0
);
56 testTouchPoint(touchPoint(30, 230, 50), e
.a1
);
58 function testAdjustedTouches()
60 adjustedPoint
= adjustedPointAtTouch(10, 120, 80);
61 shouldBeNonNull('adjustedPoint');
62 adjustedNode
= document
.elementFromPoint(adjustedPoint
.x
, adjustedPoint
.y
);
63 shouldBe('adjustedNode', 'e.a0');
65 adjustedPoint
= adjustedPointAtTouch(5, 220, 80);
66 shouldBeNonNull('adjustedPoint');
67 adjustedNode
= document
.elementFromPoint(adjustedPoint
.x
, adjustedPoint
.y
);
68 shouldBe('adjustedNode', 'e.a1');
73 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestClickableNode
) {
74 description('Test touch adjustment when main frame is scroll offset.');
75 window
.scrollBy(0,400);
77 testAdjustedTouches();
78 e
.scrolloffsetcontainer
.style
.display
= 'none';