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 declareTouchStart() 22{ 23 var touchStartCount = 0; 24 return function touchStartHandler() 25 { 26 shouldBeEqualToString('event.type', 'touchstart'); 27 switch (touchStartCount) { 28 case 0: 29 shouldBeEqualToString('event.touches[0].target.id', div1.id); 30 shouldBeEqualToString('event.touches[1].target.id', div2.id); 31 break; 32 case 1: 33 shouldBeEqualToString('event.touches[0].target.id', div2.id); 34 shouldBeEqualToString('event.touches[1].target.id', div1.id); 35 break; 36 } 37 shouldBe('event.targetTouches.length', '1'); 38 39 touchStartCount++; 40 } 41} 42 43var totalTouchMoveCount = 0; 44 45function declareTouchMove(div_id) 46{ 47 var touchMoveCount = 0; 48 return function touchMoveHandler() 49 { 50 shouldBeEqualToString('event.type', 'touchmove'); 51 switch (touchMoveCount) { 52 case 0: 53 case 1: 54 shouldBeEqualToString('event.touches[0].target.id', div1.id); 55 shouldBeEqualToString('event.touches[1].target.id', div2.id); 56 break; 57 case 2: 58 shouldBeEqualToString('event.touches[0].target.id', div2.id); 59 shouldBeEqualToString('event.touches[1].target.id', div1.id); 60 break; 61 } 62 shouldBe('event.targetTouches.length', '1'); 63 ++touchMoveCount; 64 65 if (++totalTouchMoveCount == 6) 66 { 67 successfullyParsed = true; 68 layoutTestController.notifyDone(); 69 isSuccessfullyParsed(); 70 } 71 } 72} 73 74div1.addEventListener("touchstart", declareTouchStart(), false); 75div1.addEventListener("touchmove", declareTouchMove(), false); 76 77div2.addEventListener("touchstart", declareTouchStart(), false); 78div2.addEventListener("touchmove", declareTouchMove(), false); 79 80description("Tests that the target of touches match the element where the event originated, not where the touch is currently occurring."); 81 82if (window.layoutTestController) { 83 layoutTestController.waitUntilDone(); 84} 85 86if (window.eventSender) { 87 eventSender.clearTouchPoints(); 88 eventSender.addTouchPoint(50, 150); 89 eventSender.addTouchPoint(50, 250); 90 eventSender.touchStart(); 91 92 eventSender.updateTouchPoint(0, 50, 250); 93 eventSender.updateTouchPoint(1, 50, 150); 94 eventSender.touchMove(); 95 96 eventSender.updateTouchPoint(0, 1000, 1000); 97 eventSender.updateTouchPoint(1, 1000, 1000); 98 eventSender.touchMove(); 99 100 eventSender.releaseTouchPoint(0); 101 eventSender.touchEnd(); 102 103 eventSender.addTouchPoint(50,150); 104 eventSender.touchStart(); 105 106 eventSender.updateTouchPoint(0, 500, 500); 107 eventSender.updateTouchPoint(1, 500, 500); 108 eventSender.touchMove(); 109} else 110 debug('This test requires DRT.'); 111 112