2 style=
"font-family: Arial; font-size: 10px; line-height: 16px;">
4 <title>Test for mouse scroll handling on Windows
</title>
5 <script src=
"chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
6 <script src=
"chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
7 <link rel=
"stylesheet" type=
"text/css"
8 href=
"chrome://mochikit/content/tests/SimpleTest/test.css" />
10 <body onunload=
"onUnload();">
11 <div id=
"display" style=
"width: 5000px; height: 5000px;">
12 <p id=
"p1" style=
"font-size: 16px; width: 100px; height: 100px;">1st
<p
>.
</p>
13 <p id=
"p2" style=
"font-size: 32px; width: 100px; height: 100px;">2nd
<p
>.
</p>
15 <script class=
"testbody" type=
"application/javascript">
17 window.arguments[
0].SimpleTest.waitForFocus(prepareTests, window);
19 const nsIDOMWindowUtils = Ci.nsIDOMWindowUtils;
21 const WHEEL_PAGESCROLL =
4294967295;
23 const WM_VSCROLL =
0x0115;
24 const WM_HSCROLL =
0x0114;
25 const WM_MOUSEWHEEL =
0x020A;
26 const WM_MOUSEHWHEEL =
0x020E;
29 const SB_LINELEFT =
0;
30 const SB_LINEDOWN =
1;
31 const SB_LINERIGHT =
1;
33 const SB_PAGELEFT =
2;
34 const SB_PAGEDOWN =
3;
35 const SB_PAGERIGHT =
3;
37 const SHIFT_L =
0x0100;
38 const SHIFT_R =
0x0200;
39 const CTRL_L =
0x0400;
40 const CTRL_R =
0x0800;
44 const DOM_PAGE_SCROLL_DELTA =
32768;
46 const kSystemScrollSpeedOverridePref =
"mousewheel.system_scroll_override.enabled";
48 const kAltKeyActionPref =
"mousewheel.with_alt.action";
49 const kCtrlKeyActionPref =
"mousewheel.with_control.action";
50 const kShiftKeyActionPref =
"mousewheel.with_shift.action";
51 const kWinKeyActionPref =
"mousewheel.with_meta.action";
53 const kAltKeyDeltaMultiplierXPref =
"mousewheel.with_alt.delta_multiplier_x";
54 const kAltKeyDeltaMultiplierYPref =
"mousewheel.with_alt.delta_multiplier_y";
55 const kCtrlKeyDeltaMultiplierXPref =
"mousewheel.with_control.delta_multiplier_x";
56 const kCtrlKeyDeltaMultiplierYPref =
"mousewheel.with_control.delta_multiplier_y";
57 const kShiftKeyDeltaMultiplierXPref =
"mousewheel.with_shift.delta_multiplier_x";
58 const kShiftKeyDeltaMultiplierYPref =
"mousewheel.with_shift.delta_multiplier_y";
59 const kWinKeyDeltaMultiplierXPref =
"mousewheel.with_meta.delta_multiplier_x";
60 const kWinKeyDeltaMultiplierYPref =
"mousewheel.with_meta.delta_multiplier_y";
62 const kEmulateWheelByWMSCROLLPref =
"mousewheel.emulate_at_wm_scroll";
63 const kVAmountPref =
"mousewheel.windows.vertical_amount_override";
64 const kHAmountPref =
"mousewheel.windows.horizontal_amount_override";
65 const kTimeoutPref =
"mousewheel.windows.transaction.timeout";
67 const kMouseLineScrollEvent =
"DOMMouseScroll";
68 const kMousePixelScrollEvent =
"MozMousePixelScroll";
70 const kVAxis = MouseScrollEvent.VERTICAL_AXIS;
71 const kHAxis = MouseScrollEvent.HORIZONTAL_AXIS;
78 var gP1 = document.getElementById(
"p1");
79 var gP2 = document.getElementById(
"p2");
83 function ok(aCondition, aMessage) {
84 window.arguments[
0].SimpleTest.ok(aCondition, aMessage);
87 function is(aLeft, aRight, aMessage) {
88 window.arguments[
0].SimpleTest.is(aLeft, aRight, aMessage);
91 function isnot(aLeft, aRight, aMessage) {
92 window.arguments[
0].SimpleTest.isnot(aLeft, aRight, aMessage);
95 function todo_is(aLeft, aRight, aMessage) {
96 window.arguments[
0].SimpleTest.todo_is(aLeft, aRight, aMessage);
100 SpecialPowers.clearUserPref(kAltKeyActionPref);
101 SpecialPowers.clearUserPref(kCtrlKeyActionPref);
102 SpecialPowers.clearUserPref(kShiftKeyActionPref);
103 SpecialPowers.clearUserPref(kWinKeyActionPref);
105 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierXPref);
106 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierYPref);
107 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierXPref);
108 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierYPref);
109 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierXPref);
110 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierYPref);
111 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref);
112 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref);
114 SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref);
115 SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref);
116 SpecialPowers.clearUserPref(kVAmountPref);
117 SpecialPowers.clearUserPref(kHAmountPref);
118 SpecialPowers.clearUserPref(kTimeoutPref);
119 window.arguments[
0].SimpleTest.finish();
122 function getWindowUtils(aWindow) {
126 return aWindow.windowUtils;
129 function getPointInScreen(aElement, aWindow) {
133 var bounds = aElement.getBoundingClientRect();
134 return { x: bounds.left + aWindow.mozInnerScreenX,
135 y: bounds.top + aWindow.mozInnerScreenY };
139 return (aNum
>=
0) ? Math.floor(aNum) : Math.ceil(aNum);
143 * Make each steps for the tests in following arrays in global scope. Each item
144 * of the arrays will be executed after previous test is finished.
147 * Set the description of the test. This will be used for the message of is()
151 * aNativeMessage of nsIDOMWindowUtils.sendNativeMouseScrollEvent().
152 * Must be WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL or WM_HSCROLL.
155 * The native delta value for WM_MOUSEWHEEL or WM_MOUSEHWHEEL.
156 * Or one of the SB_* const value for WM_VSCROLL or WM_HSCROLL.
159 * The target element, under the mouse cursor.
162 * The window which is used for getting nsIDOMWindowUtils.
165 * Pressed modifier keys,
0 means no modifier key is pressed.
166 * Otherwise, one or more values of SHIFT_L, SHIFT_R, CTRL_L, CTRL_R,
170 * aAdditionalFlags of nsIDOMWindowUtils.sendNativeMouseScrollEvent().
171 * See the document of nsIDOMWindowUtils for the detail of the values.
174 * Must be a function or null.
175 * If the value is a function, it will be called when DOMMouseScroll event
176 * is received by the synthesized event.
177 * If return true, the common checks are canceled.
179 * onPixelScrollEvent:
180 * Must be a function or null.
181 * If the value is a function, it will be called when MozMousePixelScroll
182 * event is received by the synthesized event.
183 * If return true, the common checks are canceled.
186 * Must not be null and this must have:
188 * kVAxis if the synthesized event causes vertical scroll. Otherwise,
189 * it causes horizontal scroll, kHAxis.
191 * Integer value which is expected detail attribute value of
192 * DOMMouseScroll. If the event shouldn't be fired, must be
0.
194 * Integer value or a function which returns double value. The value is
195 * expected detail attribute value of MozMousePixelScroll.
196 * If the event shouldn't be fired, must be
0.
198 * Note that if both lines and pixels are
0, the test framework waits
199 * a few seconds. After that, go to next test.
202 * Must be a function or null. If this value is a function, it's called
203 * before synthesizing the native event.
206 * Must be a function or null. If this value is a function, it's called
207 * after received all expected events or timeout if no events are expected.
210 // First, get the computed line height, char width, page height and page width.
211 var gPreparingSteps = [
212 { description:
"Preparing gLineHeight",
213 message: WM_MOUSEWHEEL, delta: -
120,
214 target: gP1, x:
10, y:
10, window,
217 onLineScrollEvent() {
220 onPixelScrollEvent(aEvent) {
221 gLineHeight = aEvent.detail;
225 axis: kVAxis, lines:
1, pixels:
1,
228 SpecialPowers.setIntPref(kVAmountPref,
1);
229 SpecialPowers.setIntPref(kHAmountPref,
1);
232 { description:
"Preparing gCharWidth",
233 message: WM_MOUSEHWHEEL, delta:
120,
234 target: gP1, x:
10, y:
10, window,
237 onLineScrollEvent() {
240 onPixelScrollEvent(aEvent) {
241 gCharWidth = aEvent.detail;
245 axis: kVAxis, lines:
1, pixels:
1,
248 { description:
"Preparing gPageHeight",
249 message: WM_MOUSEWHEEL, delta: -
120,
250 target: gP1, x:
10, y:
10, window,
253 onLineScrollEvent() {
256 onPixelScrollEvent(aEvent) {
257 gPageHeight = aEvent.detail;
261 axis: kHAxis, lines:
1, pixels:
1,
264 SpecialPowers.setIntPref(kVAmountPref,
0xFFFF);
265 SpecialPowers.setIntPref(kHAmountPref,
0xFFFF);
268 { description:
"Preparing gPageWidth",
269 message: WM_MOUSEHWHEEL, delta:
120,
270 target: gP1, x:
10, y:
10, window,
273 onLineScrollEvent() {
276 onPixelScrollEvent(aEvent) {
277 gPageWidth = aEvent.detail;
281 axis: kHAxis, lines:
1, pixels:
1,
284 ok(gLineHeight
> 0,
"gLineHeight isn't positive got " + gLineHeight);
285 ok(gCharWidth
> 0,
"gCharWidth isn't positive got " + gCharWidth);
286 ok(gPageHeight
> 0,
"gPageHeight isn't positive got " + gPageHeight);
287 ok(gPageWidth
> 0,
"gPageWidth isn't positive got " + gPageWidth);
289 ok(gPageHeight
> gLineHeight,
290 "gPageHeight must be larger than gLineHeight");
291 ok(gPageWidth
> gCharWidth,
292 "gPageWidth must be larger than gCharWidth");
293 runNextTest(gBasicTests,
0);
299 // Widget shouldn't dispatch a pixel event if the delta can be devided by
300 // lines to be scrolled. However, pixel events should be fired by ESM.
301 { description:
"WM_MOUSEWHEEL, -120, 3 lines",
302 message: WM_MOUSEWHEEL, delta: -
120,
303 target: gP1, x:
10, y:
10, window,
307 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
310 SpecialPowers.setIntPref(kVAmountPref,
3);
311 SpecialPowers.setIntPref(kHAmountPref,
3);
315 { description:
"WM_MOUSEWHEEL, 120, -3 lines",
316 message: WM_MOUSEWHEEL, delta:
120,
317 target: gP1, x:
10, y:
10, window,
321 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
325 { description:
"WM_MOUSEHWHEEL, 120, 3 chars",
326 message: WM_MOUSEHWHEEL, delta:
120,
327 target: gP1, x:
10, y:
10, window,
331 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
335 { description:
"WM_MOUSEHWHEEL, -120, -3 chars",
336 message: WM_MOUSEHWHEEL, delta: -
120,
337 target: gP1, x:
10, y:
10, window,
341 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
345 // Pixel scroll event should be fired always but line scroll event should be
346 // fired only when accumulated delta value is over a line.
347 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines",
348 message: WM_MOUSEWHEEL, delta: -
20,
349 target: gP1, x:
10, y:
10, window,
353 axis: kVAxis, lines:
0, pixels() { return gLineHeight /
2; },
356 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines (pending: 0.5 lines)",
357 message: WM_MOUSEWHEEL, delta: -
20,
358 target: gP1, x:
10, y:
10, window,
362 axis: kVAxis, lines:
1, pixels() { return gLineHeight /
2; },
365 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines",
366 message: WM_MOUSEWHEEL, delta: -
20,
367 target: gP1, x:
10, y:
10, window,
371 axis: kVAxis, lines:
0, pixels() { return gLineHeight /
2; },
375 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines (pending: 0.5 lines)",
376 message: WM_MOUSEWHEEL, delta:
20,
377 target: gP1, x:
10, y:
10, window,
381 axis: kVAxis, lines:
0, pixels() { return gLineHeight / -
2; },
384 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines (pending: -0.5 lines)",
385 message: WM_MOUSEWHEEL, delta:
20,
386 target: gP1, x:
10, y:
10, window,
390 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight /
2; },
393 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines",
394 message: WM_MOUSEWHEEL, delta:
20,
395 target: gP1, x:
10, y:
10, window,
399 axis: kVAxis, lines:
0, pixels() { return gLineHeight / -
2; },
403 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars",
404 message: WM_MOUSEHWHEEL, delta:
20,
405 target: gP1, x:
10, y:
10, window,
409 axis: kHAxis, lines:
0, pixels() { return gCharWidth /
2; },
412 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars (pending: 0.5 chars)",
413 message: WM_MOUSEHWHEEL, delta:
20,
414 target: gP1, x:
10, y:
10, window,
418 axis: kHAxis, lines:
1, pixels() { return gCharWidth /
2; },
421 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars",
422 message: WM_MOUSEHWHEEL, delta:
20,
423 target: gP1, x:
10, y:
10, window,
427 axis: kHAxis, lines:
0, pixels() { return gCharWidth /
2; },
431 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars (pending: 0.5 chars)",
432 message: WM_MOUSEHWHEEL, delta: -
20,
433 target: gP1, x:
10, y:
10, window,
437 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
440 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars (pending: -0.5 chars)",
441 message: WM_MOUSEHWHEEL, delta: -
20,
442 target: gP1, x:
10, y:
10, window,
446 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth /
2; },
449 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars",
450 message: WM_MOUSEHWHEEL, delta: -
20,
451 target: gP1, x:
10, y:
10, window,
455 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
459 // Even if the mouse cursor is an element whose font-size is different than
460 // the scrollable element, the pixel scroll amount shouldn't be changed.
461 // Widget shouldn't dispatch a pixel event if the delta can be devided by
462 // lines to be scrolled. However, pixel events should be fired by ESM.
463 { description:
"WM_MOUSEWHEEL, -120, 3 lines, on the other div whose font-size is larger",
464 message: WM_MOUSEWHEEL, delta: -
120,
465 target: gP2, x:
10, y:
10, window,
469 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
473 { description:
"WM_MOUSEWHEEL, 120, -3 lines, on the other div whose font-size is larger",
474 message: WM_MOUSEWHEEL, delta:
120,
475 target: gP2, x:
10, y:
10, window,
479 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
483 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, on the other div whose font-size is larger",
484 message: WM_MOUSEHWHEEL, delta:
120,
485 target: gP2, x:
10, y:
10, window,
489 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
493 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, on the other div whose font-size is larger",
494 message: WM_MOUSEHWHEEL, delta: -
120,
495 target: gP2, x:
10, y:
10, window,
499 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
503 // Modifier key tests
504 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Shift",
505 message: WM_MOUSEWHEEL, delta: -
40,
506 target: gP1, x:
10, y:
10, window,
510 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
513 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Shift",
514 message: WM_MOUSEWHEEL, delta: -
40,
515 target: gP1, x:
10, y:
10, window,
519 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
522 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Ctrl",
523 message: WM_MOUSEWHEEL, delta: -
40,
524 target: gP1, x:
10, y:
10, window,
528 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
531 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Ctrl",
532 message: WM_MOUSEWHEEL, delta: -
40,
533 target: gP1, x:
10, y:
10, window,
537 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
540 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Alt",
541 message: WM_MOUSEWHEEL, delta: -
40,
542 target: gP1, x:
10, y:
10, window,
546 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
549 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Alt",
550 message: WM_MOUSEWHEEL, delta: -
40,
551 target: gP1, x:
10, y:
10, window,
555 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
559 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Shift",
560 message: WM_MOUSEHWHEEL, delta:
40,
561 target: gP1, x:
10, y:
10, window,
565 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
568 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Shift",
569 message: WM_MOUSEHWHEEL, delta:
40,
570 target: gP1, x:
10, y:
10, window,
574 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
577 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Ctrl",
578 message: WM_MOUSEHWHEEL, delta:
40,
579 target: gP1, x:
10, y:
10, window,
583 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
586 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Ctrl",
587 message: WM_MOUSEHWHEEL, delta:
40,
588 target: gP1, x:
10, y:
10, window,
592 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
595 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Alt",
596 message: WM_MOUSEHWHEEL, delta:
40,
597 target: gP1, x:
10, y:
10, window,
601 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
604 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Alt",
605 message: WM_MOUSEHWHEEL, delta:
40,
606 target: gP1, x:
10, y:
10, window,
610 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
614 runNextTest(gScrollMessageTests,
0);
619 var gPageScrllTests = [
620 // Pixel scroll event should be fired always but line scroll event should be
621 // fired only when accumulated delta value is over a line.
622 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages",
623 message: WM_MOUSEWHEEL, delta: -
60,
624 target: gP1, x:
10, y:
10, window,
628 axis: kVAxis, lines:
0, pixels() { return gPageHeight /
2; },
631 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages (pending: 0.5 pages)",
632 message: WM_MOUSEWHEEL, delta: -
60,
633 target: gP1, x:
10, y:
10, window,
637 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
638 pixels() { return ((gPageHeight /
2) + (gPageHeight %
2)); },
641 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages",
642 message: WM_MOUSEWHEEL, delta: -
60,
643 target: gP1, x:
10, y:
10, window,
647 axis: kVAxis, lines:
0, pixels() { return gPageHeight /
2; },
651 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages (pending: 0.5 pages)",
652 message: WM_MOUSEWHEEL, delta:
60,
653 target: gP1, x:
10, y:
10, window,
657 axis: kVAxis, lines:
0, pixels() { return gPageHeight / -
2; },
660 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages (pending: -0.5 pages)",
661 message: WM_MOUSEWHEEL, delta:
60,
662 target: gP1, x:
10, y:
10, window,
666 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
667 pixels() { return -((gPageHeight /
2) + (gPageHeight %
2)); },
670 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages",
671 message: WM_MOUSEWHEEL, delta:
60,
672 target: gP1, x:
10, y:
10, window,
676 axis: kVAxis, lines:
0, pixels() { return gPageHeight / -
2; },
680 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages",
681 message: WM_MOUSEHWHEEL, delta:
60,
682 target: gP1, x:
10, y:
10, window,
686 axis: kHAxis, lines:
0, pixels() { return gPageWidth /
2; },
689 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages (pending: 0.5 pages)",
690 message: WM_MOUSEHWHEEL, delta:
60,
691 target: gP1, x:
10, y:
10, window,
695 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
696 pixels() { return ((gPageWidth /
2) + (gPageWidth %
2)); },
699 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages",
700 message: WM_MOUSEHWHEEL, delta:
60,
701 target: gP1, x:
10, y:
10, window,
705 axis: kHAxis, lines:
0, pixels() { return gPageWidth /
2; },
709 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages (pending: 0.5 pages)",
710 message: WM_MOUSEHWHEEL, delta: -
60,
711 target: gP1, x:
10, y:
10, window,
715 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
718 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages (pending: -0.5 pages)",
719 message: WM_MOUSEHWHEEL, delta: -
60,
720 target: gP1, x:
10, y:
10, window,
724 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
725 pixels() { return -((gCharWidth /
2) + (gCharWidth %
2)); },
728 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages",
729 message: WM_MOUSEHWHEEL, delta: -
60,
730 target: gP1, x:
10, y:
10, window,
734 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
739 var gScrollMessageTests = [
740 // Widget should dispatch neither line scroll event nor pixel scroll event if
741 // the WM_*SCROLL's lParam is NULL and mouse wheel emulation is disabled.
742 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation disabled",
743 message: WM_VSCROLL, delta: SB_LINEDOWN,
744 target: gP1, x:
10, y:
10, window,
748 axis: kVAxis, lines:
0, pixels:
0,
751 SpecialPowers.setIntPref(kVAmountPref,
3);
752 SpecialPowers.setIntPref(kHAmountPref,
3);
753 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
757 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation disabled",
758 message: WM_VSCROLL, delta: SB_LINEUP,
759 target: gP1, x:
10, y:
10, window,
763 axis: kVAxis, lines:
0, pixels:
0,
767 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation disabled",
768 message: WM_HSCROLL, delta: SB_LINERIGHT,
769 target: gP1, x:
10, y:
10, window,
773 axis: kHAxis, lines:
0, pixels:
0,
777 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation disabled",
778 message: WM_HSCROLL, delta: SB_LINELEFT,
779 target: gP1, x:
10, y:
10, window,
783 axis: kHAxis, lines:
0, pixels:
0,
787 // Widget should emulate mouse wheel behavior for WM_*SCROLL even if the
788 // kEmulateWheelByWMSCROLLPref is disabled but the message's lParam is not
789 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages,
790 // but ESM dispatches it instead.
791 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled",
792 message: WM_VSCROLL, delta: SB_LINEUP,
793 target: gP1, x:
10, y:
10, window,
795 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
797 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
800 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
804 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled",
805 message: WM_VSCROLL, delta: SB_LINEDOWN,
806 target: gP1, x:
10, y:
10, window,
808 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
810 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
814 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled",
815 message: WM_HSCROLL, delta: SB_LINELEFT,
816 target: gP1, x:
10, y:
10, window,
818 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
820 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
824 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled",
825 message: WM_HSCROLL, delta: SB_LINERIGHT,
826 target: gP1, x:
10, y:
10, window,
828 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
830 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
834 { description:
"WM_VSCROLL, SB_PAGEUP, lParam is not NULL, emulation disabled",
835 message: WM_VSCROLL, delta: SB_PAGEUP,
836 target: gP1, x:
10, y:
10, window,
838 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
840 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
841 pixels() { return -gPageHeight; },
845 { description:
"WM_VSCROLL, SB_PAGEDOWN, lParam is not NULL, emulation disabled",
846 message: WM_VSCROLL, delta: SB_PAGEDOWN,
847 target: gP1, x:
10, y:
10, window,
849 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
851 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
852 pixels() { return gPageHeight; },
856 { description:
"WM_HSCROLL, SB_PAGELEFT, lParam is not NULL, emulation disabled",
857 message: WM_HSCROLL, delta: SB_PAGELEFT,
858 target: gP1, x:
10, y:
10, window,
860 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
862 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
863 pixels() { return -gPageWidth; },
867 { description:
"WM_HSCROLL, SB_PAGERIGHT, lParam is not NULL, emulation disabled",
868 message: WM_HSCROLL, delta: SB_PAGERIGHT,
869 target: gP1, x:
10, y:
10, window,
871 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
873 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
874 pixels() { return gPageWidth; },
878 // Widget should emulate mouse wheel behavior for WM_*SCROLL when the
879 // kEmulateWheelByWMSCROLLPref is enabled even if the message's lParam is
880 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages,
881 // but ESM dispatches it instead.
882 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled",
883 message: WM_VSCROLL, delta: SB_LINEUP,
884 target: gP1, x:
10, y:
10, window,
888 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
891 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
895 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled",
896 message: WM_VSCROLL, delta: SB_LINEDOWN,
897 target: gP1, x:
10, y:
10, window,
901 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
905 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled",
906 message: WM_HSCROLL, delta: SB_LINELEFT,
907 target: gP1, x:
10, y:
10, window,
911 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
915 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled",
916 message: WM_HSCROLL, delta: SB_LINERIGHT,
917 target: gP1, x:
10, y:
10, window,
921 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
925 { description:
"WM_VSCROLL, SB_PAGEUP, lParam is NULL, emulation enabled",
926 message: WM_VSCROLL, delta: SB_PAGEUP,
927 target: gP1, x:
10, y:
10, window,
931 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
932 pixels() { return -gPageHeight; },
936 { description:
"WM_VSCROLL, SB_PAGEDOWN, lParam is NULL, emulation enabled",
937 message: WM_VSCROLL, delta: SB_PAGEDOWN,
938 target: gP1, x:
10, y:
10, window,
942 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
943 pixels() { return gPageHeight; },
947 { description:
"WM_HSCROLL, SB_PAGELEFT, lParam is NULL, emulation enabled",
948 message: WM_HSCROLL, delta: SB_PAGELEFT,
949 target: gP1, x:
10, y:
10, window,
953 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
954 pixels() { return -gPageWidth; },
958 { description:
"WM_HSCROLL, SB_PAGERIGHT, lParam is NULL, emulation enabled",
959 message: WM_HSCROLL, delta: SB_PAGERIGHT,
960 target: gP1, x:
10, y:
10, window,
964 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
965 pixels() { return gPageWidth; },
969 // Modifier key tests for WM_*SCROLL
970 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Shift",
971 message: WM_VSCROLL, delta: SB_LINEDOWN,
972 target: gP1, x:
10, y:
10, window,
974 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
976 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
979 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
982 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Shift",
983 message: WM_VSCROLL, delta: SB_LINEDOWN,
984 target: gP1, x:
10, y:
10, window,
986 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
988 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
991 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Ctrl",
992 message: WM_VSCROLL, delta: SB_LINEDOWN,
993 target: gP1, x:
10, y:
10, window,
995 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
997 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1000 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Ctrl",
1001 message: WM_VSCROLL, delta: SB_LINEDOWN,
1002 target: gP1, x:
10, y:
10, window,
1004 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1006 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1009 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Alt",
1010 message: WM_VSCROLL, delta: SB_LINEDOWN,
1011 target: gP1, x:
10, y:
10, window,
1013 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1015 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1018 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Alt",
1019 message: WM_VSCROLL, delta: SB_LINEDOWN,
1020 target: gP1, x:
10, y:
10, window,
1022 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1024 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1028 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Shift",
1029 message: WM_HSCROLL, delta: SB_LINERIGHT,
1030 target: gP1, x:
10, y:
10, window,
1032 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1034 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1037 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Shift",
1038 message: WM_HSCROLL, delta: SB_LINERIGHT,
1039 target: gP1, x:
10, y:
10, window,
1041 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1043 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1046 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Ctrl",
1047 message: WM_HSCROLL, delta: SB_LINERIGHT,
1048 target: gP1, x:
10, y:
10, window,
1050 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1052 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1055 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Ctrl",
1056 message: WM_HSCROLL, delta: SB_LINERIGHT,
1057 target: gP1, x:
10, y:
10, window,
1059 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1061 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1064 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Alt",
1065 message: WM_HSCROLL, delta: SB_LINERIGHT,
1066 target: gP1, x:
10, y:
10, window,
1068 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1070 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1073 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Alt",
1074 message: WM_HSCROLL, delta: SB_LINERIGHT,
1075 target: gP1, x:
10, y:
10, window,
1077 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1079 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1083 runDeactiveWindowTests();
1088 var gDeactiveWindowTests = [
1089 // Typically, mouse drivers send wheel messages to focused window.
1090 // However, we prefer to scroll a scrollable element under the mouse cursor.
1091 { description:
"WM_MOUSEWHEEL, -120, 3 lines, window is deactive",
1092 message: WM_MOUSEWHEEL, delta: -
120,
1093 target: gP1, x:
10, y:
10, window,
1097 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
1100 SpecialPowers.setIntPref(kVAmountPref,
3);
1101 SpecialPowers.setIntPref(kHAmountPref,
3);
1103 onLineScrollEvent() {
1104 var fm = Services.focus;
1105 is(fm.activeWindow, gOtherWindow,
"The other window isn't activated");
1109 { description:
"WM_MOUSEWHEEL, 120, -3 lines, window is deactive",
1110 message: WM_MOUSEWHEEL, delta:
120,
1111 target: gP1, x:
10, y:
10, window,
1115 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
1119 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, window is deactive",
1120 message: WM_MOUSEHWHEEL, delta:
120,
1121 target: gP1, x:
10, y:
10, window,
1125 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
1129 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, window is deactive",
1130 message: WM_MOUSEHWHEEL, delta: -
120,
1131 target: gP1, x:
10, y:
10, window,
1135 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
1139 // Of course, even if some drivers prefer the cursor position, we don't need
1140 // to change anything.
1141 { description:
"WM_MOUSEWHEEL, -120, 3 lines, window is deactive (receive the message directly)",
1142 message: WM_MOUSEWHEEL, delta: -
120,
1143 target: gP1, x:
10, y:
10, window,
1145 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1147 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
1151 { description:
"WM_MOUSEWHEEL, 120, -3 lines, window is deactive (receive the message directly)",
1152 message: WM_MOUSEWHEEL, delta:
120,
1153 target: gP1, x:
10, y:
10, window,
1155 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1157 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
1161 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, window is deactive (receive the message directly)",
1162 message: WM_MOUSEHWHEEL, delta:
120,
1163 target: gP1, x:
10, y:
10, window,
1165 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1167 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
1171 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, window is deactive (receive the message directly)",
1172 message: WM_MOUSEHWHEEL, delta: -
120,
1173 target: gP1, x:
10, y:
10, window,
1175 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1177 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
1181 // Same for WM_*SCROLL if lParam is not NULL
1182 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive",
1183 message: WM_VSCROLL, delta: SB_LINEUP,
1184 target: gP1, x:
10, y:
10, window,
1186 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1188 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1191 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
1195 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive",
1196 message: WM_VSCROLL, delta: SB_LINEDOWN,
1197 target: gP1, x:
10, y:
10, window,
1199 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1201 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1205 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive",
1206 message: WM_HSCROLL, delta: SB_LINELEFT,
1207 target: gP1, x:
10, y:
10, window,
1209 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1211 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1215 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive",
1216 message: WM_HSCROLL, delta: SB_LINERIGHT,
1217 target: gP1, x:
10, y:
10, window,
1219 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1221 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1225 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled
1226 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive",
1227 message: WM_VSCROLL, delta: SB_LINEUP,
1228 target: gP1, x:
10, y:
10, window,
1232 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1235 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
1239 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive",
1240 message: WM_VSCROLL, delta: SB_LINEDOWN,
1241 target: gP1, x:
10, y:
10, window,
1245 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1249 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive",
1250 message: WM_HSCROLL, delta: SB_LINELEFT,
1251 target: gP1, x:
10, y:
10, window,
1255 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1259 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive",
1260 message: WM_HSCROLL, delta: SB_LINERIGHT,
1261 target: gP1, x:
10, y:
10, window,
1265 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1269 // Same for WM_*SCROLL if lParam is not NULL and message sent to the deactive window directly
1270 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1271 message: WM_VSCROLL, delta: SB_LINEUP,
1272 target: gP1, x:
10, y:
10, window,
1274 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1275 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1277 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1280 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
1284 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1285 message: WM_VSCROLL, delta: SB_LINEDOWN,
1286 target: gP1, x:
10, y:
10, window,
1288 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1289 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1291 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1295 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1296 message: WM_HSCROLL, delta: SB_LINELEFT,
1297 target: gP1, x:
10, y:
10, window,
1299 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1300 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1302 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1306 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1307 message: WM_HSCROLL, delta: SB_LINERIGHT,
1308 target: gP1, x:
10, y:
10, window,
1310 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1311 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1313 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1317 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled, and message sent to the deactive window directly
1318 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1319 message: WM_VSCROLL, delta: SB_LINEUP,
1320 target: gP1, x:
10, y:
10, window,
1322 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1324 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1327 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
1331 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1332 message: WM_VSCROLL, delta: SB_LINEDOWN,
1333 target: gP1, x:
10, y:
10, window,
1335 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1337 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1341 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1342 message: WM_HSCROLL, delta: SB_LINELEFT,
1343 target: gP1, x:
10, y:
10, window,
1345 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1347 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1351 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1352 message: WM_HSCROLL, delta: SB_LINERIGHT,
1353 target: gP1, x:
10, y:
10, window,
1355 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1357 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1361 gOtherWindow.close();
1362 gOtherWindow = null;
1368 function runDeactiveWindowTests() {
1369 gOtherWindow = window.open(
"window_mouse_scroll_win_2.html",
"_blank",
1370 "chrome,width=100,height=100,top=700,left=700");
1372 window.arguments[
0].SimpleTest.waitForFocus(function() {
1373 runNextTest(gDeactiveWindowTests,
0);
1377 function runNextTest(aTests, aIndex) {
1378 if (aIndex
> 0 && aTests[aIndex -
1] && aTests[aIndex -
1].finish) {
1379 aTests[aIndex -
1].finish();
1382 if (aTests.length == aIndex) {
1386 var test = aTests[aIndex++];
1390 test.handled = { lines: false, pixels: false };
1392 switch (test.message) {
1394 case WM_MOUSEHWHEEL:
1397 var expectedLines = test.expected.lines;
1398 var expectedPixels =
1399 cut((typeof test.expected.pixels ==
"function") ?
1400 test.expected.pixels() : test.expected.pixels);
1401 var handler = function(aEvent) {
1402 var doCommonTests = true;
1405 ok(!test.handled.lines,
1406 test.description +
", line scroll event has been handled");
1407 ok(!test.handled.pixels,
1408 test.description +
", pixel scroll event has been handled");
1409 doCommonTests = false;
1410 } else if (aEvent.type == kMouseLineScrollEvent) {
1411 ok(!test.handled.lines,
1412 test.description +
":(" + aEvent.type +
"), same event has already been handled");
1413 test.handled.lines = true;
1414 isnot(expectedLines,
0,
1415 test.description +
":(" + aEvent.type +
"), event shouldn't be fired");
1416 if (test.onLineScrollEvent && test.onLineScrollEvent(aEvent)) {
1417 doCommonTests = false;
1419 } else if (aEvent.type == kMousePixelScrollEvent) {
1420 ok(!test.handled.pixels,
1421 test.description +
":(" + aEvent.type +
"), same event has already been handled");
1422 test.handled.pixels = true;
1423 isnot(expectedPixels,
0,
1424 test.description +
":(" + aEvent.type +
"), event shouldn't be fired");
1425 if (test.onPixelScrollEvent && test.onPixelScrollEvent(aEvent)) {
1426 doCommonTests = false;
1430 if (doCommonTests) {
1432 (aEvent.type == kMouseLineScrollEvent) ?
1433 expectedLines : expectedPixels;
1434 is(aEvent.target.id, test.target.id,
1435 test.description +
":(" + aEvent.type +
"), ID mismatch");
1436 is(aEvent.axis, test.expected.axis,
1437 test.description +
":(" + aEvent.type +
"), axis mismatch");
1438 ok(aEvent.detail !=
0,
1439 test.description +
":(" + aEvent.type +
"), delta must not be 0");
1440 is(aEvent.detail, expectedDelta,
1441 test.description +
":(" + aEvent.type +
"), delta mismatch");
1442 is(aEvent.shiftKey, (test.modifiers & (SHIFT_L | SHIFT_R)) !=
0,
1443 test.description +
":(" + aEvent.type +
"), shiftKey mismatch");
1444 is(aEvent.ctrlKey, (test.modifiers & (CTRL_L | CTRL_R)) !=
0,
1445 test.description +
":(" + aEvent.type +
"), ctrlKey mismatch");
1446 is(aEvent.altKey, (test.modifiers & (ALT_L | ALT_R)) !=
0,
1447 test.description +
":(" + aEvent.type +
"), altKey mismatch");
1450 if (!aEvent || (test.handled.lines || expectedLines ==
0) &&
1451 (test.handled.pixels || expectedPixels ==
0)) {
1452 // Don't scroll actually.
1454 aEvent.preventDefault();
1456 test.target.removeEventListener(kMouseLineScrollEvent, handler, true);
1457 test.target.removeEventListener(kMousePixelScrollEvent, handler, true);
1458 setTimeout(runNextTest,
0, aTests, aIndex);
1462 test.target.addEventListener(kMouseLineScrollEvent, handler, true);
1463 test.target.addEventListener(kMousePixelScrollEvent, handler, true);
1465 if (expectedLines ==
0 && expectedPixels ==
0) {
1466 // The timeout might not be enough if system is slow by other process,
1467 // so, the test might be passed unexpectedly. However, it must be able
1468 // to be detected by random orange.
1469 setTimeout(handler,
500);
1472 var utils = getWindowUtils(test.window);
1473 var ptInScreen = getPointInScreen(test.target, test.window);
1475 ((test.message == WM_MOUSEWHEEL) || (test.message == WM_VSCROLL));
1476 var deltaX = !isVertical ? test.delta :
0;
1477 var deltaY = isVertical ? test.delta :
0;
1478 utils.sendNativeMouseScrollEvent(ptInScreen.x + test.x,
1479 ptInScreen.y + test.y,
1480 test.message, deltaX, deltaY,
0,
1482 test.additionalFlags,
1486 ok(false, test.description +
": invalid message");
1491 function prepareTests() {
1492 // Disable special action with modifier key
1493 SpecialPowers.setIntPref(kAltKeyActionPref,
1);
1494 SpecialPowers.setIntPref(kCtrlKeyActionPref,
1);
1495 SpecialPowers.setIntPref(kShiftKeyActionPref,
1);
1496 SpecialPowers.setIntPref(kWinKeyActionPref,
1);
1498 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierXPref,
100);
1499 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierYPref,
100);
1500 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierXPref,
100);
1501 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierYPref,
100);
1502 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierXPref,
100);
1503 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierYPref,
100);
1504 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierXPref,
100);
1505 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref,
100);
1507 SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false);
1508 SpecialPowers.setIntPref(kTimeoutPref, -
1);
1510 runNextTest(gPreparingSteps,
0);