4 <title>Touch Adjustment : Too aggresive adjustments for large elements - bug
91262</title>
5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/touchadjustment.js"></script>
21 <p id='description'
></p>
22 <div id='console'
></div>
31 function runTouchTests() {
32 element
= document
.getElementById("targetDiv");
33 element
.addEventListener('click', function() {}, false);
34 document
.addEventListener('click', function() {}, false);
36 targetBounds
= findAbsoluteBounds(element
);
39 var offset
= touchRadius
/ 2;
40 var midX
= targetBounds
.left
+ targetBounds
.width
/ 2;
41 var midY
= targetBounds
.top
+ targetBounds
.height
/ 2;
43 debug('\nOverlapping touch above the target should snap to the top of the target element.');
44 testTouch(midX
, targetBounds
.top
- offset
, touchRadius
, targetBounds
);
45 debug('\nOverlapping touch below the target should snap to the bottom of the target element.');
46 testTouch(midX
, targetBounds
.top
+ targetBounds
.height
+ offset
, touchRadius
, targetBounds
);
47 debug('\nOverlapping touch left of the target should snap to the left side of the target element.');
48 testTouch(targetBounds
.left
- offset
, midY
, touchRadius
, targetBounds
);
49 debug('\nOverlapping touch right of the target should snap to the right side of the target element.');
50 testTouch(targetBounds
.left
+ targetBounds
.width
+ offset
, midY
, touchRadius
, targetBounds
);
51 debug('\nTest touch area contained within the target element.');
52 testTouch(midX
, midY
, touchRadius
, targetBounds
);
55 function testTouch(touchX
, touchY
, radius
, targetBounds
) {
63 adjustedNode
= internals
.touchNodeAdjustedToBestClickableNode(touchBounds
.x
, touchBounds
.y
, touchBounds
.width
, touchBounds
.height
, document
);
64 shouldBe('adjustedNode.id', 'element.id');
65 adjustedPoint
= internals
.touchPositionAdjustedToBestClickableNode(touchBounds
.x
, touchBounds
.y
, touchBounds
.width
, touchBounds
.height
, document
);
67 shouldBeTrue('adjustedPoint.x >= targetBounds.left');
68 shouldBeTrue('adjustedPoint.x <= targetBounds.left + targetBounds.width');
69 shouldBeTrue('adjustedPoint.y >= targetBounds.top');
70 shouldBeTrue('adjustedPoint.y <= targetBounds.top + targetBounds.height');
71 shouldBeTrue('adjustedPoint.x >= touchBounds.x');
72 shouldBeTrue('adjustedPoint.x <= touchBounds.x + touchBounds.width');
73 shouldBeTrue('adjustedPoint.y >= touchBounds.y');
74 shouldBeTrue('adjustedPoint.y <= touchBounds.y + touchBounds.height');
79 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestClickableNode
) {
80 description('Test touch adjustment on a large div. The adjusted touch point should lie inside the target element and within the touch area.');