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
|
<!doctype html>
<html>
<head>
<title>Pointer Event: touch-action test for two-finger interaction</title>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>
<link rel="author" title="Google" href="http://www.google.com "/>
<link rel="help" href="https://compat.spec.whatwg.org/#touch-action" />
<meta name="assert" content="Tests that a two-finger pan gesture is cancelled in 'touch-action: pan-x pan-y' but is allowed in 'touch-action: pinch-zoom'"/>
<link rel="stylesheet" type="text/css" href="../pointerevent_styles.css">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script type="text/javascript" src="../pointerevent_support.js"></script>
<script type="text/javascript">
var event_log = [];
var active_pointers = 0;
function resetTestState() {
event_log = [];
active_pointers = 0;
}
function run() {
var test_pointer_events = [
setup_pointerevent_test("two-finger pan on 'touch-action: pan-x pan-y'", ["touch"]),
setup_pointerevent_test("two-finger pan on 'touch-action: pinch-zoom'", ["touch"])
];
var expected_events = [
"pointerdown@black, pointerdown@black, pointerup@black, pointerup@black",
"pointerdown@grey, pointerdown@grey, pointercancel@grey, pointercancel@grey"
];
var current_test_index = 0;
on_event(document.getElementById("done"), "click", function() {
test_pointer_events[current_test_index].step(function () {
assert_equals(active_pointers, 0);
assert_equals(event_log.join(", "), expected_events[current_test_index]);
});
event_log = [];
test_pointer_events[current_test_index++].done();
});
var targets = [document.getElementById("black"), document.getElementById("grey")];
["pointerdown", "pointerup", "pointercancel"].forEach(function(eventName) {
targets.forEach(function(target){
on_event(target, eventName, function (event) {
event_log.push(event.type + "@" + event.target.id);
if (event.type == "pointerdown") {
active_pointers++;
} else {
active_pointers--;
}
});
});
});
}
</script>
<style>
.box {
width: 250px;
height: 150px;
float: left;
margin: 10px;
}
#black {
touch-action: pan-x pan-y;
background-color: black;
}
#grey {
touch-action: pinch-zoom;
background-color: grey;
}
#done {
float: left;
padding: 20px;
}
</style>
</head>
<body onload="run()">
<h1>Pointer Event: touch-action test for two-finger interaction</h1>
<h2 id="pointerTypeDescription"></h2>
<h4>
Tests that a two-finger pan gesture is cancelled in 'touch-action: pan-x pan-y' but is allowed in 'touch-action: pinch-zoom'
</h4>
<ol>
<li>Touch on Black with two fingers and drag both fingers down at same speed.</li>
<li>Tap on Done.</li>
<li>Touch on Grey with two fingers and drag both fingers down at same speed.</li>
<li>Tap on Done.</li>
</ol>
<div class="box" id="black"></div>
<input type="button" id="done" value="Done" />
<div class="box" id="grey"></div>
<div id="log"></div>
</body>
</html>
|