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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=968148
-->
<head>
<title>Test for Bug 968148</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<style>
.test {
width: 20px;
height: 20px;
border: 1px solid black;
-moz-user-select: none;
}
</style>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=968148">Mozilla Bug 968148</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script type="application/javascript">
/**
* Test for Bug 968148, test orignally copied from test_bug582771.html.
* Mouse functionality converted to pointer and all steps duplicated in order to run them in parallel for two different pointer Id's
**/
function ok(condition, msg) {
parent.ok(condition, msg);
}
function is(a, b, msg) {
parent.is(a, b, msg);
}
var test1d1;
var test1d2;
var test2d1;
var test2d2;
var test1d1pointermovecount = 0;
var test1d2pointermovecount = 0;
var test2d1pointermovecount = 0;
var test2d2pointermovecount = 0;
var test1d1pointerlostcapture = 0;
var test1d2pointerlostcapture = 0;
var test2d1pointerlostcapture = 0;
var test2d2pointerlostcapture = 0;
var test1d1pointergotcapture = 0;
var test1d2pointergotcapture = 0;
var test2d1pointergotcapture = 0;
var test2d2pointergotcapture = 0;
var test1PointerId = 1;
var test2PointerId = 2;
var rx = 1;
var ry = 1;
var angle = 0;
var force = 1;
var modifiers = 0;
var utils = SpecialPowers.getDOMWindowUtils(window);
function log(s) {
document.getElementById("l").textContent += s + "\n";
}
function test1d1IncreasePointerMoveCount(e) {
log(e.type + ", " + e.target.id);
is(e.target, test1d1, "check target is 1d1.");
++test1d1pointermovecount;
}
function test1d2IncreasePointerMoveCount(e) {
log(e.type + ", " + e.target.id);
is(e.target, test1d2, "check target is 1d2.");
++test1d2pointermovecount;
}
function test2d1IncreasePointerMoveCount(e) {
log(e.type + ", " + e.target.id);
is(e.target, test2d1, "check target is 2d1.");
++test2d1pointermovecount;
}
function test2d2IncreasePointerMoveCount(e) {
log(e.type + ", " + e.target.id);
is(e.target, test2d2, "check target is 2d2.");
++test2d2pointermovecount;
}
function test1d1CapturePointer(e) {
log(e.type + ", " + e.target.id);
test1d1.setPointerCapture(e.pointerId);
}
function test1d2CapturePointer(e) {
log(e.type + ", " + e.target.id);
test1d2.setPointerCapture(e.pointerId);
}
function test2d1CapturePointer(e) {
log(e.type + ", " + e.target.id);
test2d1.setPointerCapture(e.pointerId);
}
function test2d2CapturePointer(e) {
log(e.type + ", " + e.target.id);
test2d2.setPointerCapture(e.pointerId);
}
function test1d1PointerGotCapture(e) {
log(e.type + ", " + e.target.id);
++test1d1pointergotcapture;
}
function test1d1PointerLostCapture(e) {
log(e.type + ", " + e.target.id);
++test1d1pointerlostcapture;
}
function test2d1PointerGotCapture(e) {
log(e.type + ", " + e.target.id);
++test2d1pointergotcapture;
}
function test2d1PointerLostCapture(e) {
log(e.type + ", " + e.target.id);
++test2d1pointerlostcapture;
}
function test1d2PointerGotCapture(e) {
log(e.type + ", " + e.target.id);
++test1d2pointergotcapture;
}
function test1d2PointerLostCapture(e) {
log(e.type + ", " + e.target.id);
++test1d2pointerlostcapture;
}
function test2d2PointerGotCapture(e) {
log(e.type + ", " + e.target.id);
++test2d2pointergotcapture;
}
function test2d2PointerLostCapture(e) {
log(e.type + ", " + e.target.id);
++test2d2pointerlostcapture;
}
function runTests() {
test1d1 = document.getElementById("test1d1");
test1d2 = document.getElementById("test1d2");
test2d1 = document.getElementById("test2d1");
test2d2 = document.getElementById("test2d2");
var rect1d1 = test1d1.getBoundingClientRect();
var rect1d2 = test1d2.getBoundingClientRect();
var rect2d1 = test2d1.getBoundingClientRect();
var rect2d2 = test2d2.getBoundingClientRect();
var left1d1 = rect1d1.left + 5;
var top1d1 = rect1d1.top + 5;
var left1d2 = rect1d2.left + 5;
var top1d2 = rect1d2.top + 5;
var left2d1 = rect2d1.left + 5;
var top2d1 = rect2d1.top + 5;
var left2d2 = rect2d2.left + 5;
var top2d2 = rect2d2.top + 5;
test1d1.addEventListener("pointermove", test1d1IncreasePointerMoveCount, true);
test1d2.addEventListener("pointermove", test1d2IncreasePointerMoveCount, true);
test2d1.addEventListener("pointermove", test2d1IncreasePointerMoveCount, true);
test2d2.addEventListener("pointermove", test2d2IncreasePointerMoveCount, true);
test1d1.addEventListener("gotpointercapture", test1d1PointerGotCapture, true);
test1d1.addEventListener("lostpointercapture", test1d1PointerLostCapture, true);
test2d1.addEventListener("gotpointercapture", test2d1PointerGotCapture, true);
test2d1.addEventListener("lostpointercapture", test2d1PointerLostCapture, true);
test1d2.addEventListener("gotpointercapture", test1d2PointerGotCapture, true);
test1d2.addEventListener("lostpointercapture", test1d2PointerLostCapture, true);
test2d2.addEventListener("gotpointercapture", test2d2PointerGotCapture, true);
test2d2.addEventListener("lostpointercapture", test2d2PointerLostCapture, true);
document.body.offsetLeft;
// This shouldn't enable capturing, since we're not in a right kind of
// event listener.
utils.sendTouchEvent('touchstart', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
[left1d2, left2d2], [top1d2, top2d2], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
utils.sendTouchEvent('touchend', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
// Implicitly pointer capture. pointermove should be dispatched to 1d1, 2d1
is(test1d1pointermovecount, 1, "1d1 should have got pointermove");
is(test2d1pointermovecount, 1, "2d1 should have got pointermove");
is(test1d2pointermovecount, 0, "1d2 shouldn't have got pointermove");
is(test2d2pointermovecount, 0, "2d2 shouldn't have got pointermove");
// Explicitly capture pointer to 1d1, 2d1
test1d1.addEventListener("pointerdown", test1d1CapturePointer, {capture: true, once: true});
test2d1.addEventListener("pointerdown", test2d1CapturePointer, {capture: true, once: true});
utils.sendTouchEvent('touchstart', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
[left1d2, left2d2], [top1d2, top2d2], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
// Explicitly capture pointer to 1d1, 2d1. pointermove, gotpointercapture
// should be dispatched to 1d1, 2d1
is(test1d1pointermovecount, 2, "1d1 should have got pointermove");
is(test1d1pointergotcapture, 2, "1d1 should have got pointergotcapture");
is(test1d2pointermovecount, 0, "1d2 shouldn't have got pointermove");
is(test1d2pointergotcapture, 0, "1d2 shouldn't have got pointergotcapture");
is(test2d1pointermovecount, 2, "2d1 should have got pointermove");
is(test2d1pointergotcapture, 2, "2d1 should have got pointergotcapture");
is(test2d2pointermovecount, 0, "2d2 shouldn't have got pointermove");
is(test2d2pointergotcapture, 0, "2d2 shouldn't have got pointergotcapture");
utils.sendTouchEvent('touchend', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
// Explicitly capture pointer to 1d1, 2d1 when pointerdown
test1d1.addEventListener("pointerdown", test1d1CapturePointer, {capture: true, once: true});
test2d1.addEventListener("pointerdown", test2d1CapturePointer, {capture: true, once: true});
// Explicitly capture pointer to 1d2, 2d2 when pointermove
test1d1.addEventListener("pointermove", test1d2CapturePointer, {capture: true, once: true});
test2d1.addEventListener("pointermove", test2d2CapturePointer, {capture: true, once: true});
utils.sendTouchEvent('touchstart', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
// This should send pointer event to test1d1, test2d1.
utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
[left1d1 + 5, left2d1 + 5], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
// This should send pointer event to test1d2, test2d2.
utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId],
[left1d1 + 5, left2d1 + 5], [top1d1 + 5, top2d1 + 5], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
is(test1d1pointermovecount, 3, "1d1 shouldn't have got pointermove");
is(test1d1pointergotcapture, 3, "1d1 should have got pointergotcapture");
is(test1d2pointermovecount, 1, "1d2 should have got pointermove");
is(test1d2pointergotcapture, 1, "1d2 should have got pointergotcapture");
is(test2d1pointermovecount, 3, "2d1 shouldn't have got pointermove");
is(test2d1pointergotcapture, 3, "2d1 should have got pointergotcapture");
is(test2d2pointermovecount, 1, "2d2 should have got pointermove");
is(test2d2pointergotcapture, 1, "2d2 should have got pointergotcapture");
utils.sendTouchEvent('touchend', [test1PointerId, test2PointerId],
[left1d1, left2d1], [top1d1, top2d1], [rx, rx], [ry, ry],
[angle, angle], [force, force], [0, 0], [0, 0],
[0, 0], modifiers);
finishTest();
}
function finishTest() {
// Let window.onerror have a chance to fire
setTimeout(function() {
setTimeout(function() {
window.parent.postMessage("finishTest", "*");
}, 0);
}, 0);
}
window.onload = function () {
SpecialPowers.pushPrefEnv({
"set": [
["dom.w3c_pointer_events.implicit_capture", true]
]
}, runTests);
}
SimpleTest.waitForExplicitFinish();
</script>
</pre>
<div class="test" id="test1d1"> </div><br><div class="test" id="test1d2"> </div>
<div class="test" id="test2d1"> </div><br><div class="test" id="test2d2"> </div>
<pre id="l"></pre>
</body>
</html>
|