4 <title>Touch Adjustment : Shadow DOM Element Search Cancel Button - bug
91894</title>
5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/touchadjustment.js"></script>
9 -webkit-appearance: none;
10 -webkit-box-sizing: border-box;
11 border:
1px solid #
999;
15 input[type='search']::-webkit-search-cancel-button {
16 -webkit-appearance: none;
17 -webkit-box-sizing: border-box;
30 <input id=
"target" type=
"search" value=
"abcd">
33 <p id='description'
></p>
34 <div id='console'
></div>
42 var textContentBounds
;
45 var targetContainsPoint
;
46 var touchContainsPoint
;
48 function runTouchTests() {
49 document
.addEventListener('click', function() {}, false);
51 element
= document
.getElementById('target');
54 inputBounds
= findAbsoluteBounds(element
);
57 var offset
= touchRadius
/ 2;
59 // Center of cancel button.
60 var midX
= inputBounds
.left
+ inputBounds
.width
- 11;
61 var midY
= inputBounds
.top
+ inputBounds
.height
/ 2;
71 left
: inputBounds
.left
,
73 width
: inputBounds
.width
- 16,
74 height
: inputBounds
.height
77 debug('\nTouch centered on cancel button but overlapping neighboring candidate.');
78 testTouch(midX
, midY
, touchRadius
, cancelBounds
);
80 debug('\nOff-center touches enclosing cancel button.');
81 testTouch(midX
- offset
, midY
, touchRadius
, cancelBounds
);
82 testTouch(midX
- offset
, midY
+ offset
, touchRadius
, cancelBounds
);
83 testTouch(midX
- offset
, midY
- offset
, touchRadius
, cancelBounds
);
85 debug('\nTouches clipping left edge of cancel-button.');
86 testTouch(midX
- touchRadius
- 2, midY
, touchRadius
, textContentBounds
);
87 testTouch(midX
- touchRadius
- 2, midY
- offset
, touchRadius
, textContentBounds
);
88 testTouch(midX
- touchRadius
- 2, midY
+ offset
, touchRadius
, textContentBounds
);
91 function testTouch(touchX
, touchY
, radius
, bounds
) {
93 targetBounds
= bounds
;
96 left
: touchX
- radius
,
101 adjustedPoint
= internals
.touchPositionAdjustedToBestClickableNode(touchBounds
.left
, touchBounds
.top
, touchBounds
.width
, touchBounds
.height
, document
);
102 targetContainsPoint
= containsPoint(targetBounds
, adjustedPoint
);
103 touchContainsPoint
= containsPoint(touchBounds
, adjustedPoint
);
104 shouldBeTrue('targetContainsPoint');
105 shouldBeTrue('touchContainsPoint');
108 function containsPoint(bounds
, point
) {
109 return bounds
.left
<= point
.x
&& bounds
.top
<= point
.y
&& bounds
.left
+ bounds
.width
>= point
.x
&& bounds
.left
+ bounds
.height
>= point
.y
;
114 if (window
.testRunner
&& window
.internals
&& internals
.touchNodeAdjustedToBestClickableNode
) {
115 description('Test touch adjustment on a search field with a visible cancel button.');