Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 <!DOCTYPE HTML>
2 <html>
3 <head>
4 <title>Test for MozMousePixelScroll events</title>
5 <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
6 <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
7 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
8 <style>
9 .scrollable {
10 overflow: auto;
11 line-height: 1;
12 margin: 15px;
13 }
14 .scrollable > div {
15 width: 1000px;
16 height: 1000px;
17 font-size: 1000px;
18 line-height: 1;
19 }
20 </style>
21 </head>
22 <body>
23 <p id="display"></p>
24 <div id="Scrollable128" class="scrollable" style="font-size: 128px; width: 100px; height: 100px;">
25 <div>
26 <div id="Scrollable96" class="scrollable" style="font-size: 96px; width: 150px; height: 150px;">
27 <div>
28 <div id="Scrollable64" class="scrollable" style="font-size: 64px; width: 200px; height: 200px;">
29 <div>
30 </div>
31 </div>
32 </div>
33 </div>
34 </div>
35 </div>
36 <div id="Scrollable32" class="scrollable" style="font-size: 32px; width: 50px; height: 50px;">
37 <div>
38 </div>
39 </div>
40 <div id="content" style="display: none">
42 </div>
43 <pre id="test">
44 <script type="application/javascript">
46 SimpleTest.waitForExplicitFinish();
47 SimpleTest.waitForFocus(runTests, window);
49 var gScrollable128 = document.getElementById("Scrollable128");
50 var gScrollable96 = document.getElementById("Scrollable96");
51 var gScrollable64 = document.getElementById("Scrollable64");
52 var gScrollable32 = document.getElementById("Scrollable32");
53 var gRoot = document.documentElement;
55 function prepareScrollUnits()
56 {
57 var result = -1;
58 function handler(aEvent)
59 {
60 result = aEvent.detail;
61 aEvent.preventDefault();
62 }
63 window.addEventListener("MozMousePixelScroll", handler, true);
65 synthesizeWheel(gScrollable128, 10, 10,
66 { deltaMode: WheelEvent.DOM_DELTA_LINE,
67 deltaY: 1.0, lineOrPageDeltaY: 1 });
68 gScrollable128.wheelLineHeight = result;
69 ok(result > 96 && result < 200, "prepareScrollUnits: gScrollable128.wheelLineHeight may be illegal value, got " + result);
71 result = -1;
72 synthesizeWheel(gScrollable96, 10, 10,
73 { deltaMode: WheelEvent.DOM_DELTA_LINE,
74 deltaY: 1.0, lineOrPageDeltaY: 1 });
75 gScrollable96.wheelLineHeight = result;
76 ok(result > 64 && result < gScrollable128.wheelLineHeight, "prepareScrollUnits: gScrollable96.wheelLineHeight may be illegal value, got " + result);
78 result = -1;
79 synthesizeWheel(gScrollable64, 10, 10,
80 { deltaMode: WheelEvent.DOM_DELTA_LINE,
81 deltaY: 1.0, lineOrPageDeltaY: 1 });
82 gScrollable64.wheelLineHeight = result;
83 ok(result > 32 && result < gScrollable96.wheelLineHeight, "prepareScrollUnits: gScrollable64.wheelLineHeight may be illegal value, got " + result);
85 result = -1;
86 synthesizeWheel(gScrollable32, 10, 10,
87 { deltaMode: WheelEvent.DOM_DELTA_LINE,
88 deltaY: 1.0, lineOrPageDeltaY: 1 });
89 gScrollable32.wheelLineHeight = result;
90 ok(result > 16 && result < gScrollable64.wheelLineHeight, "prepareScrollUnits: gScrollable32.wheelLineHeight may be illegal value, got " + result);
92 result = -1;
93 synthesizeWheel(gRoot, 10, 10,
94 { deltaMode: WheelEvent.DOM_DELTA_LINE,
95 deltaY: 1.0, lineOrPageDeltaY: 1 });
96 gRoot.wheelLineHeight = result;
97 ok(result > 10 && result < gScrollable32.wheelLineHeight, "prepareScrollUnits: gRoot.wheelLineHeight may be illegal value, got " + result);
99 result = -1;
100 synthesizeWheel(gScrollable128, 10, 10,
101 { deltaMode: WheelEvent.DOM_DELTA_LINE,
102 deltaX: 1.0, lineOrPageDeltaX: 1 });
103 gScrollable128.wheelHorizontalLine = result;
104 ok(result > 50 && result < 200, "prepareScrollUnits: gScrollable128.wheelHorizontalLine may be illegal value, got " + result);
106 result = -1;
107 synthesizeWheel(gScrollable96, 10, 10,
108 { deltaMode: WheelEvent.DOM_DELTA_LINE,
109 deltaX: 1.0, lineOrPageDeltaX: 1 });
110 gScrollable96.wheelHorizontalLine = result;
111 ok(result > 30 && result < gScrollable128.wheelHorizontalLine, "prepareScrollUnits: gScrollable96.wheelHorizontalLine may be illegal value, got " + result);
113 result = -1;
114 synthesizeWheel(gScrollable64, 10, 10,
115 { deltaMode: WheelEvent.DOM_DELTA_LINE,
116 deltaX: 1.0, lineOrPageDeltaX: 1 });
117 gScrollable64.wheelHorizontalLine = result;
118 ok(result > 20 && result < gScrollable96.wheelHorizontalLine, "prepareScrollUnits: gScrollable64.wheelHorizontalLine may be illegal value, got " + result);
120 result = -1;
121 synthesizeWheel(gScrollable32, 10, 10,
122 { deltaMode: WheelEvent.DOM_DELTA_LINE,
123 deltaX: 1.0, lineOrPageDeltaX: 1 });
124 gScrollable32.wheelHorizontalLine = result;
125 ok(result > 12 && result < gScrollable64.wheelHorizontalLine, "prepareScrollUnits: gScrollable32.wheelHorizontalLine may be illegal value, got " + result);
127 result = -1;
128 synthesizeWheel(gRoot, 10, 10,
129 { deltaMode: WheelEvent.DOM_DELTA_LINE,
130 deltaX: 1.0, lineOrPageDeltaX: 1 });
131 gRoot.wheelHorizontalLine = result;
132 ok(result > 5 && result < gScrollable32.wheelHorizontalLine, "prepareScrollUnits: gRoot.wheelHorizontalLine may be illegal value, got " + result);
134 result = -1;
135 synthesizeWheel(gScrollable128, 10, 10,
136 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
137 deltaY: 1.0, lineOrPageDeltaY: 1 });
138 gScrollable128.wheelPageHeight = result;
139 ok(result >= (100 - gScrollable128.wheelLineHeight * 2) && result <= 100,
140 "prepareScrollUnits: gScrollable128.wheelLineHeight is strange value, got " + result);
142 result = -1;
143 synthesizeWheel(gScrollable96, 10, 10,
144 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
145 deltaY: 1.0, lineOrPageDeltaY: 1 });
146 gScrollable96.wheelPageHeight = result;
147 ok(result >= (150 - gScrollable96.wheelLineHeight * 2) && result <= 150,
148 "prepareScrollUnits: gScrollable96.wheelLineHeight is strange value, got " + result);
150 result = -1;
151 synthesizeWheel(gScrollable64, 10, 10,
152 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
153 deltaY: 1.0, lineOrPageDeltaY: 1 });
154 gScrollable64.wheelPageHeight = result;
155 ok(result >= (200 - gScrollable64.wheelLineHeight * 2) && result <= 200,
156 "prepareScrollUnits: gScrollable64.wheelLineHeight is strange value, got " + result);
158 result = -1;
159 synthesizeWheel(gScrollable32, 10, 10,
160 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
161 deltaY: 1.0, lineOrPageDeltaY: 1 });
162 gScrollable32.wheelPageHeight = result;
163 ok(result >= (50 - gScrollable32.wheelLineHeight * 2) && result <= 50,
164 "prepareScrollUnits: gScrollable32.wheelLineHeight is strange value, got " + result);
166 result = -1;
167 synthesizeWheel(gRoot, 10, 10,
168 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
169 deltaY: 1.0, lineOrPageDeltaY: 1 });
170 gRoot.wheelPageHeight = result;
171 ok(window.innerHeight - result < 100 && window.innerHeight - result > 0,
172 "prepareScrollUnits: gRoot.wheelLineHeight is strange value, got " + result);
175 result = -1;
176 synthesizeWheel(gScrollable128, 10, 10,
177 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
178 deltaX: 1.0, lineOrPageDeltaX: 1 });
179 gScrollable128.wheelPageWidth = result;
180 ok(result >= (100 - gScrollable128.wheelLineHeight * 2) && result <= 100,
181 "prepareScrollUnits: gScrollable128.wheelPageWidth is strange value, got " + result);
183 result = -1;
184 synthesizeWheel(gScrollable96, 10, 10,
185 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
186 deltaX: 1.0, lineOrPageDeltaX: 1 });
187 gScrollable96.wheelPageWidth = result;
188 ok(result >= (150 - gScrollable96.wheelLineHeight * 2) && result <= 150,
189 "prepareScrollUnits: gScrollable96.wheelPageWidth is strange value, got " + result);
191 result = -1;
192 synthesizeWheel(gScrollable64, 10, 10,
193 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
194 deltaX: 1.0, lineOrPageDeltaX: 1 });
195 gScrollable64.wheelPageWidth = result;
196 ok(result >= (200 - gScrollable64.wheelLineHeight * 2) && result <= 200,
197 "prepareScrollUnits: gScrollable64.wheelPageWidth is strange value, got " + result);
199 result = -1;
200 synthesizeWheel(gScrollable32, 10, 10,
201 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
202 deltaX: 1.0, lineOrPageDeltaX: 1 });
203 gScrollable32.wheelPageWidth = result;
204 ok(result >= (50 - gScrollable32.wheelLineHeight * 2) && result <= 50,
205 "prepareScrollUnits: gScrollable32.wheelPageWidth is strange value, got " + result);
207 result = -1;
208 synthesizeWheel(gRoot, 10, 10,
209 { deltaMode: WheelEvent.DOM_DELTA_PAGE,
210 deltaX: 1.0, lineOrPageDeltaX: 1 });
211 gRoot.wheelPageWidth = result;
212 ok(window.innerWidth - result < 100 && window.innerWidth - result > 0,
213 "prepareScrollUnits: gRoot.wheelPageWidth is strange value, got " + result);
215 window.removeEventListener("MozMousePixelScroll", handler, true);
216 }
218 function doTests()
219 {
220 const kTests = [
221 // DOM_DELTA_LINE
222 { description: "Should be computed from nearest scrollable element, 128",
223 target: gScrollable128,
224 event: {
225 deltaMode: WheelEvent.DOM_DELTA_LINE,
226 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
227 prepare: function () {
228 gScrollable128.scrollLeft = 0;
229 gScrollable128.scrollTop = 0;
230 },
231 cleanup: function () {
232 },
233 expected: {
234 x: gScrollable128, y: gScrollable128
235 }
236 },
237 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
238 target: gScrollable128,
239 event: {
240 deltaMode: WheelEvent.DOM_DELTA_LINE,
241 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
242 prepare: function () {
243 gScrollable128.scrollLeft = 0;
244 gScrollable128.scrollTop = 0;
245 },
246 cleanup: function () {
247 },
248 expected: {
249 x: gScrollable128, y: gScrollable128
250 }
251 },
252 { description: "Should be computed from nearest scrollable element, 96",
253 target: gScrollable96,
254 event: {
255 deltaMode: WheelEvent.DOM_DELTA_LINE,
256 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
257 prepare: function () {
258 gScrollable96.scrollLeft = 0;
259 gScrollable96.scrollTop = 0;
260 },
261 cleanup: function () {
262 },
263 expected: {
264 x: gScrollable96, y: gScrollable96
265 }
266 },
267 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
268 target: gScrollable96,
269 event: {
270 deltaMode: WheelEvent.DOM_DELTA_LINE,
271 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
272 prepare: function () {
273 gScrollable96.scrollLeft = 0;
274 gScrollable96.scrollTop = 0;
275 },
276 cleanup: function () {
277 },
278 expected: {
279 x: gScrollable96, y: gScrollable96
280 }
281 },
282 { description: "Should be computed from nearest scrollable element, 64",
283 target: gScrollable64,
284 event: {
285 deltaMode: WheelEvent.DOM_DELTA_LINE,
286 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
287 prepare: function () {
288 gScrollable64.scrollLeft = 0;
289 gScrollable64.scrollTop = 0;
290 },
291 cleanup: function () {
292 },
293 expected: {
294 x: gScrollable64, y: gScrollable64
295 }
296 },
297 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
298 target: gScrollable64,
299 event: {
300 deltaMode: WheelEvent.DOM_DELTA_LINE,
301 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
302 prepare: function () {
303 gScrollable64.scrollLeft = 0;
304 gScrollable64.scrollTop = 0;
305 },
306 cleanup: function () {
307 },
308 expected: {
309 x: gScrollable64, y: gScrollable64
310 }
311 },
312 { description: "Should be computed from nearest scrollable element, 32",
313 target: gScrollable32,
314 event: {
315 deltaMode: WheelEvent.DOM_DELTA_LINE,
316 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
317 prepare: function () {
318 gScrollable32.scrollLeft = 0;
319 gScrollable32.scrollTop = 0;
320 },
321 cleanup: function () {
322 },
323 expected: {
324 x: gScrollable32, y: gScrollable32
325 }
326 },
327 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
328 target: gScrollable32,
329 event: {
330 deltaMode: WheelEvent.DOM_DELTA_LINE,
331 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
332 prepare: function () {
333 gScrollable32.scrollLeft = 0;
334 gScrollable32.scrollTop = 0;
335 },
336 cleanup: function () {
337 },
338 expected: {
339 x: gScrollable32, y: gScrollable32
340 }
341 },
342 { description: "Should be computed from root element if there is no scrollable element, root",
343 target: gRoot,
344 event: {
345 deltaMode: WheelEvent.DOM_DELTA_LINE,
346 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
347 prepare: function () {
348 },
349 cleanup: function () {
350 },
351 expected: {
352 x: gRoot, y: gRoot
353 }
354 },
355 { description: "Should be computed from root element, even if there is no scrollable element, root",
356 target: gRoot,
357 event: {
358 deltaMode: WheelEvent.DOM_DELTA_LINE,
359 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
360 prepare: function () {
361 },
362 cleanup: function () {
363 },
364 expected: {
365 x: gRoot, y: gRoot
366 }
367 },
368 { description: "Should be computed from nearest scrollable element, 128",
369 target: gScrollable128,
370 event: {
371 deltaMode: WheelEvent.DOM_DELTA_LINE,
372 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
373 prepare: function () {
374 gScrollable128.scrollLeft = 0;
375 gScrollable128.scrollTop = 0;
376 },
377 cleanup: function () {
378 },
379 expected: {
380 x: null, y: gScrollable128
381 }
382 },
383 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
384 target: gScrollable128,
385 event: {
386 deltaMode: WheelEvent.DOM_DELTA_LINE,
387 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
388 prepare: function () {
389 gScrollable128.scrollLeft = 0;
390 gScrollable128.scrollTop = 0;
391 },
392 cleanup: function () {
393 },
394 expected: {
395 x: null, y: gScrollable128
396 }
397 },
398 { description: "Should be computed from nearest scrollable element, 96",
399 target: gScrollable96,
400 event: {
401 deltaMode: WheelEvent.DOM_DELTA_LINE,
402 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
403 prepare: function () {
404 gScrollable96.scrollLeft = 0;
405 gScrollable96.scrollTop = 0;
406 },
407 cleanup: function () {
408 },
409 expected: {
410 x: null, y: gScrollable96
411 }
412 },
413 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
414 target: gScrollable96,
415 event: {
416 deltaMode: WheelEvent.DOM_DELTA_LINE,
417 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
418 prepare: function () {
419 gScrollable96.scrollLeft = 0;
420 gScrollable96.scrollTop = 0;
421 },
422 cleanup: function () {
423 },
424 expected: {
425 x: null, y: gScrollable96
426 }
427 },
428 { description: "Should be computed from nearest scrollable element, 64",
429 target: gScrollable64,
430 event: {
431 deltaMode: WheelEvent.DOM_DELTA_LINE,
432 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
433 prepare: function () {
434 gScrollable64.scrollLeft = 0;
435 gScrollable64.scrollTop = 0;
436 },
437 cleanup: function () {
438 },
439 expected: {
440 x: null, y: gScrollable64
441 }
442 },
443 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
444 target: gScrollable64,
445 event: {
446 deltaMode: WheelEvent.DOM_DELTA_LINE,
447 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
448 prepare: function () {
449 gScrollable64.scrollLeft = 0;
450 gScrollable64.scrollTop = 0;
451 },
452 cleanup: function () {
453 },
454 expected: {
455 x: null, y: gScrollable64
456 }
457 },
458 { description: "Should be computed from nearest scrollable element, 32",
459 target: gScrollable32,
460 event: {
461 deltaMode: WheelEvent.DOM_DELTA_LINE,
462 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
463 prepare: function () {
464 gScrollable32.scrollLeft = 0;
465 gScrollable32.scrollTop = 0;
466 },
467 cleanup: function () {
468 },
469 expected: {
470 x: null, y: gScrollable32
471 }
472 },
473 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
474 target: gScrollable32,
475 event: {
476 deltaMode: WheelEvent.DOM_DELTA_LINE,
477 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
478 prepare: function () {
479 gScrollable32.scrollLeft = 0;
480 gScrollable32.scrollTop = 0;
481 },
482 cleanup: function () {
483 },
484 expected: {
485 x: null, y: gScrollable32
486 }
487 },
488 { description: "Should be computed from root element if there is no scrollable element, root",
489 target: gRoot,
490 event: {
491 deltaMode: WheelEvent.DOM_DELTA_LINE,
492 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
493 prepare: function () {
494 },
495 cleanup: function () {
496 },
497 expected: {
498 x: null, y: gRoot
499 }
500 },
501 { description: "Should be computed from root element, even if there is no scrollable element, root",
502 target: gRoot,
503 event: {
504 deltaMode: WheelEvent.DOM_DELTA_LINE,
505 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
506 prepare: function () {
507 },
508 cleanup: function () {
509 },
510 expected: {
511 x: null, y: gRoot
512 }
513 },
514 { description: "Should be computed from nearest scrollable element, 128",
515 target: gScrollable128,
516 event: {
517 deltaMode: WheelEvent.DOM_DELTA_LINE,
518 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
519 prepare: function () {
520 gScrollable128.scrollLeft = 0;
521 gScrollable128.scrollTop = 0;
522 },
523 cleanup: function () {
524 },
525 expected: {
526 x: gScrollable128, y: null
527 }
528 },
529 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
530 target: gScrollable128,
531 event: {
532 deltaMode: WheelEvent.DOM_DELTA_LINE,
533 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
534 prepare: function () {
535 gScrollable128.scrollLeft = 0;
536 gScrollable128.scrollTop = 0;
537 },
538 cleanup: function () {
539 },
540 expected: {
541 x: gScrollable128, y: null
542 }
543 },
544 { description: "Should be computed from nearest scrollable element, 96",
545 target: gScrollable96,
546 event: {
547 deltaMode: WheelEvent.DOM_DELTA_LINE,
548 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
549 prepare: function () {
550 gScrollable96.scrollLeft = 0;
551 gScrollable96.scrollTop = 0;
552 },
553 cleanup: function () {
554 },
555 expected: {
556 x: gScrollable96, y: null
557 }
558 },
559 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
560 target: gScrollable96,
561 event: {
562 deltaMode: WheelEvent.DOM_DELTA_LINE,
563 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
564 prepare: function () {
565 gScrollable96.scrollLeft = 0;
566 gScrollable96.scrollTop = 0;
567 },
568 cleanup: function () {
569 },
570 expected: {
571 x: gScrollable96, y: null
572 }
573 },
574 { description: "Should be computed from nearest scrollable element, 64",
575 target: gScrollable64,
576 event: {
577 deltaMode: WheelEvent.DOM_DELTA_LINE,
578 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
579 prepare: function () {
580 gScrollable64.scrollLeft = 0;
581 gScrollable64.scrollTop = 0;
582 },
583 cleanup: function () {
584 },
585 expected: {
586 x: gScrollable64, y: null
587 }
588 },
589 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
590 target: gScrollable64,
591 event: {
592 deltaMode: WheelEvent.DOM_DELTA_LINE,
593 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
594 prepare: function () {
595 gScrollable64.scrollLeft = 0;
596 gScrollable64.scrollTop = 0;
597 },
598 cleanup: function () {
599 },
600 expected: {
601 x: gScrollable64, y: null
602 }
603 },
604 { description: "Should be computed from nearest scrollable element, 32",
605 target: gScrollable32,
606 event: {
607 deltaMode: WheelEvent.DOM_DELTA_LINE,
608 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
609 prepare: function () {
610 gScrollable32.scrollLeft = 0;
611 gScrollable32.scrollTop = 0;
612 },
613 cleanup: function () {
614 },
615 expected: {
616 x: gScrollable32, y: null
617 }
618 },
619 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
620 target: gScrollable32,
621 event: {
622 deltaMode: WheelEvent.DOM_DELTA_LINE,
623 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
624 prepare: function () {
625 gScrollable32.scrollLeft = 0;
626 gScrollable32.scrollTop = 0;
627 },
628 cleanup: function () {
629 },
630 expected: {
631 x: gScrollable32, y: null
632 }
633 },
634 { description: "Should be computed from root element if there is no scrollable element, root",
635 target: gRoot,
636 event: {
637 deltaMode: WheelEvent.DOM_DELTA_LINE,
638 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
639 prepare: function () {
640 },
641 cleanup: function () {
642 },
643 expected: {
644 x: gRoot, y: null
645 }
646 },
647 { description: "Should be computed from root element, even if there is no scrollable element, root",
648 target: gRoot,
649 event: {
650 deltaMode: WheelEvent.DOM_DELTA_LINE,
651 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
652 prepare: function () {
653 },
654 cleanup: function () {
655 },
656 expected: {
657 x: gRoot, y: null
658 }
659 },
661 // DOM_DELTA_PAGE
662 { description: "Should be computed from nearest scrollable element, 128",
663 target: gScrollable128,
664 event: {
665 deltaMode: WheelEvent.DOM_DELTA_PAGE,
666 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
667 prepare: function () {
668 gScrollable128.scrollLeft = 0;
669 gScrollable128.scrollTop = 0;
670 },
671 cleanup: function () {
672 },
673 expected: {
674 x: gScrollable128, y: gScrollable128
675 }
676 },
677 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
678 target: gScrollable128,
679 event: {
680 deltaMode: WheelEvent.DOM_DELTA_PAGE,
681 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
682 prepare: function () {
683 gScrollable128.scrollLeft = 0;
684 gScrollable128.scrollTop = 0;
685 },
686 cleanup: function () {
687 },
688 expected: {
689 x: gScrollable128, y: gScrollable128
690 }
691 },
692 { description: "Should be computed from nearest scrollable element, 96",
693 target: gScrollable96,
694 event: {
695 deltaMode: WheelEvent.DOM_DELTA_PAGE,
696 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
697 prepare: function () {
698 gScrollable96.scrollLeft = 0;
699 gScrollable96.scrollTop = 0;
700 },
701 cleanup: function () {
702 },
703 expected: {
704 x: gScrollable96, y: gScrollable96
705 }
706 },
707 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
708 target: gScrollable96,
709 event: {
710 deltaMode: WheelEvent.DOM_DELTA_PAGE,
711 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
712 prepare: function () {
713 gScrollable96.scrollLeft = 0;
714 gScrollable96.scrollTop = 0;
715 },
716 cleanup: function () {
717 },
718 expected: {
719 x: gScrollable96, y: gScrollable96
720 }
721 },
722 { description: "Should be computed from nearest scrollable element, 64",
723 target: gScrollable64,
724 event: {
725 deltaMode: WheelEvent.DOM_DELTA_PAGE,
726 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
727 prepare: function () {
728 gScrollable64.scrollLeft = 0;
729 gScrollable64.scrollTop = 0;
730 },
731 cleanup: function () {
732 },
733 expected: {
734 x: gScrollable64, y: gScrollable64
735 }
736 },
737 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
738 target: gScrollable64,
739 event: {
740 deltaMode: WheelEvent.DOM_DELTA_PAGE,
741 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
742 prepare: function () {
743 gScrollable64.scrollLeft = 0;
744 gScrollable64.scrollTop = 0;
745 },
746 cleanup: function () {
747 },
748 expected: {
749 x: gScrollable64, y: gScrollable64
750 }
751 },
752 { description: "Should be computed from nearest scrollable element, 32",
753 target: gScrollable32,
754 event: {
755 deltaMode: WheelEvent.DOM_DELTA_PAGE,
756 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
757 prepare: function () {
758 gScrollable32.scrollLeft = 0;
759 gScrollable32.scrollTop = 0;
760 },
761 cleanup: function () {
762 },
763 expected: {
764 x: gScrollable32, y: gScrollable32
765 }
766 },
767 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
768 target: gScrollable32,
769 event: {
770 deltaMode: WheelEvent.DOM_DELTA_PAGE,
771 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
772 prepare: function () {
773 gScrollable32.scrollLeft = 0;
774 gScrollable32.scrollTop = 0;
775 },
776 cleanup: function () {
777 },
778 expected: {
779 x: gScrollable32, y: gScrollable32
780 }
781 },
782 { description: "Should be computed from root element if there is no scrollable element, root",
783 target: gRoot,
784 event: {
785 deltaMode: WheelEvent.DOM_DELTA_PAGE,
786 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
787 prepare: function () {
788 },
789 cleanup: function () {
790 },
791 expected: {
792 x: gRoot, y: gRoot
793 }
794 },
795 { description: "Should be computed from root element, even if there is no scrollable element, root",
796 target: gRoot,
797 event: {
798 deltaMode: WheelEvent.DOM_DELTA_PAGE,
799 deltaX: -1.0, deltaY: -1.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: -1 },
800 prepare: function () {
801 },
802 cleanup: function () {
803 },
804 expected: {
805 x: gRoot, y: gRoot
806 }
807 },
808 { description: "Should be computed from nearest scrollable element, 128",
809 target: gScrollable128,
810 event: {
811 deltaMode: WheelEvent.DOM_DELTA_PAGE,
812 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
813 prepare: function () {
814 gScrollable128.scrollLeft = 0;
815 gScrollable128.scrollTop = 0;
816 },
817 cleanup: function () {
818 },
819 expected: {
820 x: null, y: gScrollable128
821 }
822 },
823 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
824 target: gScrollable128,
825 event: {
826 deltaMode: WheelEvent.DOM_DELTA_PAGE,
827 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
828 prepare: function () {
829 gScrollable128.scrollLeft = 0;
830 gScrollable128.scrollTop = 0;
831 },
832 cleanup: function () {
833 },
834 expected: {
835 x: null, y: gScrollable128
836 }
837 },
838 { description: "Should be computed from nearest scrollable element, 96",
839 target: gScrollable96,
840 event: {
841 deltaMode: WheelEvent.DOM_DELTA_PAGE,
842 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
843 prepare: function () {
844 gScrollable96.scrollLeft = 0;
845 gScrollable96.scrollTop = 0;
846 },
847 cleanup: function () {
848 },
849 expected: {
850 x: null, y: gScrollable96
851 }
852 },
853 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
854 target: gScrollable96,
855 event: {
856 deltaMode: WheelEvent.DOM_DELTA_PAGE,
857 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
858 prepare: function () {
859 gScrollable96.scrollLeft = 0;
860 gScrollable96.scrollTop = 0;
861 },
862 cleanup: function () {
863 },
864 expected: {
865 x: null, y: gScrollable96
866 }
867 },
868 { description: "Should be computed from nearest scrollable element, 64",
869 target: gScrollable64,
870 event: {
871 deltaMode: WheelEvent.DOM_DELTA_PAGE,
872 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
873 prepare: function () {
874 gScrollable64.scrollLeft = 0;
875 gScrollable64.scrollTop = 0;
876 },
877 cleanup: function () {
878 },
879 expected: {
880 x: null, y: gScrollable64
881 }
882 },
883 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
884 target: gScrollable64,
885 event: {
886 deltaMode: WheelEvent.DOM_DELTA_PAGE,
887 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
888 prepare: function () {
889 gScrollable64.scrollLeft = 0;
890 gScrollable64.scrollTop = 0;
891 },
892 cleanup: function () {
893 },
894 expected: {
895 x: null, y: gScrollable64
896 }
897 },
898 { description: "Should be computed from nearest scrollable element, 32",
899 target: gScrollable32,
900 event: {
901 deltaMode: WheelEvent.DOM_DELTA_PAGE,
902 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
903 prepare: function () {
904 gScrollable32.scrollLeft = 0;
905 gScrollable32.scrollTop = 0;
906 },
907 cleanup: function () {
908 },
909 expected: {
910 x: null, y: gScrollable32
911 }
912 },
913 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
914 target: gScrollable32,
915 event: {
916 deltaMode: WheelEvent.DOM_DELTA_PAGE,
917 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
918 prepare: function () {
919 gScrollable32.scrollLeft = 0;
920 gScrollable32.scrollTop = 0;
921 },
922 cleanup: function () {
923 },
924 expected: {
925 x: null, y: gScrollable32
926 }
927 },
928 { description: "Should be computed from root element if there is no scrollable element, root",
929 target: gRoot,
930 event: {
931 deltaMode: WheelEvent.DOM_DELTA_PAGE,
932 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
933 prepare: function () {
934 },
935 cleanup: function () {
936 },
937 expected: {
938 x: null, y: gRoot
939 }
940 },
941 { description: "Should be computed from root element, even if there is no scrollable element, root",
942 target: gRoot,
943 event: {
944 deltaMode: WheelEvent.DOM_DELTA_PAGE,
945 deltaX: 0.0, deltaY: -1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
946 prepare: function () {
947 },
948 cleanup: function () {
949 },
950 expected: {
951 x: null, y: gRoot
952 }
953 },
954 { description: "Should be computed from nearest scrollable element, 128",
955 target: gScrollable128,
956 event: {
957 deltaMode: WheelEvent.DOM_DELTA_PAGE,
958 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
959 prepare: function () {
960 gScrollable128.scrollLeft = 0;
961 gScrollable128.scrollTop = 0;
962 },
963 cleanup: function () {
964 },
965 expected: {
966 x: gScrollable128, y: null
967 }
968 },
969 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction",
970 target: gScrollable128,
971 event: {
972 deltaMode: WheelEvent.DOM_DELTA_PAGE,
973 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
974 prepare: function () {
975 gScrollable128.scrollLeft = 0;
976 gScrollable128.scrollTop = 0;
977 },
978 cleanup: function () {
979 },
980 expected: {
981 x: gScrollable128, y: null
982 }
983 },
984 { description: "Should be computed from nearest scrollable element, 96",
985 target: gScrollable96,
986 event: {
987 deltaMode: WheelEvent.DOM_DELTA_PAGE,
988 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
989 prepare: function () {
990 gScrollable96.scrollLeft = 0;
991 gScrollable96.scrollTop = 0;
992 },
993 cleanup: function () {
994 },
995 expected: {
996 x: gScrollable96, y: null
997 }
998 },
999 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 96",
1000 target: gScrollable96,
1001 event: {
1002 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1003 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
1004 prepare: function () {
1005 gScrollable96.scrollLeft = 0;
1006 gScrollable96.scrollTop = 0;
1007 },
1008 cleanup: function () {
1009 },
1010 expected: {
1011 x: gScrollable96, y: null
1012 }
1013 },
1014 { description: "Should be computed from nearest scrollable element, 64",
1015 target: gScrollable64,
1016 event: {
1017 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1018 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
1019 prepare: function () {
1020 gScrollable64.scrollLeft = 0;
1021 gScrollable64.scrollTop = 0;
1022 },
1023 cleanup: function () {
1024 },
1025 expected: {
1026 x: gScrollable64, y: null
1027 }
1028 },
1029 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 64",
1030 target: gScrollable64,
1031 event: {
1032 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1033 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
1034 prepare: function () {
1035 gScrollable64.scrollLeft = 0;
1036 gScrollable64.scrollTop = 0;
1037 },
1038 cleanup: function () {
1039 },
1040 expected: {
1041 x: gScrollable64, y: null
1042 }
1043 },
1044 { description: "Should be computed from nearest scrollable element, 32",
1045 target: gScrollable32,
1046 event: {
1047 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1048 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
1049 prepare: function () {
1050 gScrollable32.scrollLeft = 0;
1051 gScrollable32.scrollTop = 0;
1052 },
1053 cleanup: function () {
1054 },
1055 expected: {
1056 x: gScrollable32, y: null
1057 }
1058 },
1059 { description: "Should be computed from nearest scrollable element, even if not scrollable to the direction, 32",
1060 target: gScrollable32,
1061 event: {
1062 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1063 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
1064 prepare: function () {
1065 gScrollable32.scrollLeft = 0;
1066 gScrollable32.scrollTop = 0;
1067 },
1068 cleanup: function () {
1069 },
1070 expected: {
1071 x: gScrollable32, y: null
1072 }
1073 },
1074 { description: "Should be computed from root element if there is no scrollable element, root",
1075 target: gRoot,
1076 event: {
1077 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1078 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
1079 prepare: function () {
1080 },
1081 cleanup: function () {
1082 },
1083 expected: {
1084 x: gRoot, y: null
1085 }
1086 },
1087 { description: "Should be computed from root element, even if there is no scrollable element, root",
1088 target: gRoot,
1089 event: {
1090 deltaMode: WheelEvent.DOM_DELTA_PAGE,
1091 deltaX: -1.0, deltaY: 0.0, lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
1092 prepare: function () {
1093 },
1094 cleanup: function () {
1095 },
1096 expected: {
1097 x: gRoot, y: null
1098 }
1099 },
1101 // Overflow: hidden; boxes shouldn't be ignored.
1102 { description: "Should be computed from nearest scrollable element even if it hides overflow content, 64",
1103 target: gScrollable64,
1104 event: {
1105 deltaMode: WheelEvent.DOM_DELTA_LINE,
1106 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
1107 prepare: function () {
1108 gScrollable64.style.overflow = "hidden";
1109 gScrollable96.scrollLeft = 0;
1110 gScrollable96.scrollTop = 0;
1111 gScrollable64.scrollLeft = 0;
1112 gScrollable64.scrollTop = 0;
1113 },
1114 cleanup: function () {
1115 gScrollable64.style.overflow = "auto";
1116 },
1117 expected: {
1118 x: gScrollable64, y: gScrollable64
1119 }
1120 },
1121 { description: "Should be computed from nearest scrollable element even if it hides overflow content (X), 64",
1122 target: gScrollable64,
1123 event: {
1124 deltaMode: WheelEvent.DOM_DELTA_LINE,
1125 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
1126 prepare: function () {
1127 gScrollable64.style.overflowX = "hidden";
1128 gScrollable96.scrollLeft = 0;
1129 gScrollable96.scrollTop = 0;
1130 gScrollable64.scrollLeft = 0;
1131 gScrollable64.scrollTop = 0;
1132 },
1133 cleanup: function () {
1134 gScrollable64.style.overflow = "auto";
1135 },
1136 expected: {
1137 x: gScrollable64, y: gScrollable64
1138 }
1139 },
1140 { description: "Should be computed from nearest scrollable element even if it hides overflow content (Y), 64",
1141 target: gScrollable64,
1142 event: {
1143 deltaMode: WheelEvent.DOM_DELTA_LINE,
1144 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
1145 prepare: function () {
1146 gScrollable64.style.overflowY = "hidden";
1147 gScrollable96.scrollLeft = 0;
1148 gScrollable96.scrollTop = 0;
1149 gScrollable64.scrollLeft = 0;
1150 gScrollable64.scrollTop = 0;
1151 },
1152 cleanup: function () {
1153 gScrollable64.style.overflow = "auto";
1154 },
1155 expected: {
1156 x: gScrollable64, y: gScrollable64
1157 }
1158 },
1159 { description: "Should be computed from nearest scrollable element even if it hides overflow content (X), 64",
1160 target: gScrollable64,
1161 event: {
1162 deltaMode: WheelEvent.DOM_DELTA_LINE,
1163 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
1164 prepare: function () {
1165 gScrollable64.style.overflowX = "hidden";
1166 gScrollable96.scrollLeft = 0;
1167 gScrollable96.scrollTop = 0;
1168 gScrollable64.scrollLeft = 0;
1169 gScrollable64.scrollTop = 0;
1170 },
1171 cleanup: function () {
1172 gScrollable64.style.overflow = "auto";
1173 },
1174 expected: {
1175 x: null, y: gScrollable64
1176 }
1177 },
1178 { description: "Should be computed from nearest scrollable element even if it hides overflow content (Y), 64",
1179 target: gScrollable64,
1180 event: {
1181 deltaMode: WheelEvent.DOM_DELTA_LINE,
1182 deltaX: 0.0, deltaY: 1.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
1183 prepare: function () {
1184 gScrollable64.style.overflowY = "hidden";
1185 gScrollable96.scrollLeft = 0;
1186 gScrollable96.scrollTop = 0;
1187 gScrollable64.scrollLeft = 0;
1188 gScrollable64.scrollTop = 0;
1189 },
1190 cleanup: function () {
1191 gScrollable64.style.overflow = "auto";
1192 },
1193 expected: {
1194 x: null, y: gScrollable64
1195 }
1196 },
1197 { description: "Should be computed from nearest scrollable element even if it hides overflow content (X), 64",
1198 target: gScrollable64,
1199 event: {
1200 deltaMode: WheelEvent.DOM_DELTA_LINE,
1201 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
1202 prepare: function () {
1203 gScrollable64.style.overflowX = "hidden";
1204 gScrollable96.scrollLeft = 0;
1205 gScrollable96.scrollTop = 0;
1206 gScrollable64.scrollLeft = 0;
1207 gScrollable64.scrollTop = 0;
1208 },
1209 cleanup: function () {
1210 gScrollable64.style.overflow = "auto";
1211 },
1212 expected: {
1213 x: gScrollable64, y: null
1214 }
1215 },
1216 { description: "Should be computed from nearest scrollable element even if it hides overflow content (Y), 64",
1217 target: gScrollable64,
1218 event: {
1219 deltaMode: WheelEvent.DOM_DELTA_LINE,
1220 deltaX: 1.0, deltaY: 0.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
1221 prepare: function () {
1222 gScrollable64.style.overflowY = "hidden";
1223 gScrollable96.scrollLeft = 0;
1224 gScrollable96.scrollTop = 0;
1225 gScrollable64.scrollLeft = 0;
1226 gScrollable64.scrollTop = 0;
1227 },
1228 cleanup: function () {
1229 gScrollable64.style.overflow = "auto";
1230 },
1231 expected: {
1232 x: gScrollable64, y: null
1233 }
1234 },
1235 ];
1237 var currentTest, description, firedX, firedY;
1239 function handler(aEvent)
1240 {
1241 aEvent.preventDefault();
1243 if (aEvent.axis != MouseScrollEvent.HORIZONTAL_AXIS &&
1244 aEvent.axis != MouseScrollEvent.VERTICAL_AXIS) {
1245 ok(false,
1246 description + "The event had invalid axis (" + aEvent.axis + ")");
1247 return;
1248 }
1250 var isHorizontal = (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS);
1251 if ((isHorizontal && !currentTest.expected.x) ||
1252 (!isHorizontal && !currentTest.expected.y)) {
1253 ok(false,
1254 description + "The event fired unexpectedly (" +
1255 (isHorizontal ? "Horizontal" : "Vertical") + ")");
1256 return;
1257 }
1259 if (isHorizontal) {
1260 firedX = true;
1261 } else {
1262 firedY = true;
1263 }
1265 var expectedDetail =
1266 (currentTest.event.deltaMode == WheelEvent.DOM_DELTA_LINE) ?
1267 (isHorizontal ? currentTest.expected.x.wheelHorizontalLine :
1268 currentTest.expected.y.wheelLineHeight) :
1269 (isHorizontal ? currentTest.expected.x.wheelPageWidth :
1270 currentTest.expected.y.wheelPageHeight);
1271 is(Math.abs(aEvent.detail), expectedDetail,
1272 description + ((isHorizontal) ? "horizontal" : "vertical") + " event detail is wrong");
1273 }
1275 window.addEventListener("MozMousePixelScroll", handler, true);
1277 for (var i = 0; i < kTests.length; i++) {
1278 currentTest = kTests[i];
1279 description = "doTests, " + currentTest.description + " (deltaMode: " +
1280 (currentTest.event.deltaMode == WheelEvent.DOM_DELTA_LINE ?
1281 "DOM_DELTA_LINE" : "DOM_DELTA_PAGE") +
1282 ", deltaX: " + currentTest.event.deltaX +
1283 ", deltaY: " + currentTest.event.deltaY + "): ";
1284 currentTest.prepare();
1285 firedX = firedY = false;
1286 synthesizeWheel(currentTest.target, 10, 10, currentTest.event);
1287 if (currentTest.expected.x) {
1288 ok(firedX, description + "Horizontla MozMousePixelScroll event wasn't fired");
1289 }
1290 if (currentTest.expected.y) {
1291 ok(firedY, description + "Vertical MozMousePixelScroll event wasn't fired");
1292 }
1293 currentTest.cleanup();
1294 }
1296 window.removeEventListener("MozMousePixelScroll", handler, true);
1297 }
1299 function runTests()
1300 {
1301 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
1302 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 100);
1303 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_z", 100);
1304 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_x", 100);
1305 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_y", 100);
1306 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_z", 100);
1307 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_x", 100);
1308 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_y", 100);
1309 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_z", 100);
1310 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_x", 100);
1311 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_y", 100);
1312 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_z", 100);
1313 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_x", 100);
1314 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_y", 100);
1315 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_z", 100);
1316 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_x", 100);
1317 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_y", 100);
1318 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_z", 100);
1320 prepareScrollUnits();
1321 doTests();
1323 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
1324 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");
1325 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_z");
1326 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_x");
1327 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_y");
1328 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_z");
1329 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_x");
1330 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_y");
1331 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_z");
1332 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_x");
1333 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_y");
1334 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_z");
1335 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_x");
1336 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_y");
1337 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_z");
1338 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_x");
1339 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_y");
1340 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_z");
1342 SimpleTest.finish();
1343 }
1345 </script>
1346 </pre>
1347 </body>
1348 </html>