1var targetsDiv = document.createElement("div"); 2targetsDiv.id = "targetsDiv"; 3 4var div1 = document.createElement("div"); 5div1.id = "targetA"; 6div1.style.width = "100px"; 7div1.style.height = "100px"; 8div1.style.backgroundColor = "blue"; 9 10var div2 = document.createElement("div"); 11div2.id = "targetB"; 12div2.style.width = "100px"; 13div2.style.height = "100px"; 14div2.style.backgroundColor = "green"; 15 16document.body.insertBefore(targetsDiv, document.getElementById('console')); 17targetsDiv.appendChild(div1); 18targetsDiv.appendChild(document.createElement('br')); 19targetsDiv.appendChild(div2); 20 21function declareTouchHandler(div_id, expectedTargetTouches) 22{ 23 return function () 24 { 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++) 32 { 33 if (event.targetTouches[i].target.id != div_id) 34 testFailed('Incorrect targetTouch ID: ' + event.targetTouches[i].target.id + ' vs ' + div_id); 35 } 36 shouldBe('event.changedTouches.length', '3'); 37 } 38} 39 40var endCount = 0; 41function touchEndHandler() 42{ 43 shouldBeEqualToString('event.type', 'touchend'); 44 45 shouldBe('event.touches.length', '0'); 46 shouldBe('event.targetTouches.length', '0'); 47 shouldBe('event.changedTouches.length', '3'); 48 49 if (++endCount == 2) 50 { 51 successfullyParsed = true; 52 layoutTestController.notifyDone(); 53 isSuccessfullyParsed(); 54 } 55} 56 57div1.addEventListener("touchstart", declareTouchHandler('targetA', '2'), false); 58div1.addEventListener("touchmove", declareTouchHandler('targetA', '2'), false); 59div1.addEventListener("touchend", touchEndHandler, false); 60 61div2.addEventListener("touchstart", declareTouchHandler('targetB', '1'), false); 62div2.addEventListener("touchmove", declareTouchHandler('targetB', '1'), false); 63div2.addEventListener("touchend", touchEndHandler, false); 64 65description("Tests that the an event is sent for every touch listener, and target touches contains all the points for that target"); 66 67if (window.layoutTestController) { 68 layoutTestController.waitUntilDone(); 69} 70 71if (window.eventSender) { 72 eventSender.clearTouchPoints(); 73 eventSender.addTouchPoint(50, 150); 74 eventSender.addTouchPoint(50, 250); 75 eventSender.addTouchPoint(50, 150); 76 eventSender.touchStart(); 77 78 eventSender.updateTouchPoint(0, 200, 150); 79 eventSender.updateTouchPoint(1, 300, 250); 80 eventSender.updateTouchPoint(2, 400, 150); 81 eventSender.touchMove(); 82 83 eventSender.releaseTouchPoint(0); 84 eventSender.releaseTouchPoint(1); 85 eventSender.releaseTouchPoint(2); 86 eventSender.touchEnd(); 87} else 88 debug('This test requires DRT.'); 89 90