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 declareTouchStart()
23 var touchStartCount = 0;
24 return function touchStartHandler()
26 shouldBeEqualToString('event.type', 'touchstart');
27 switch (touchStartCount) {
29 shouldBeEqualToString('event.touches[0].target.id', div1.id);
30 shouldBeEqualToString('event.touches[1].target.id', div2.id);
33 shouldBeEqualToString('event.touches[0].target.id', div2.id);
34 shouldBeEqualToString('event.touches[1].target.id', div1.id);
37 shouldBe('event.targetTouches.length', '1');
43 var totalTouchMoveCount = 0;
45 function declareTouchMove(div_id)
47 var touchMoveCount = 0;
48 return function touchMoveHandler()
50 shouldBeEqualToString('event.type', 'touchmove');
51 switch (touchMoveCount) {
54 shouldBeEqualToString('event.touches[0].target.id', div1.id);
55 shouldBeEqualToString('event.touches[1].target.id', div2.id);
58 shouldBeEqualToString('event.touches[0].target.id', div2.id);
59 shouldBeEqualToString('event.touches[1].target.id', div1.id);
62 shouldBe('event.targetTouches.length', '1');
65 if (++totalTouchMoveCount == 6)
67 testRunner.notifyDone();
68 isSuccessfullyParsed();
73 div1.addEventListener("touchstart", declareTouchStart(), false);
74 div1.addEventListener("touchmove", declareTouchMove(), false);
76 div2.addEventListener("touchstart", declareTouchStart(), false);
77 div2.addEventListener("touchmove", declareTouchMove(), false);
79 description("Tests that the target of touches match the element where the event originated, not where the touch is currently occurring.");
81 if (window.testRunner) {
82 testRunner.waitUntilDone();
85 if (window.eventSender) {
86 eventSender.clearTouchPoints();
87 eventSender.addTouchPoint(50, 150);
88 eventSender.addTouchPoint(50, 250);
89 eventSender.touchStart();
91 eventSender.updateTouchPoint(0, 50, 250);
92 eventSender.updateTouchPoint(1, 50, 150);
93 eventSender.touchMove();
95 eventSender.updateTouchPoint(0, 1000, 1000);
96 eventSender.updateTouchPoint(1, 1000, 1000);
97 eventSender.touchMove();
99 eventSender.releaseTouchPoint(0);
100 eventSender.touchEnd();
102 eventSender.addTouchPoint(50,150);
103 eventSender.touchStart();
105 eventSender.updateTouchPoint(0, 500, 500);
106 eventSender.updateTouchPoint(1, 500, 500);
107 eventSender.touchMove();
109 debug('This test requires DRT.');