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 adjustedNode = touchNodeAdjustedToBestClickableNode(left, top, padding, padding, document, /* disallowShadowDOM */ true); |
Rick Byers
2014/07/10 20:09:10
nit: you could just call testTouchPoint here to be
| |
86 shouldBe('adjustedNode.id', 'element.id'); | 87 shouldBe('adjustedNode.id', 'element.id'); |
87 adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(left, top, padding, padding, document); | 88 adjustedPoint = internals.touchPositionAdjustedToBestClickableNode(left, top, padding, padding, document); |
88 shouldBeCloseTo('adjustedPoint.x', adjustedX, tolerance); | 89 shouldBeCloseTo('adjustedPoint.x', adjustedX, tolerance); |
89 shouldBeCloseTo('adjustedPoint.y', adjustedY, tolerance); | 90 shouldBeCloseTo('adjustedPoint.y', adjustedY, tolerance); |
90 } | 91 } |
91 | 92 |
92 function runTests() | 93 function runTests() |
93 { | 94 { |
94 if (window.testRunner && window.internals && internals.touchNodeAdjusted ToBestClickableNode) { | 95 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.') | 96 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(); | 97 addShadowDOM(); |
97 runTouchTests(); | 98 runTouchTests(); |
98 } | 99 } |
99 } | 100 } |
100 runTests(); | 101 runTests(); |
101 </script> | 102 </script> |
102 </body> | 103 </body> |
103 </html> | 104 </html> |
OLD | NEW |