OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Touch Adjustment : Touch adjustment does not target shadow DOM elemen
ts - bug 89556</title> | 4 <title>Touch Adjustment : Touch adjustment does not target shadow DOM elemen
ts - bug 89556</title> |
5 <script src="../resources/js-test.js"></script> | 5 <script src="../resources/js-test.js"></script> |
| 6 <script src="resources/touchadjustment.js"></script> |
6 <style> | 7 <style> |
7 #targetDiv { | 8 #targetDiv { |
8 background: #00f; | 9 background: #00f; |
9 height: 100px; | 10 height: 100px; |
10 position: relative; | 11 position: relative; |
11 width: 100px; | 12 width: 100px; |
12 } | 13 } |
13 </style> | 14 </style> |
14 | 15 |
15 </head> | 16 </head> |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 testTouch(targetX, targetY + targetRadius + offset, padding, targetX, ta
rgetY, targetRadius); | 76 testTouch(targetX, targetY + targetRadius + offset, padding, targetX, ta
rgetY, targetRadius); |
76 testTouch(targetX, targetY - targetRadius - offset, padding, targetX, ta
rgetY, targetRadius); | 77 testTouch(targetX, targetY - targetRadius - offset, padding, targetX, ta
rgetY, targetRadius); |
77 | 78 |
78 // A touch in the center of targetDiv is sufficient distance from the sh
adow-DOM element that the position should not snap. | 79 // A touch in the center of targetDiv is sufficient distance from the sh
adow-DOM element that the position should not snap. |
79 testTouch(midX, midY, padding, midX, midY, 1); | 80 testTouch(midX, midY, padding, midX, midY, 1); |
80 } | 81 } |
81 | 82 |
82 function testTouch(touchX, touchY, padding, adjustedX, adjustedY, tolerance)
{ | 83 function testTouch(touchX, touchY, padding, adjustedX, adjustedY, tolerance)
{ |
83 var left = touchX - padding / 2; | 84 var left = touchX - padding / 2; |
84 var top = touchY - padding / 2; | 85 var top = touchY - padding / 2; |
85 adjustedNode = internals.touchNodeAdjustedToBestClickableNode(left, top,
padding, padding, document); | 86 testTouchPoint(touchPoint(left, top, padding), element, /* allowTextNode
s */ false, /* disallowShadowDOM */ true); |
86 shouldBe('adjustedNode.id', 'element.id'); | |
87 adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(left,
top, padding, padding, document); | 87 adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(left,
top, padding, padding, document); |
88 shouldBeCloseTo('adjustedPoint.x', adjustedX, tolerance); | 88 shouldBeCloseTo('adjustedPoint.x', adjustedX, tolerance); |
89 shouldBeCloseTo('adjustedPoint.y', adjustedY, tolerance); | 89 shouldBeCloseTo('adjustedPoint.y', adjustedY, tolerance); |
90 } | 90 } |
91 | 91 |
92 function runTests() | 92 function runTests() |
93 { | 93 { |
94 if (window.testRunner && window.internals && internals.touchNodeAdjusted
ToBestClickableNode) { | 94 if (window.testRunner && window.internals && internals.touchNodeAdjusted
ToBestClickableNode) { |
95 description('Test the case where a clickable target contains a shado
w-DOM element. The adjusted point should snap to the location of the shadow-DOM
element if close enough to the original touch position.') | 95 description('Test the case where a clickable target contains a shado
w-DOM element. The adjusted point should snap to the location of the shadow-DOM
element if close enough to the original touch position.') |
96 addShadowDOM(); | 96 addShadowDOM(); |
97 runTouchTests(); | 97 runTouchTests(); |
98 } | 98 } |
99 } | 99 } |
100 runTests(); | 100 runTests(); |
101 </script> | 101 </script> |
102 </body> | 102 </body> |
103 </html> | 103 </html> |
OLD | NEW |