1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
var targetsDiv = document.createElement("div");
targetsDiv.id = "targetsDiv";
var div1 = document.createElement("div");
div1.id = "targetA";
div1.style.width = "100px";
div1.style.height = "100px";
div1.style.backgroundColor = "blue";
var div2 = document.createElement("div");
div2.id = "targetB";
div2.style.width = "100px";
div2.style.height = "100px";
div2.style.backgroundColor = "green";
var touchStartCount = 0;
var touchMoveCount = 0;
document.body.insertBefore(targetsDiv, document.getElementById('console'));
targetsDiv.appendChild(div1);
targetsDiv.appendChild(document.createElement('br'));
targetsDiv.appendChild(div2);
function touchStartHandler()
{
shouldBeEqualToString('event.type', 'touchstart');
switch (touchStartCount) {
case 0:
shouldBeEqualToString('event.touches[0].target.id', div1.id);
shouldBeEqualToString('event.touches[1].target.id', div2.id);
break;
case 1:
shouldBeEqualToString('event.touches[0].target.id', div2.id);
shouldBeEqualToString('event.touches[1].target.id', div1.id);
break;
}
touchStartCount++;
}
function touchMoveHandler()
{
shouldBeEqualToString('event.type', 'touchmove');
switch (touchMoveCount) {
case 0:
case 1:
shouldBeEqualToString('event.touches[0].target.id', div1.id);
shouldBeEqualToString('event.touches[1].target.id', div2.id);
break;
case 2:
shouldBeEqualToString('event.touches[0].target.id', div2.id);
shouldBeEqualToString('event.touches[1].target.id', div1.id);
break;
}
if (++touchMoveCount == 3)
{
successfullyParsed = true;
layoutTestController.notifyDone();
isSuccessfullyParsed();
}
}
div1.addEventListener("touchstart", touchStartHandler, false);
div1.addEventListener("touchmove", touchMoveHandler, false);
div2.addEventListener("touchstart", touchStartHandler, false);
div2.addEventListener("touchmove", touchMoveHandler, false);
description("Tests that the target of touches match the element where the event originated, not where the touch is currently occurring. This is a limited version of test touch-target.html that avoids the situation where one touch point is released while another is maintained.");
if (window.layoutTestController) {
layoutTestController.waitUntilDone();
}
if (window.eventSender) {
eventSender.clearTouchPoints();
eventSender.addTouchPoint(50, 150);
eventSender.addTouchPoint(50, 250);
eventSender.touchStart();
eventSender.updateTouchPoint(0, 50, 250);
eventSender.updateTouchPoint(1, 50, 150);
eventSender.touchMove();
eventSender.updateTouchPoint(0, 1000, 1000);
eventSender.updateTouchPoint(1, 1000, 1000);
eventSender.touchMove();
eventSender.releaseTouchPoint(0);
eventSender.releaseTouchPoint(1);
eventSender.touchEnd();
eventSender.addTouchPoint(50, 250);
eventSender.addTouchPoint(50, 150);
eventSender.touchStart();
eventSender.updateTouchPoint(0, 500, 500);
eventSender.updateTouchPoint(1, 500, 500);
eventSender.touchMove();
} else
debug('This test requires DRT.');
|