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 { Services } = ChromeUtils.import(
"resource://gre/modules/Services.jsm");
23 const WHEEL_PAGESCROLL =
4294967295;
25 const WM_VSCROLL =
0x0115;
26 const WM_HSCROLL =
0x0114;
27 const WM_MOUSEWHEEL =
0x020A;
28 const WM_MOUSEHWHEEL =
0x020E;
31 const SB_LINELEFT =
0;
32 const SB_LINEDOWN =
1;
33 const SB_LINERIGHT =
1;
35 const SB_PAGELEFT =
2;
36 const SB_PAGEDOWN =
3;
37 const SB_PAGERIGHT =
3;
39 const SHIFT_L =
0x0100;
40 const SHIFT_R =
0x0200;
41 const CTRL_L =
0x0400;
42 const CTRL_R =
0x0800;
46 const DOM_PAGE_SCROLL_DELTA =
32768;
48 const kSystemScrollSpeedOverridePref =
"mousewheel.system_scroll_override_on_root_content.enabled";
50 const kAltKeyActionPref =
"mousewheel.with_alt.action";
51 const kCtrlKeyActionPref =
"mousewheel.with_control.action";
52 const kShiftKeyActionPref =
"mousewheel.with_shift.action";
53 const kWinKeyActionPref =
"mousewheel.with_win.action";
55 const kAltKeyDeltaMultiplierXPref =
"mousewheel.with_alt.delta_multiplier_x";
56 const kAltKeyDeltaMultiplierYPref =
"mousewheel.with_alt.delta_multiplier_y";
57 const kCtrlKeyDeltaMultiplierXPref =
"mousewheel.with_control.delta_multiplier_x";
58 const kCtrlKeyDeltaMultiplierYPref =
"mousewheel.with_control.delta_multiplier_y";
59 const kShiftKeyDeltaMultiplierXPref =
"mousewheel.with_shift.delta_multiplier_x";
60 const kShiftKeyDeltaMultiplierYPref =
"mousewheel.with_shift.delta_multiplier_y";
61 const kWinKeyDeltaMultiplierXPref =
"mousewheel.with_win.delta_multiplier_x";
62 const kWinKeyDeltaMultiplierYPref =
"mousewheel.with_win.delta_multiplier_y";
64 const kEmulateWheelByWMSCROLLPref =
"mousewheel.emulate_at_wm_scroll";
65 const kVAmountPref =
"mousewheel.windows.vertical_amount_override";
66 const kHAmountPref =
"mousewheel.windows.horizontal_amount_override";
67 const kTimeoutPref =
"mousewheel.windows.transaction.timeout";
69 const kMouseLineScrollEvent =
"DOMMouseScroll";
70 const kMousePixelScrollEvent =
"MozMousePixelScroll";
72 const kVAxis = MouseScrollEvent.VERTICAL_AXIS;
73 const kHAxis = MouseScrollEvent.HORIZONTAL_AXIS;
80 var gP1 = document.getElementById(
"p1");
81 var gP2 = document.getElementById(
"p2");
85 function ok(aCondition, aMessage) {
86 window.arguments[
0].SimpleTest.ok(aCondition, aMessage);
89 function is(aLeft, aRight, aMessage) {
90 window.arguments[
0].SimpleTest.is(aLeft, aRight, aMessage);
93 function isnot(aLeft, aRight, aMessage) {
94 window.arguments[
0].SimpleTest.isnot(aLeft, aRight, aMessage);
97 function todo_is(aLeft, aRight, aMessage) {
98 window.arguments[
0].SimpleTest.todo_is(aLeft, aRight, aMessage);
101 function onUnload() {
102 SpecialPowers.clearUserPref(kAltKeyActionPref);
103 SpecialPowers.clearUserPref(kCtrlKeyActionPref);
104 SpecialPowers.clearUserPref(kShiftKeyActionPref);
105 SpecialPowers.clearUserPref(kWinKeyActionPref);
107 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierXPref);
108 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierYPref);
109 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierXPref);
110 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierYPref);
111 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierXPref);
112 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierYPref);
113 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref);
114 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref);
116 SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref);
117 SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref);
118 SpecialPowers.clearUserPref(kVAmountPref);
119 SpecialPowers.clearUserPref(kHAmountPref);
120 SpecialPowers.clearUserPref(kTimeoutPref);
121 window.arguments[
0].SimpleTest.finish();
124 function getWindowUtils(aWindow) {
128 return aWindow.windowUtils;
131 function getPointInScreen(aElement, aWindow) {
135 var bounds = aElement.getBoundingClientRect();
136 return { x: bounds.left + aWindow.mozInnerScreenX,
137 y: bounds.top + aWindow.mozInnerScreenY };
141 return (aNum
>=
0) ? Math.floor(aNum) : Math.ceil(aNum);
145 * Make each steps for the tests in following arrays in global scope. Each item
146 * of the arrays will be executed after previous test is finished.
149 * Set the description of the test. This will be used for the message of is()
153 * aNativeMessage of nsIDOMWindowUtils.sendNativeMouseScrollEvent().
154 * Must be WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL or WM_HSCROLL.
157 * The native delta value for WM_MOUSEWHEEL or WM_MOUSEHWHEEL.
158 * Or one of the SB_* const value for WM_VSCROLL or WM_HSCROLL.
161 * The target element, under the mouse cursor.
164 * The window which is used for getting nsIDOMWindowUtils.
167 * Pressed modifier keys,
0 means no modifier key is pressed.
168 * Otherwise, one or more values of SHIFT_L, SHIFT_R, CTRL_L, CTRL_R,
172 * aAdditionalFlags of nsIDOMWindowUtils.sendNativeMouseScrollEvent().
173 * See the document of nsIDOMWindowUtils for the detail of the values.
176 * Must be a function or null.
177 * If the value is a function, it will be called when DOMMouseScroll event
178 * is received by the synthesized event.
179 * If return true, the common checks are canceled.
181 * onPixelScrollEvent:
182 * Must be a function or null.
183 * If the value is a function, it will be called when MozMousePixelScroll
184 * event is received by the synthesized event.
185 * If return true, the common checks are canceled.
188 * Must not be null and this must have:
190 * kVAxis if the synthesized event causes vertical scroll. Otherwise,
191 * it causes horizontal scroll, kHAxis.
193 * Integer value which is expected detail attribute value of
194 * DOMMouseScroll. If the event shouldn't be fired, must be
0.
196 * Integer value or a function which returns double value. The value is
197 * expected detail attribute value of MozMousePixelScroll.
198 * If the event shouldn't be fired, must be
0.
200 * Note that if both lines and pixels are
0, the test framework waits
201 * a few seconds. After that, go to next test.
204 * Must be a function or null. If this value is a function, it's called
205 * before synthesizing the native event.
208 * Must be a function or null. If this value is a function, it's called
209 * after received all expected events or timeout if no events are expected.
212 // First, get the computed line height, char width, page height and page width.
213 var gPreparingSteps = [
214 { description:
"Preparing gLineHeight",
215 message: WM_MOUSEWHEEL, delta: -
120,
216 target: gP1, x:
10, y:
10, window,
219 onLineScrollEvent(aEvent) {
222 onPixelScrollEvent(aEvent) {
223 gLineHeight = aEvent.detail;
227 axis: kVAxis, lines:
1, pixels:
1,
230 SpecialPowers.setIntPref(kVAmountPref,
1);
231 SpecialPowers.setIntPref(kHAmountPref,
1);
234 { description:
"Preparing gCharWidth",
235 message: WM_MOUSEHWHEEL, delta:
120,
236 target: gP1, x:
10, y:
10, window,
239 onLineScrollEvent(aEvent) {
242 onPixelScrollEvent(aEvent) {
243 gCharWidth = aEvent.detail;
247 axis: kVAxis, lines:
1, pixels:
1,
250 { description:
"Preparing gPageHeight",
251 message: WM_MOUSEWHEEL, delta: -
120,
252 target: gP1, x:
10, y:
10, window,
255 onLineScrollEvent(aEvent) {
258 onPixelScrollEvent(aEvent) {
259 gPageHeight = aEvent.detail;
263 axis: kHAxis, lines:
1, pixels:
1,
266 SpecialPowers.setIntPref(kVAmountPref,
0xFFFF);
267 SpecialPowers.setIntPref(kHAmountPref,
0xFFFF);
270 { description:
"Preparing gPageWidth",
271 message: WM_MOUSEHWHEEL, delta:
120,
272 target: gP1, x:
10, y:
10, window,
275 onLineScrollEvent(aEvent) {
278 onPixelScrollEvent(aEvent) {
279 gPageWidth = aEvent.detail;
283 axis: kHAxis, lines:
1, pixels:
1,
286 ok(gLineHeight
> 0,
"gLineHeight isn't positive got " + gLineHeight);
287 ok(gCharWidth
> 0,
"gCharWidth isn't positive got " + gCharWidth);
288 ok(gPageHeight
> 0,
"gPageHeight isn't positive got " + gPageHeight);
289 ok(gPageWidth
> 0,
"gPageWidth isn't positive got " + gPageWidth);
291 ok(gPageHeight
> gLineHeight,
292 "gPageHeight must be larger than gLineHeight");
293 ok(gPageWidth
> gCharWidth,
294 "gPageWidth must be larger than gCharWidth");
295 runNextTest(gBasicTests,
0);
301 // Widget shouldn't dispatch a pixel event if the delta can be devided by
302 // lines to be scrolled. However, pixel events should be fired by ESM.
303 { description:
"WM_MOUSEWHEEL, -120, 3 lines",
304 message: WM_MOUSEWHEEL, delta: -
120,
305 target: gP1, x:
10, y:
10, window,
309 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
312 SpecialPowers.setIntPref(kVAmountPref,
3);
313 SpecialPowers.setIntPref(kHAmountPref,
3);
317 { description:
"WM_MOUSEWHEEL, 120, -3 lines",
318 message: WM_MOUSEWHEEL, delta:
120,
319 target: gP1, x:
10, y:
10, window,
323 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
327 { description:
"WM_MOUSEHWHEEL, 120, 3 chars",
328 message: WM_MOUSEHWHEEL, delta:
120,
329 target: gP1, x:
10, y:
10, window,
333 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
337 { description:
"WM_MOUSEHWHEEL, -120, -3 chars",
338 message: WM_MOUSEHWHEEL, delta: -
120,
339 target: gP1, x:
10, y:
10, window,
343 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
347 // Pixel scroll event should be fired always but line scroll event should be
348 // fired only when accumulated delta value is over a line.
349 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines",
350 message: WM_MOUSEWHEEL, delta: -
20,
351 target: gP1, x:
10, y:
10, window,
355 axis: kVAxis, lines:
0, pixels() { return gLineHeight /
2; },
358 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines (pending: 0.5 lines)",
359 message: WM_MOUSEWHEEL, delta: -
20,
360 target: gP1, x:
10, y:
10, window,
364 axis: kVAxis, lines:
1, pixels() { return gLineHeight /
2; },
367 { description:
"WM_MOUSEWHEEL, -20, 0.5 lines",
368 message: WM_MOUSEWHEEL, delta: -
20,
369 target: gP1, x:
10, y:
10, window,
373 axis: kVAxis, lines:
0, pixels() { return gLineHeight /
2; },
377 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines (pending: 0.5 lines)",
378 message: WM_MOUSEWHEEL, delta:
20,
379 target: gP1, x:
10, y:
10, window,
383 axis: kVAxis, lines:
0, pixels() { return gLineHeight / -
2; },
386 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines (pending: -0.5 lines)",
387 message: WM_MOUSEWHEEL, delta:
20,
388 target: gP1, x:
10, y:
10, window,
392 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight /
2; },
395 { description:
"WM_MOUSEWHEEL, 20, -0.5 lines",
396 message: WM_MOUSEWHEEL, delta:
20,
397 target: gP1, x:
10, y:
10, window,
401 axis: kVAxis, lines:
0, pixels() { return gLineHeight / -
2; },
405 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars",
406 message: WM_MOUSEHWHEEL, delta:
20,
407 target: gP1, x:
10, y:
10, window,
411 axis: kHAxis, lines:
0, pixels() { return gCharWidth /
2; },
414 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars (pending: 0.5 chars)",
415 message: WM_MOUSEHWHEEL, delta:
20,
416 target: gP1, x:
10, y:
10, window,
420 axis: kHAxis, lines:
1, pixels() { return gCharWidth /
2; },
423 { description:
"WM_MOUSEHWHEEL, 20, 0.5 chars",
424 message: WM_MOUSEHWHEEL, delta:
20,
425 target: gP1, x:
10, y:
10, window,
429 axis: kHAxis, lines:
0, pixels() { return gCharWidth /
2; },
433 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars (pending: 0.5 chars)",
434 message: WM_MOUSEHWHEEL, delta: -
20,
435 target: gP1, x:
10, y:
10, window,
439 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
442 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars (pending: -0.5 chars)",
443 message: WM_MOUSEHWHEEL, delta: -
20,
444 target: gP1, x:
10, y:
10, window,
448 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth /
2; },
451 { description:
"WM_MOUSEHWHEEL, -20, -0.5 chars",
452 message: WM_MOUSEHWHEEL, delta: -
20,
453 target: gP1, x:
10, y:
10, window,
457 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
461 // Even if the mouse cursor is an element whose font-size is different than
462 // the scrollable element, the pixel scroll amount shouldn't be changed.
463 // Widget shouldn't dispatch a pixel event if the delta can be devided by
464 // lines to be scrolled. However, pixel events should be fired by ESM.
465 { description:
"WM_MOUSEWHEEL, -120, 3 lines, on the other div whose font-size is larger",
466 message: WM_MOUSEWHEEL, delta: -
120,
467 target: gP2, x:
10, y:
10, window,
471 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
475 { description:
"WM_MOUSEWHEEL, 120, -3 lines, on the other div whose font-size is larger",
476 message: WM_MOUSEWHEEL, delta:
120,
477 target: gP2, x:
10, y:
10, window,
481 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
485 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, on the other div whose font-size is larger",
486 message: WM_MOUSEHWHEEL, delta:
120,
487 target: gP2, x:
10, y:
10, window,
491 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
495 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, on the other div whose font-size is larger",
496 message: WM_MOUSEHWHEEL, delta: -
120,
497 target: gP2, x:
10, y:
10, window,
501 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
505 // Modifier key tests
506 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Shift",
507 message: WM_MOUSEWHEEL, delta: -
40,
508 target: gP1, x:
10, y:
10, window,
512 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
515 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Shift",
516 message: WM_MOUSEWHEEL, delta: -
40,
517 target: gP1, x:
10, y:
10, window,
521 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
524 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Ctrl",
525 message: WM_MOUSEWHEEL, delta: -
40,
526 target: gP1, x:
10, y:
10, window,
530 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
533 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Ctrl",
534 message: WM_MOUSEWHEEL, delta: -
40,
535 target: gP1, x:
10, y:
10, window,
539 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
542 { description:
"WM_MOUSEWHEEL, -40, 1 line with left Alt",
543 message: WM_MOUSEWHEEL, delta: -
40,
544 target: gP1, x:
10, y:
10, window,
548 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
551 { description:
"WM_MOUSEWHEEL, -40, 1 line with right Alt",
552 message: WM_MOUSEWHEEL, delta: -
40,
553 target: gP1, x:
10, y:
10, window,
557 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
561 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Shift",
562 message: WM_MOUSEHWHEEL, delta:
40,
563 target: gP1, x:
10, y:
10, window,
567 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
570 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Shift",
571 message: WM_MOUSEHWHEEL, delta:
40,
572 target: gP1, x:
10, y:
10, window,
576 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
579 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Ctrl",
580 message: WM_MOUSEHWHEEL, delta:
40,
581 target: gP1, x:
10, y:
10, window,
585 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
588 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Ctrl",
589 message: WM_MOUSEHWHEEL, delta:
40,
590 target: gP1, x:
10, y:
10, window,
594 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
597 { description:
"WM_MOUSEHWHEEL, 40, 1 character with left Alt",
598 message: WM_MOUSEHWHEEL, delta:
40,
599 target: gP1, x:
10, y:
10, window,
603 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
606 { description:
"WM_MOUSEHWHEEL, 40, 1 character with right Alt",
607 message: WM_MOUSEHWHEEL, delta:
40,
608 target: gP1, x:
10, y:
10, window,
612 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
616 runNextTest(gScrollMessageTests,
0);
621 var gPageScrllTests = [
622 // Pixel scroll event should be fired always but line scroll event should be
623 // fired only when accumulated delta value is over a line.
624 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages",
625 message: WM_MOUSEWHEEL, delta: -
60,
626 target: gP1, x:
10, y:
10, window,
630 axis: kVAxis, lines:
0, pixels() { return gPageHeight /
2; },
633 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages (pending: 0.5 pages)",
634 message: WM_MOUSEWHEEL, delta: -
60,
635 target: gP1, x:
10, y:
10, window,
639 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
640 pixels() { return ((gPageHeight /
2) + (gPageHeight %
2)); },
643 { description:
"WM_MOUSEWHEEL, -60, 0.5 pages",
644 message: WM_MOUSEWHEEL, delta: -
60,
645 target: gP1, x:
10, y:
10, window,
649 axis: kVAxis, lines:
0, pixels() { return gPageHeight /
2; },
653 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages (pending: 0.5 pages)",
654 message: WM_MOUSEWHEEL, delta:
60,
655 target: gP1, x:
10, y:
10, window,
659 axis: kVAxis, lines:
0, pixels() { return gPageHeight / -
2; },
662 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages (pending: -0.5 pages)",
663 message: WM_MOUSEWHEEL, delta:
60,
664 target: gP1, x:
10, y:
10, window,
668 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
669 pixels() { return -((gPageHeight /
2) + (gPageHeight %
2)); },
672 { description:
"WM_MOUSEWHEEL, 60, -0.5 pages",
673 message: WM_MOUSEWHEEL, delta:
60,
674 target: gP1, x:
10, y:
10, window,
678 axis: kVAxis, lines:
0, pixels() { return gPageHeight / -
2; },
682 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages",
683 message: WM_MOUSEHWHEEL, delta:
60,
684 target: gP1, x:
10, y:
10, window,
688 axis: kHAxis, lines:
0, pixels() { return gPageWidth /
2; },
691 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages (pending: 0.5 pages)",
692 message: WM_MOUSEHWHEEL, delta:
60,
693 target: gP1, x:
10, y:
10, window,
697 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
698 pixels() { return ((gPageWidth /
2) + (gPageWidth %
2)); },
701 { description:
"WM_MOUSEHWHEEL, 60, 0.5 pages",
702 message: WM_MOUSEHWHEEL, delta:
60,
703 target: gP1, x:
10, y:
10, window,
707 axis: kHAxis, lines:
0, pixels() { return gPageWidth /
2; },
711 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages (pending: 0.5 pages)",
712 message: WM_MOUSEHWHEEL, delta: -
60,
713 target: gP1, x:
10, y:
10, window,
717 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
720 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages (pending: -0.5 pages)",
721 message: WM_MOUSEHWHEEL, delta: -
60,
722 target: gP1, x:
10, y:
10, window,
726 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
727 pixels() { return -((gCharWidth /
2) + (gCharWidth %
2)); },
730 { description:
"WM_MOUSEHWHEEL, -60, -0.5 pages",
731 message: WM_MOUSEHWHEEL, delta: -
60,
732 target: gP1, x:
10, y:
10, window,
736 axis: kHAxis, lines:
0, pixels() { return gCharWidth / -
2; },
741 var gScrollMessageTests = [
742 // Widget should dispatch neither line scroll event nor pixel scroll event if
743 // the WM_*SCROLL's lParam is NULL and mouse wheel emulation is disabled.
744 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation disabled",
745 message: WM_VSCROLL, delta: SB_LINEDOWN,
746 target: gP1, x:
10, y:
10, window,
750 axis: kVAxis, lines:
0, pixels:
0,
753 SpecialPowers.setIntPref(kVAmountPref,
3);
754 SpecialPowers.setIntPref(kHAmountPref,
3);
755 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
759 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation disabled",
760 message: WM_VSCROLL, delta: SB_LINEUP,
761 target: gP1, x:
10, y:
10, window,
765 axis: kVAxis, lines:
0, pixels:
0,
769 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation disabled",
770 message: WM_HSCROLL, delta: SB_LINERIGHT,
771 target: gP1, x:
10, y:
10, window,
775 axis: kHAxis, lines:
0, pixels:
0,
779 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation disabled",
780 message: WM_HSCROLL, delta: SB_LINELEFT,
781 target: gP1, x:
10, y:
10, window,
785 axis: kHAxis, lines:
0, pixels:
0,
789 // Widget should emulate mouse wheel behavior for WM_*SCROLL even if the
790 // kEmulateWheelByWMSCROLLPref is disabled but the message's lParam is not
791 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages,
792 // but ESM dispatches it instead.
793 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled",
794 message: WM_VSCROLL, delta: SB_LINEUP,
795 target: gP1, x:
10, y:
10, window,
797 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
799 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
802 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
806 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled",
807 message: WM_VSCROLL, delta: SB_LINEDOWN,
808 target: gP1, x:
10, y:
10, window,
810 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
812 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
816 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled",
817 message: WM_HSCROLL, delta: SB_LINELEFT,
818 target: gP1, x:
10, y:
10, window,
820 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
822 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
826 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled",
827 message: WM_HSCROLL, delta: SB_LINERIGHT,
828 target: gP1, x:
10, y:
10, window,
830 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
832 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
836 { description:
"WM_VSCROLL, SB_PAGEUP, lParam is not NULL, emulation disabled",
837 message: WM_VSCROLL, delta: SB_PAGEUP,
838 target: gP1, x:
10, y:
10, window,
840 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
842 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
843 pixels() { return -gPageHeight; },
847 { description:
"WM_VSCROLL, SB_PAGEDOWN, lParam is not NULL, emulation disabled",
848 message: WM_VSCROLL, delta: SB_PAGEDOWN,
849 target: gP1, x:
10, y:
10, window,
851 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
853 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
854 pixels() { return gPageHeight; },
858 { description:
"WM_HSCROLL, SB_PAGELEFT, lParam is not NULL, emulation disabled",
859 message: WM_HSCROLL, delta: SB_PAGELEFT,
860 target: gP1, x:
10, y:
10, window,
862 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
864 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
865 pixels() { return -gPageWidth; },
869 { description:
"WM_HSCROLL, SB_PAGERIGHT, lParam is not NULL, emulation disabled",
870 message: WM_HSCROLL, delta: SB_PAGERIGHT,
871 target: gP1, x:
10, y:
10, window,
873 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
875 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
876 pixels() { return gPageWidth; },
880 // Widget should emulate mouse wheel behavior for WM_*SCROLL when the
881 // kEmulateWheelByWMSCROLLPref is enabled even if the message's lParam is
882 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages,
883 // but ESM dispatches it instead.
884 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled",
885 message: WM_VSCROLL, delta: SB_LINEUP,
886 target: gP1, x:
10, y:
10, window,
890 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
893 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
897 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled",
898 message: WM_VSCROLL, delta: SB_LINEDOWN,
899 target: gP1, x:
10, y:
10, window,
903 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
907 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled",
908 message: WM_HSCROLL, delta: SB_LINELEFT,
909 target: gP1, x:
10, y:
10, window,
913 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
917 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled",
918 message: WM_HSCROLL, delta: SB_LINERIGHT,
919 target: gP1, x:
10, y:
10, window,
923 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
927 { description:
"WM_VSCROLL, SB_PAGEUP, lParam is NULL, emulation enabled",
928 message: WM_VSCROLL, delta: SB_PAGEUP,
929 target: gP1, x:
10, y:
10, window,
933 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA,
934 pixels() { return -gPageHeight; },
938 { description:
"WM_VSCROLL, SB_PAGEDOWN, lParam is NULL, emulation enabled",
939 message: WM_VSCROLL, delta: SB_PAGEDOWN,
940 target: gP1, x:
10, y:
10, window,
944 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA,
945 pixels() { return gPageHeight; },
949 { description:
"WM_HSCROLL, SB_PAGELEFT, lParam is NULL, emulation enabled",
950 message: WM_HSCROLL, delta: SB_PAGELEFT,
951 target: gP1, x:
10, y:
10, window,
955 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA,
956 pixels() { return -gPageWidth; },
960 { description:
"WM_HSCROLL, SB_PAGERIGHT, lParam is NULL, emulation enabled",
961 message: WM_HSCROLL, delta: SB_PAGERIGHT,
962 target: gP1, x:
10, y:
10, window,
966 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA,
967 pixels() { return gPageWidth; },
971 // Modifier key tests for WM_*SCROLL
972 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Shift",
973 message: WM_VSCROLL, delta: SB_LINEDOWN,
974 target: gP1, x:
10, y:
10, window,
976 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
978 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
981 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
984 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Shift",
985 message: WM_VSCROLL, delta: SB_LINEDOWN,
986 target: gP1, x:
10, y:
10, window,
988 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
990 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
993 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Ctrl",
994 message: WM_VSCROLL, delta: SB_LINEDOWN,
995 target: gP1, x:
10, y:
10, window,
997 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
999 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1002 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Ctrl",
1003 message: WM_VSCROLL, delta: SB_LINEDOWN,
1004 target: gP1, x:
10, y:
10, window,
1006 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1008 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1011 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Alt",
1012 message: WM_VSCROLL, delta: SB_LINEDOWN,
1013 target: gP1, x:
10, y:
10, window,
1015 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1017 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1020 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Alt",
1021 message: WM_VSCROLL, delta: SB_LINEDOWN,
1022 target: gP1, x:
10, y:
10, window,
1024 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1026 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1030 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Shift",
1031 message: WM_HSCROLL, delta: SB_LINERIGHT,
1032 target: gP1, x:
10, y:
10, window,
1034 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1036 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1039 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Shift",
1040 message: WM_HSCROLL, delta: SB_LINERIGHT,
1041 target: gP1, x:
10, y:
10, window,
1043 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1045 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1048 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Ctrl",
1049 message: WM_HSCROLL, delta: SB_LINERIGHT,
1050 target: gP1, x:
10, y:
10, window,
1052 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1054 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1057 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Ctrl",
1058 message: WM_HSCROLL, delta: SB_LINERIGHT,
1059 target: gP1, x:
10, y:
10, window,
1061 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1063 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1066 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Alt",
1067 message: WM_HSCROLL, delta: SB_LINERIGHT,
1068 target: gP1, x:
10, y:
10, window,
1070 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1072 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1075 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Alt",
1076 message: WM_HSCROLL, delta: SB_LINERIGHT,
1077 target: gP1, x:
10, y:
10, window,
1079 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1081 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1085 runDeactiveWindowTests();
1090 var gDeactiveWindowTests = [
1091 // Typically, mouse drivers send wheel messages to focused window.
1092 // However, we prefer to scroll a scrollable element under the mouse cursor.
1093 { description:
"WM_MOUSEWHEEL, -120, 3 lines, window is deactive",
1094 message: WM_MOUSEWHEEL, delta: -
120,
1095 target: gP1, x:
10, y:
10, window,
1099 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
1102 SpecialPowers.setIntPref(kVAmountPref,
3);
1103 SpecialPowers.setIntPref(kHAmountPref,
3);
1105 onLineScrollEvent(aEvent) {
1106 var fm = Services.focus;
1107 is(fm.activeWindow, gOtherWindow,
"The other window isn't activated");
1111 { description:
"WM_MOUSEWHEEL, 120, -3 lines, window is deactive",
1112 message: WM_MOUSEWHEEL, delta:
120,
1113 target: gP1, x:
10, y:
10, window,
1117 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
1121 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, window is deactive",
1122 message: WM_MOUSEHWHEEL, delta:
120,
1123 target: gP1, x:
10, y:
10, window,
1127 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
1131 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, window is deactive",
1132 message: WM_MOUSEHWHEEL, delta: -
120,
1133 target: gP1, x:
10, y:
10, window,
1137 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
1141 // Of course, even if some drivers prefer the cursor position, we don't need
1142 // to change anything.
1143 { description:
"WM_MOUSEWHEEL, -120, 3 lines, window is deactive (receive the message directly)",
1144 message: WM_MOUSEWHEEL, delta: -
120,
1145 target: gP1, x:
10, y:
10, window,
1147 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1149 axis: kVAxis, lines:
3, pixels() { return gLineHeight *
3; },
1153 { description:
"WM_MOUSEWHEEL, 120, -3 lines, window is deactive (receive the message directly)",
1154 message: WM_MOUSEWHEEL, delta:
120,
1155 target: gP1, x:
10, y:
10, window,
1157 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1159 axis: kVAxis, lines: -
3, pixels() { return gLineHeight * -
3; },
1163 { description:
"WM_MOUSEHWHEEL, 120, 3 chars, window is deactive (receive the message directly)",
1164 message: WM_MOUSEHWHEEL, delta:
120,
1165 target: gP1, x:
10, y:
10, window,
1167 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1169 axis: kHAxis, lines:
3, pixels() { return gCharWidth *
3; },
1173 { description:
"WM_MOUSEHWHEEL, -120, -3 chars, window is deactive (receive the message directly)",
1174 message: WM_MOUSEHWHEEL, delta: -
120,
1175 target: gP1, x:
10, y:
10, window,
1177 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1179 axis: kHAxis, lines: -
3, pixels() { return gCharWidth * -
3; },
1183 // Same for WM_*SCROLL if lParam is not NULL
1184 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive",
1185 message: WM_VSCROLL, delta: SB_LINEUP,
1186 target: gP1, x:
10, y:
10, window,
1188 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1190 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1193 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
1197 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive",
1198 message: WM_VSCROLL, delta: SB_LINEDOWN,
1199 target: gP1, x:
10, y:
10, window,
1201 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1203 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1207 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive",
1208 message: WM_HSCROLL, delta: SB_LINELEFT,
1209 target: gP1, x:
10, y:
10, window,
1211 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1213 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1217 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive",
1218 message: WM_HSCROLL, delta: SB_LINERIGHT,
1219 target: gP1, x:
10, y:
10, window,
1221 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL,
1223 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1227 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled
1228 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive",
1229 message: WM_VSCROLL, delta: SB_LINEUP,
1230 target: gP1, x:
10, y:
10, window,
1234 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1237 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
1241 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive",
1242 message: WM_VSCROLL, delta: SB_LINEDOWN,
1243 target: gP1, x:
10, y:
10, window,
1247 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1251 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive",
1252 message: WM_HSCROLL, delta: SB_LINELEFT,
1253 target: gP1, x:
10, y:
10, window,
1257 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1261 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive",
1262 message: WM_HSCROLL, delta: SB_LINERIGHT,
1263 target: gP1, x:
10, y:
10, window,
1267 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1271 // Same for WM_*SCROLL if lParam is not NULL and message sent to the deactive window directly
1272 { description:
"WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1273 message: WM_VSCROLL, delta: SB_LINEUP,
1274 target: gP1, x:
10, y:
10, window,
1276 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1277 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1279 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1282 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false);
1286 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1287 message: WM_VSCROLL, delta: SB_LINEDOWN,
1288 target: gP1, x:
10, y:
10, window,
1290 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1291 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1293 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1297 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1298 message: WM_HSCROLL, delta: SB_LINELEFT,
1299 target: gP1, x:
10, y:
10, window,
1301 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1302 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1304 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1308 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)",
1309 message: WM_HSCROLL, delta: SB_LINERIGHT,
1310 target: gP1, x:
10, y:
10, window,
1312 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL |
1313 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1315 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1319 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled, and message sent to the deactive window directly
1320 { description:
"WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1321 message: WM_VSCROLL, delta: SB_LINEUP,
1322 target: gP1, x:
10, y:
10, window,
1324 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1326 axis: kVAxis, lines: -
1, pixels() { return -gLineHeight; },
1329 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true);
1333 { description:
"WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1334 message: WM_VSCROLL, delta: SB_LINEDOWN,
1335 target: gP1, x:
10, y:
10, window,
1337 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1339 axis: kVAxis, lines:
1, pixels() { return gLineHeight; },
1343 { description:
"WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1344 message: WM_HSCROLL, delta: SB_LINELEFT,
1345 target: gP1, x:
10, y:
10, window,
1347 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1349 axis: kHAxis, lines: -
1, pixels() { return -gCharWidth; },
1353 { description:
"WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)",
1354 message: WM_HSCROLL, delta: SB_LINERIGHT,
1355 target: gP1, x:
10, y:
10, window,
1357 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT,
1359 axis: kHAxis, lines:
1, pixels() { return gCharWidth; },
1363 gOtherWindow.close();
1364 gOtherWindow = null;
1370 function runDeactiveWindowTests() {
1371 gOtherWindow = window.open(
"window_mouse_scroll_win_2.html",
"_blank",
1372 "chrome,width=100,height=100,top=700,left=700");
1374 window.arguments[
0].SimpleTest.waitForFocus(function() {
1375 runNextTest(gDeactiveWindowTests,
0);
1379 function runNextTest(aTests, aIndex) {
1380 if (aIndex
> 0 && aTests[aIndex -
1] && aTests[aIndex -
1].finish) {
1381 aTests[aIndex -
1].finish();
1384 if (aTests.length == aIndex) {
1388 var test = aTests[aIndex++];
1392 test.handled = { lines: false, pixels: false };
1394 switch (test.message) {
1396 case WM_MOUSEHWHEEL:
1399 var expectedLines = test.expected.lines;
1400 var expectedPixels =
1401 cut((typeof test.expected.pixels ==
"function") ?
1402 test.expected.pixels() : test.expected.pixels);
1403 var handler = function(aEvent) {
1404 var doCommonTests = true;
1407 ok(!test.handled.lines,
1408 test.description +
", line scroll event has been handled");
1409 ok(!test.handled.pixels,
1410 test.description +
", pixel scroll event has been handled");
1411 doCommonTests = false;
1412 } else if (aEvent.type == kMouseLineScrollEvent) {
1413 ok(!test.handled.lines,
1414 test.description +
":(" + aEvent.type +
"), same event has already been handled");
1415 test.handled.lines = true;
1416 isnot(expectedLines,
0,
1417 test.description +
":(" + aEvent.type +
"), event shouldn't be fired");
1418 if (test.onLineScrollEvent && test.onLineScrollEvent(aEvent)) {
1419 doCommonTests = false;
1421 } else if (aEvent.type == kMousePixelScrollEvent) {
1422 ok(!test.handled.pixels,
1423 test.description +
":(" + aEvent.type +
"), same event has already been handled");
1424 test.handled.pixels = true;
1425 isnot(expectedPixels,
0,
1426 test.description +
":(" + aEvent.type +
"), event shouldn't be fired");
1427 if (test.onPixelScrollEvent && test.onPixelScrollEvent(aEvent)) {
1428 doCommonTests = false;
1432 if (doCommonTests) {
1434 (aEvent.type == kMouseLineScrollEvent) ?
1435 expectedLines : expectedPixels;
1436 is(aEvent.target.id, test.target.id,
1437 test.description +
":(" + aEvent.type +
"), ID mismatch");
1438 is(aEvent.axis, test.expected.axis,
1439 test.description +
":(" + aEvent.type +
"), axis mismatch");
1440 ok(aEvent.detail !=
0,
1441 test.description +
":(" + aEvent.type +
"), delta must not be 0");
1442 is(aEvent.detail, expectedDelta,
1443 test.description +
":(" + aEvent.type +
"), delta mismatch");
1444 is(aEvent.shiftKey, (test.modifiers & (SHIFT_L | SHIFT_R)) !=
0,
1445 test.description +
":(" + aEvent.type +
"), shiftKey mismatch");
1446 is(aEvent.ctrlKey, (test.modifiers & (CTRL_L | CTRL_R)) !=
0,
1447 test.description +
":(" + aEvent.type +
"), ctrlKey mismatch");
1448 is(aEvent.altKey, (test.modifiers & (ALT_L | ALT_R)) !=
0,
1449 test.description +
":(" + aEvent.type +
"), altKey mismatch");
1452 if (!aEvent || (test.handled.lines || expectedLines ==
0) &&
1453 (test.handled.pixels || expectedPixels ==
0)) {
1454 // Don't scroll actually.
1456 aEvent.preventDefault();
1458 test.target.removeEventListener(kMouseLineScrollEvent, handler, true);
1459 test.target.removeEventListener(kMousePixelScrollEvent, handler, true);
1460 setTimeout(runNextTest,
0, aTests, aIndex);
1464 test.target.addEventListener(kMouseLineScrollEvent, handler, true);
1465 test.target.addEventListener(kMousePixelScrollEvent, handler, true);
1467 if (expectedLines ==
0 && expectedPixels ==
0) {
1468 // The timeout might not be enough if system is slow by other process,
1469 // so, the test might be passed unexpectedly. However, it must be able
1470 // to be detected by random orange.
1471 setTimeout(handler,
500);
1474 var utils = getWindowUtils(test.window);
1475 var ptInScreen = getPointInScreen(test.target, test.window);
1477 ((test.message == WM_MOUSEWHEEL) || (test.message == WM_VSCROLL));
1478 var deltaX = !isVertical ? test.delta :
0;
1479 var deltaY = isVertical ? test.delta :
0;
1480 utils.sendNativeMouseScrollEvent(ptInScreen.x + test.x,
1481 ptInScreen.y + test.y,
1482 test.message, deltaX, deltaY,
0,
1484 test.additionalFlags,
1488 ok(false, test.description +
": invalid message");
1493 function prepareTests() {
1494 // Disable special action with modifier key
1495 SpecialPowers.setIntPref(kAltKeyActionPref,
1);
1496 SpecialPowers.setIntPref(kCtrlKeyActionPref,
1);
1497 SpecialPowers.setIntPref(kShiftKeyActionPref,
1);
1498 SpecialPowers.setIntPref(kWinKeyActionPref,
1);
1500 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierXPref,
100);
1501 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierYPref,
100);
1502 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierXPref,
100);
1503 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierYPref,
100);
1504 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierXPref,
100);
1505 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierYPref,
100);
1506 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierXPref,
100);
1507 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref,
100);
1509 SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false);
1510 SpecialPowers.setIntPref(kTimeoutPref, -
1);
1512 runNextTest(gPreparingSteps,
0);