1 var targetsDiv = document.createElement("div");
2 targetsDiv.id = "targetsDiv";
4 var div1 = document.createElement("div");
6 div1.style.width = "100px";
7 div1.style.height = "100px";
8 div1.style.backgroundColor = "blue";
10 var div2 = document.createElement("div");
12 div2.style.width = "100px";
13 div2.style.height = "100px";
14 div2.style.backgroundColor = "green";
16 document.body.insertBefore(targetsDiv, document.getElementById('console'));
17 targetsDiv.appendChild(div1);
18 targetsDiv.appendChild(document.createElement('br'));
19 targetsDiv.appendChild(div2);
21 function declareTouchHandler(div_id, expectedTargetTouches)
25 // Do not use the parameters (div_id, expectedTargetTouches) in shouldBe.. calls, as
26 // the order of event dispatch is not deterministic across executions and reordering
27 // ofthe PASS debug output details would cause the test to be unreliable.
28 shouldBe('event.touches.length', '3');
29 if (event.targetTouches.length != expectedTargetTouches)
30 testFailed('Wrong targetTouch length: ' + event.targetTouches.length + ' vs ' + expectedTargetTouches);
31 for (var i = 0; i < event.targetTouches.length; i++)
33 if (event.targetTouches[i].target.id != div_id)
34 testFailed('Incorrect targetTouch ID: ' + event.targetTouches[i].target.id + ' vs ' + div_id);
36 shouldBe('event.changedTouches.length', '3');
41 function touchEndHandler()
43 shouldBeEqualToString('event.type', 'touchend');
45 shouldBe('event.touches.length', '0');
46 shouldBe('event.targetTouches.length', '0');
47 shouldBe('event.changedTouches.length', '3');
51 testRunner.notifyDone();
52 isSuccessfullyParsed();
56 div1.addEventListener("touchstart", declareTouchHandler('targetA', '2'), false);
57 div1.addEventListener("touchmove", declareTouchHandler('targetA', '2'), false);
58 div1.addEventListener("touchend", touchEndHandler, false);
60 div2.addEventListener("touchstart", declareTouchHandler('targetB', '1'), false);
61 div2.addEventListener("touchmove", declareTouchHandler('targetB', '1'), false);
62 div2.addEventListener("touchend", touchEndHandler, false);
64 description("Tests that the an event is sent for every touch listener, and target touches contains all the points for that target");
66 if (window.testRunner) {
67 testRunner.waitUntilDone();
70 if (window.eventSender) {
71 eventSender.clearTouchPoints();
72 eventSender.addTouchPoint(50, 150);
73 eventSender.addTouchPoint(50, 250);
74 eventSender.addTouchPoint(50, 150);
75 eventSender.touchStart();
77 eventSender.updateTouchPoint(0, 200, 150);
78 eventSender.updateTouchPoint(1, 300, 250);
79 eventSender.updateTouchPoint(2, 400, 150);
80 eventSender.touchMove();
82 eventSender.releaseTouchPoint(0);
83 eventSender.releaseTouchPoint(1);
84 eventSender.releaseTouchPoint(2);
85 eventSender.touchEnd();
87 debug('This test requires DRT.');