7 function handleClick(evt
) {
9 document
.getElementById('click').textContent
= 'PASS';
12 function handleTouchStart(evt
) {
14 document
.getElementById('touchstart').textContent
= 'PASS';
17 function handleTouchMove(evt
) {
19 document
.getElementById('touchmove').textContent
= 'PASS';
22 function handleTouchEnd(evt
) {
24 document
.getElementById('touchend').textContent
= 'PASS';
27 function handleTouchCancel(evt
) {
29 document
.getElementById('touchcancel').textContent
= 'PASS';
32 function fireEvents() {
33 if (!window
.testRunner
|| !window
.eventSender
) {
34 document
.write('This test does not work in manual mode.');
36 var svg
= document
.getElementById('svg');
37 var positionX
= svg
.offsetLeft
+ 30;
38 var positionY
= svg
.offsetTop
+ 30;
41 eventSender
.addTouchPoint(positionX
, positionY
);
42 eventSender
.touchStart();
43 eventSender
.updateTouchPoint(0, positionX
+ 10, positionY
+ 10);
44 eventSender
.touchMove();
45 eventSender
.releaseTouchPoint(0);
46 eventSender
.touchEnd();
48 eventSender
.addTouchPoint(positionX
, positionY
);
49 eventSender
.touchStart();
50 eventSender
.updateTouchPoint(0, positionX
+ 10, positionY
+ 10);
51 eventSender
.cancelTouchPoint(0);
52 eventSender
.touchCancel();
54 eventSender
.mouseMoveTo(positionX
, positionY
);
55 eventSender
.mouseDown();
56 eventSender
.mouseUp();
58 // Fire some events that do not hit the rect.
59 eventSender
.addTouchPoint(positionX
- 30, positionY
- 30);
60 eventSender
.touchStart();
61 eventSender
.updateTouchPoint(0, positionX
+ 5, positionY
+ 5);
62 eventSender
.touchMove();
63 eventSender
.releaseTouchPoint(0);
64 eventSender
.touchEnd();
66 document
.getElementById('eventcount').textContent
=
67 eventCount
== 6 ? 'PASS' : 'FAIL: expected 6 events, got ' + eventCount
;
69 testRunner
.dumpAsText();
74 <body onload=
"fireEvents()">
75 This test passes if you see a series of PASS lines below:
<br/>
76 onclick fired:
<span id=
"click">FAIL
</span><br/>
77 ontouchstart fired:
<span id=
"touchstart">FAIL
</span><br/>
78 ontouchmove fired:
<span id=
"touchmove">FAIL
</span><br/>
79 ontouchend fired:
<span id=
"touchend">FAIL
</span><br/>
80 ontouchcancel fired:
<span id=
"touchcancel">FAIL
</span><br/>
81 total event count is
6:
<span id=
"eventcount">FAIL
</span><br/>
82 <svg xmlns=
"http://www.w3.org/2000/svg" xmlns:
xlink=
"http://www.w3.org/1999/xlink" width=
"100" height=
"100" id=
"svg">
83 <rect id=
"rect" x=
"20" y=
"20" width=
"60" height=
"60" fill=
"green" onclick=
"handleClick()" ontouchstart=
"handleTouchStart()" ontouchmove=
"handleTouchMove()" ontouchend=
"handleTouchEnd()" ontouchcancel=
"handleTouchCancel()"/>