4 <title>Touch Adjustment : Testing that active will be set on a tapDown - bug
96677</title>
5 <script src=
"../resources/js-test.js"></script>
6 <script src=
"resources/touchadjustment.js"></script>
14 background-color: rgb(
255,
255,
255);
17 background-color: rgb(
0,
0,
255);
25 <p><a href=
"" id=
"link1">I
</a> propose to consider
<a href=
"" id=
"link2">the question
</a>,
"Can machines think?"<br>This should begin with definitions of the meaning of the terms
"machine" and
<a href=
"" id=
"link3">"think."</a></p>
28 <p id='description'
></p>
29 <div id='console'
></div>
34 // Set up shortcut access to elements
36 ['sandbox', 'link1', 'link2', 'link3'].forEach(function(a
) {
37 e
[a
] = document
.getElementById(a
);
42 function isLinkActive()
44 // These need to match the background-color used above, after round-tripping.
45 var defaultColor
= "rgb(255, 255, 255)";
46 var activeColor
= "rgb(0, 0, 255)";
48 color
= window
.getComputedStyle(curElement
).backgroundColor
;
49 if (color
== activeColor
)
51 if (color
!= defaultColor
)
52 testFailed('Got unexpected backgroundColor: ' + color
);
56 function testTapDown(touchpoint
, element
)
59 if (isLinkActive()) testFailed('Link unexpectedly active on entry');
60 eventSender
.gestureShowPress(touchpoint
.x
, touchpoint
.y
, touchpoint
.width
, touchpoint
.height
);
61 shouldBeTrue("isLinkActive()");
62 eventSender
.gestureTapCancel(touchpoint
.x
, touchpoint
.y
);
63 if (isLinkActive()) testFailed('Link unexpectedly active on exit');
66 function testDirectTouch(element
)
68 // Touch directly in the center of the element.
69 var touchpoint
= offsetTouchPoint(findAbsoluteBounds(element
), 'center', 0, 20, 30);
70 if (document
.elementFromPoint(touchpoint
.x
, touchpoint
.y
) != element
)
71 testFailed('Direct touch ended up on some other element');
72 testTapDown(touchpoint
, element
);
75 function isDescendantOf(parent
, child
)
86 function testIndirectTouch(element
)
88 // Touch just right of the element.
89 var touchpoint
= offsetTouchPoint(findAbsoluteBounds(element
), 'right', 10, 30, 20);
90 if (isDescendantOf(element
, document
.elementFromPoint(touchpoint
.x
, touchpoint
.y
)))
91 testFailed('Indirect touch ended up still on top of the element');
92 testTapDown(touchpoint
, element
);
95 function testDirectTouches()
97 debug('Testing direct hits.');
98 testDirectTouch(e
.link1
);
99 testDirectTouch(e
.link2
);
100 testDirectTouch(e
.link3
);
103 function testIndirectTouches()
105 debug('Testing indirect hits.');
106 testIndirectTouch(e
.link1
);
107 testIndirectTouch(e
.link2
);
108 testIndirectTouch(e
.link3
);
113 if (!window
.eventSender
) {
114 debug('This test requires DumpRenderTree');
117 if (!window
.eventSender
.gestureShowPress
) {
118 debug('GestureShowPress not supported by this platform');
122 description('Tests that tapDown will trigger the active state.');
123 testIndirectTouches();
125 e
.sandbox
.style
.display
= 'none';