|
1 <html lang="en-US" |
|
2 style="font-family: Arial; font-size: 10px; line-height: 16px;"> |
|
3 <head> |
|
4 <title>Test for mouse scroll handling on Windows</title> |
|
5 <script type="text/javascript" |
|
6 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
7 <script type="text/javascript" |
|
8 src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script> |
|
9 <script type="text/javascript" |
|
10 src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script> |
|
11 <link rel="stylesheet" type="text/css" |
|
12 href="chrome://mochikit/content/tests/SimpleTest/test.css" /> |
|
13 </head> |
|
14 <body onunload="onUnload();"> |
|
15 <div id="display" style="width: 5000px; height: 5000px;"> |
|
16 <p id="p1" style="font-size: 16px; width: 100px; height: 100px;">1st <p>.</p> |
|
17 <p id="p2" style="font-size: 32px; width: 100px; height: 100px;">2nd <p>.</p> |
|
18 </div> |
|
19 <script class="testbody" type="application/javascript"> |
|
20 |
|
21 window.opener.wrappedJSObject.SimpleTest.waitForFocus(prepareTests, window); |
|
22 |
|
23 const nsIDOMWindowUtils = Components.interfaces.nsIDOMWindowUtils; |
|
24 |
|
25 const WHEEL_PAGESCROLL = 4294967295; |
|
26 |
|
27 const WM_VSCROLL = 0x0115; |
|
28 const WM_HSCROLL = 0x0114; |
|
29 const WM_MOUSEWHEEL = 0x020A; |
|
30 const WM_MOUSEHWHEEL = 0x020E; |
|
31 |
|
32 const SB_LINEUP = 0; |
|
33 const SB_LINELEFT = 0; |
|
34 const SB_LINEDOWN = 1; |
|
35 const SB_LINERIGHT = 1; |
|
36 const SB_PAGEUP = 2; |
|
37 const SB_PAGELEFT = 2; |
|
38 const SB_PAGEDOWN = 3; |
|
39 const SB_PAGERIGHT = 3; |
|
40 |
|
41 const SHIFT_L = 0x0100; |
|
42 const SHIFT_R = 0x0200; |
|
43 const CTRL_L = 0x0400; |
|
44 const CTRL_R = 0x0800; |
|
45 const ALT_L = 0x1000; |
|
46 const ALT_R = 0x2000; |
|
47 |
|
48 const DOM_PAGE_SCROLL_DELTA = 32768; |
|
49 |
|
50 const kSystemScrollSpeedOverridePref = "mousewheel.system_scroll_override_on_root_content.enabled"; |
|
51 |
|
52 const kAltKeyActionPref = "mousewheel.with_alt.action"; |
|
53 const kCtrlKeyActionPref = "mousewheel.with_control.action"; |
|
54 const kShiftKeyActionPref = "mousewheel.with_shift.action"; |
|
55 const kWinKeyActionPref = "mousewheel.with_win.action"; |
|
56 |
|
57 const kAltKeyDeltaMultiplierXPref = "mousewheel.with_alt.delta_multiplier_x"; |
|
58 const kAltKeyDeltaMultiplierYPref = "mousewheel.with_alt.delta_multiplier_y"; |
|
59 const kCtrlKeyDeltaMultiplierXPref = "mousewheel.with_control.delta_multiplier_x"; |
|
60 const kCtrlKeyDeltaMultiplierYPref = "mousewheel.with_control.delta_multiplier_y"; |
|
61 const kShiftKeyDeltaMultiplierXPref = "mousewheel.with_shift.delta_multiplier_x"; |
|
62 const kShiftKeyDeltaMultiplierYPref = "mousewheel.with_shift.delta_multiplier_y"; |
|
63 const kWinKeyDeltaMultiplierXPref = "mousewheel.with_win.delta_multiplier_x"; |
|
64 const kWinKeyDeltaMultiplierYPref = "mousewheel.with_win.delta_multiplier_y"; |
|
65 |
|
66 const kEmulateWheelByWMSCROLLPref = "mousewheel.emulate_at_wm_scroll"; |
|
67 const kVAmountPref = "mousewheel.windows.vertical_amount_override"; |
|
68 const kHAmountPref = "mousewheel.windows.horizontal_amount_override"; |
|
69 const kTimeoutPref = "mousewheel.windows.transaction.timeout"; |
|
70 |
|
71 const kMouseLineScrollEvent = "DOMMouseScroll"; |
|
72 const kMousePixelScrollEvent = "MozMousePixelScroll"; |
|
73 |
|
74 const kVAxis = Components.interfaces.nsIDOMMouseScrollEvent.VERTICAL_AXIS; |
|
75 const kHAxis = Components.interfaces.nsIDOMMouseScrollEvent.HORIZONTAL_AXIS; |
|
76 |
|
77 var gLineHeight = 0; |
|
78 var gCharWidth = 0; |
|
79 var gPageHeight = 0; |
|
80 var gPageWidth = 0; |
|
81 |
|
82 var gP1 = document.getElementById("p1"); |
|
83 var gP2 = document.getElementById("p2"); |
|
84 |
|
85 var gOtherWindow; |
|
86 |
|
87 function ok(aCondition, aMessage) |
|
88 { |
|
89 window.opener.wrappedJSObject.SimpleTest.ok(aCondition, aMessage); |
|
90 } |
|
91 |
|
92 function is(aLeft, aRight, aMessage) |
|
93 { |
|
94 window.opener.wrappedJSObject.SimpleTest.is(aLeft, aRight, aMessage); |
|
95 } |
|
96 |
|
97 function isnot(aLeft, aRight, aMessage) |
|
98 { |
|
99 window.opener.wrappedJSObject.SimpleTest.isnot(aLeft, aRight, aMessage); |
|
100 } |
|
101 |
|
102 function todo_is(aLeft, aRight, aMessage) |
|
103 { |
|
104 window.opener.wrappedJSObject.SimpleTest.todo_is(aLeft, aRight, aMessage); |
|
105 } |
|
106 |
|
107 function onUnload() |
|
108 { |
|
109 SpecialPowers.clearUserPref(kAltKeyActionPref); |
|
110 SpecialPowers.clearUserPref(kCtrlKeyActionPref); |
|
111 SpecialPowers.clearUserPref(kShiftKeyActionPref); |
|
112 SpecialPowers.clearUserPref(kWinKeyActionPref); |
|
113 |
|
114 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierXPref); |
|
115 SpecialPowers.clearUserPref(kAltKeyDeltaMultiplierYPref); |
|
116 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierXPref); |
|
117 SpecialPowers.clearUserPref(kCtrlKeyDeltaMultiplierYPref); |
|
118 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierXPref); |
|
119 SpecialPowers.clearUserPref(kShiftKeyDeltaMultiplierYPref); |
|
120 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierXPref); |
|
121 SpecialPowers.clearUserPref(kWinKeyDeltaMultiplierYPref); |
|
122 |
|
123 SpecialPowers.clearUserPref(kSystemScrollSpeedOverridePref); |
|
124 SpecialPowers.clearUserPref(kEmulateWheelByWMSCROLLPref); |
|
125 SpecialPowers.clearUserPref(kVAmountPref); |
|
126 SpecialPowers.clearUserPref(kHAmountPref); |
|
127 SpecialPowers.clearUserPref(kTimeoutPref); |
|
128 window.opener.wrappedJSObject.SimpleTest.finish(); |
|
129 } |
|
130 |
|
131 function getWindowUtils(aWindow) |
|
132 { |
|
133 if (!aWindow) { |
|
134 aWindow = window; |
|
135 } |
|
136 return aWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor) |
|
137 .getInterface(nsIDOMWindowUtils); |
|
138 } |
|
139 |
|
140 function getPointInScreen(aElement, aWindow) |
|
141 { |
|
142 if (!aWindow) { |
|
143 aWindow = window; |
|
144 } |
|
145 var bounds = aElement.getBoundingClientRect(); |
|
146 return { x: bounds.left + aWindow.mozInnerScreenX, |
|
147 y: bounds.top + aWindow.mozInnerScreenY }; |
|
148 } |
|
149 |
|
150 function cut(aNum) |
|
151 { |
|
152 return (aNum >= 0) ? Math.floor(aNum) : Math.ceil(aNum); |
|
153 } |
|
154 |
|
155 /** |
|
156 * Make each steps for the tests in following arrays in global scope. Each item |
|
157 * of the arrays will be executed after previous test is finished. |
|
158 * |
|
159 * description: |
|
160 * Set the description of the test. This will be used for the message of is() |
|
161 * or the others. |
|
162 * |
|
163 * message: |
|
164 * aNativeMessage of nsIDOMWindowUtils.sendNativeMouseScrollEvent(). |
|
165 * Must be WM_MOUSEWHEEL, WM_MOUSEHWHEEL, WM_VSCROLL or WM_HSCROLL. |
|
166 * |
|
167 * delta: |
|
168 * The native delta value for WM_MOUSEWHEEL or WM_MOUSEHWHEEL. |
|
169 * Or one of the SB_* const value for WM_VSCROLL or WM_HSCROLL. |
|
170 * |
|
171 * target: |
|
172 * The target element, under the mouse cursor. |
|
173 * |
|
174 * window: |
|
175 * The window which is used for getting nsIDOMWindowUtils. |
|
176 * |
|
177 * modifiers: |
|
178 * Pressed modifier keys, 0 means no modifier key is pressed. |
|
179 * Otherwise, one or more values of SHIFT_L, SHIFT_R, CTRL_L, CTRL_R, |
|
180 * ALT_L or ALT_R. |
|
181 * |
|
182 * additionalFlags: |
|
183 * aAdditionalFlags of nsIDOMWindowUtils.sendNativeMouseScrollEvent(). |
|
184 * See the document of nsIDOMWindowUtils for the detail of the values. |
|
185 * |
|
186 * onLineScrollEvent: |
|
187 * Must be a function or null. |
|
188 * If the value is a function, it will be called when DOMMouseScroll event |
|
189 * is received by the synthesized event. |
|
190 * If return true, the common checks are canceled. |
|
191 * |
|
192 * onPixelScrollEvent: |
|
193 * Must be a function or null. |
|
194 * If the value is a function, it will be called when MozMousePixelScroll |
|
195 * event is received by the synthesized event. |
|
196 * If return true, the common checks are canceled. |
|
197 * |
|
198 * expected: |
|
199 * Must not be null and this must have: |
|
200 * axis: |
|
201 * kVAxis if the synthesized event causes vertical scroll. Otherwise, |
|
202 * it causes horizontal scroll, kHAxis. |
|
203 * lines: |
|
204 * Integer value which is expected detail attribute value of |
|
205 * DOMMouseScroll. If the event shouldn't be fired, must be 0. |
|
206 * pixels: |
|
207 * Integer value or a function which returns double value. The value is |
|
208 * expected detail attribute value of MozMousePixelScroll. |
|
209 * If the event shouldn't be fired, must be 0. |
|
210 * |
|
211 * Note that if both lines and pixels are 0, the test framework waits |
|
212 * a few seconds. After that, go to next test. |
|
213 * |
|
214 * init: |
|
215 * Must be a function or null. If this value is a function, it's called |
|
216 * before synthesizing the native event. |
|
217 * |
|
218 * finish: |
|
219 * Must be a function or null. If this value is a function, it's called |
|
220 * after received all expected events or timeout if no events are expected. |
|
221 */ |
|
222 |
|
223 // First, get the computed line height, char width, page height and page width. |
|
224 var gPreparingSteps = [ |
|
225 { description: "Preparing gLineHeight", |
|
226 message: WM_MOUSEWHEEL, delta: -120, |
|
227 target: gP1, x: 10, y: 10, window: window, |
|
228 modifiers: 0, |
|
229 additionalFlags: 0, |
|
230 onLineScrollEvent: function (aEvent) { |
|
231 return true; |
|
232 }, |
|
233 onPixelScrollEvent: function (aEvent) { |
|
234 gLineHeight = aEvent.detail; |
|
235 return true; |
|
236 }, |
|
237 expected: { |
|
238 axis: kVAxis, lines: 1, pixels: 1, |
|
239 }, |
|
240 init: function () { |
|
241 SpecialPowers.setIntPref(kVAmountPref, 1); |
|
242 SpecialPowers.setIntPref(kHAmountPref, 1); |
|
243 }, |
|
244 }, |
|
245 { description: "Preparing gCharWidth", |
|
246 message: WM_MOUSEHWHEEL, delta: 120, |
|
247 target: gP1, x: 10, y: 10, window: window, |
|
248 modifiers: 0, |
|
249 additionalFlags: 0, |
|
250 onLineScrollEvent: function (aEvent) { |
|
251 return true; |
|
252 }, |
|
253 onPixelScrollEvent: function (aEvent) { |
|
254 gCharWidth = aEvent.detail; |
|
255 return true; |
|
256 }, |
|
257 expected: { |
|
258 axis: kVAxis, lines: 1, pixels: 1, |
|
259 }, |
|
260 }, |
|
261 { description: "Preparing gPageHeight", |
|
262 message: WM_MOUSEWHEEL, delta: -120, |
|
263 target: gP1, x: 10, y: 10, window: window, |
|
264 modifiers: 0, |
|
265 additionalFlags: 0, |
|
266 onLineScrollEvent: function (aEvent) { |
|
267 return true; |
|
268 }, |
|
269 onPixelScrollEvent: function (aEvent) { |
|
270 gPageHeight = aEvent.detail; |
|
271 return true; |
|
272 }, |
|
273 expected: { |
|
274 axis: kHAxis, lines: 1, pixels: 1, |
|
275 }, |
|
276 init: function () { |
|
277 SpecialPowers.setIntPref(kVAmountPref, 0xFFFF); |
|
278 SpecialPowers.setIntPref(kHAmountPref, 0xFFFF); |
|
279 }, |
|
280 }, |
|
281 { description: "Preparing gPageWidth", |
|
282 message: WM_MOUSEHWHEEL, delta: 120, |
|
283 target: gP1, x: 10, y: 10, window: window, |
|
284 modifiers: 0, |
|
285 additionalFlags: 0, |
|
286 onLineScrollEvent: function (aEvent) { |
|
287 return true; |
|
288 }, |
|
289 onPixelScrollEvent: function (aEvent) { |
|
290 gPageWidth = aEvent.detail; |
|
291 return true; |
|
292 }, |
|
293 expected: { |
|
294 axis: kHAxis, lines: 1, pixels: 1, |
|
295 }, |
|
296 finish: function () { |
|
297 ok(gLineHeight > 0, "gLineHeight isn't positive got " + gLineHeight); |
|
298 ok(gCharWidth > 0, "gCharWidth isn't positive got " + gCharWidth); |
|
299 ok(gPageHeight > 0, "gPageHeight isn't positive got " + gPageHeight); |
|
300 ok(gPageWidth > 0, "gPageWidth isn't positive got " + gPageWidth); |
|
301 |
|
302 ok(gPageHeight > gLineHeight, |
|
303 "gPageHeight must be larger than gLineHeight"); |
|
304 ok(gPageWidth > gCharWidth, |
|
305 "gPageWidth must be larger than gCharWidth"); |
|
306 runNextTest(gBasicTests, 0) |
|
307 } |
|
308 }, |
|
309 ]; |
|
310 |
|
311 var gBasicTests = [ |
|
312 // Widget shouldn't dispatch a pixel event if the delta can be devided by |
|
313 // lines to be scrolled. However, pixel events should be fired by ESM. |
|
314 { description: "WM_MOUSEWHEEL, -120, 3 lines", |
|
315 message: WM_MOUSEWHEEL, delta: -120, |
|
316 target: gP1, x: 10, y: 10, window: window, |
|
317 modifiers: 0, |
|
318 additionalFlags: 0, |
|
319 expected: { |
|
320 axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, |
|
321 }, |
|
322 init: function () { |
|
323 SpecialPowers.setIntPref(kVAmountPref, 3); |
|
324 SpecialPowers.setIntPref(kHAmountPref, 3); |
|
325 }, |
|
326 }, |
|
327 |
|
328 { description: "WM_MOUSEWHEEL, 120, -3 lines", |
|
329 message: WM_MOUSEWHEEL, delta: 120, |
|
330 target: gP1, x: 10, y: 10, window: window, |
|
331 modifiers: 0, |
|
332 additionalFlags: 0, |
|
333 expected: { |
|
334 axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, |
|
335 }, |
|
336 }, |
|
337 |
|
338 { description: "WM_MOUSEHWHEEL, 120, 3 chars", |
|
339 message: WM_MOUSEHWHEEL, delta: 120, |
|
340 target: gP1, x: 10, y: 10, window: window, |
|
341 modifiers: 0, |
|
342 additionalFlags: 0, |
|
343 expected: { |
|
344 axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, |
|
345 }, |
|
346 }, |
|
347 |
|
348 { description: "WM_MOUSEHWHEEL, -120, -3 chars", |
|
349 message: WM_MOUSEHWHEEL, delta: -120, |
|
350 target: gP1, x: 10, y: 10, window: window, |
|
351 modifiers: 0, |
|
352 additionalFlags: 0, |
|
353 expected: { |
|
354 axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, |
|
355 }, |
|
356 }, |
|
357 |
|
358 // Pixel scroll event should be fired always but line scroll event should be |
|
359 // fired only when accumulated delta value is over a line. |
|
360 { description: "WM_MOUSEWHEEL, -20, 0.5 lines", |
|
361 message: WM_MOUSEWHEEL, delta: -20, |
|
362 target: gP1, x: 10, y: 10, window: window, |
|
363 modifiers: 0, |
|
364 additionalFlags: 0, |
|
365 expected: { |
|
366 axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / 2; }, |
|
367 }, |
|
368 }, |
|
369 { description: "WM_MOUSEWHEEL, -20, 0.5 lines (pending: 0.5 lines)", |
|
370 message: WM_MOUSEWHEEL, delta: -20, |
|
371 target: gP1, x: 10, y: 10, window: window, |
|
372 modifiers: 0, |
|
373 additionalFlags: 0, |
|
374 expected: { |
|
375 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight / 2; }, |
|
376 }, |
|
377 }, |
|
378 { description: "WM_MOUSEWHEEL, -20, 0.5 lines", |
|
379 message: WM_MOUSEWHEEL, delta: -20, |
|
380 target: gP1, x: 10, y: 10, window: window, |
|
381 modifiers: 0, |
|
382 additionalFlags: 0, |
|
383 expected: { |
|
384 axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / 2; }, |
|
385 }, |
|
386 }, |
|
387 |
|
388 { description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: 0.5 lines)", |
|
389 message: WM_MOUSEWHEEL, delta: 20, |
|
390 target: gP1, x: 10, y: 10, window: window, |
|
391 modifiers: 0, |
|
392 additionalFlags: 0, |
|
393 expected: { |
|
394 axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / -2; }, |
|
395 }, |
|
396 }, |
|
397 { description: "WM_MOUSEWHEEL, 20, -0.5 lines (pending: -0.5 lines)", |
|
398 message: WM_MOUSEWHEEL, delta: 20, |
|
399 target: gP1, x: 10, y: 10, window: window, |
|
400 modifiers: 0, |
|
401 additionalFlags: 0, |
|
402 expected: { |
|
403 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight / 2; }, |
|
404 }, |
|
405 }, |
|
406 { description: "WM_MOUSEWHEEL, 20, -0.5 lines", |
|
407 message: WM_MOUSEWHEEL, delta: 20, |
|
408 target: gP1, x: 10, y: 10, window: window, |
|
409 modifiers: 0, |
|
410 additionalFlags: 0, |
|
411 expected: { |
|
412 axis: kVAxis, lines: 0, pixels: function () { return gLineHeight / -2; }, |
|
413 }, |
|
414 }, |
|
415 |
|
416 { description: "WM_MOUSEHWHEEL, 20, 0.5 chars", |
|
417 message: WM_MOUSEHWHEEL, delta: 20, |
|
418 target: gP1, x: 10, y: 10, window: window, |
|
419 modifiers: 0, |
|
420 additionalFlags: 0, |
|
421 expected: { |
|
422 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / 2; }, |
|
423 }, |
|
424 }, |
|
425 { description: "WM_MOUSEHWHEEL, 20, 0.5 chars (pending: 0.5 chars)", |
|
426 message: WM_MOUSEHWHEEL, delta: 20, |
|
427 target: gP1, x: 10, y: 10, window: window, |
|
428 modifiers: 0, |
|
429 additionalFlags: 0, |
|
430 expected: { |
|
431 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth / 2; }, |
|
432 }, |
|
433 }, |
|
434 { description: "WM_MOUSEHWHEEL, 20, 0.5 chars", |
|
435 message: WM_MOUSEHWHEEL, delta: 20, |
|
436 target: gP1, x: 10, y: 10, window: window, |
|
437 modifiers: 0, |
|
438 additionalFlags: 0, |
|
439 expected: { |
|
440 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / 2; }, |
|
441 }, |
|
442 }, |
|
443 |
|
444 { description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: 0.5 chars)", |
|
445 message: WM_MOUSEHWHEEL, delta: -20, |
|
446 target: gP1, x: 10, y: 10, window: window, |
|
447 modifiers: 0, |
|
448 additionalFlags: 0, |
|
449 expected: { |
|
450 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, |
|
451 }, |
|
452 }, |
|
453 { description: "WM_MOUSEHWHEEL, -20, -0.5 chars (pending: -0.5 chars)", |
|
454 message: WM_MOUSEHWHEEL, delta: -20, |
|
455 target: gP1, x: 10, y: 10, window: window, |
|
456 modifiers: 0, |
|
457 additionalFlags: 0, |
|
458 expected: { |
|
459 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth / 2; }, |
|
460 }, |
|
461 }, |
|
462 { description: "WM_MOUSEHWHEEL, -20, -0.5 chars", |
|
463 message: WM_MOUSEHWHEEL, delta: -20, |
|
464 target: gP1, x: 10, y: 10, window: window, |
|
465 modifiers: 0, |
|
466 additionalFlags: 0, |
|
467 expected: { |
|
468 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, |
|
469 }, |
|
470 }, |
|
471 |
|
472 // Even if the mouse cursor is an element whose font-size is different than |
|
473 // the scrollable element, the pixel scroll amount shouldn't be changed. |
|
474 // Widget shouldn't dispatch a pixel event if the delta can be devided by |
|
475 // lines to be scrolled. However, pixel events should be fired by ESM. |
|
476 { description: "WM_MOUSEWHEEL, -120, 3 lines, on the other div whose font-size is larger", |
|
477 message: WM_MOUSEWHEEL, delta: -120, |
|
478 target: gP2, x: 10, y: 10, window: window, |
|
479 modifiers: 0, |
|
480 additionalFlags: 0, |
|
481 expected: { |
|
482 axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, |
|
483 }, |
|
484 }, |
|
485 |
|
486 { description: "WM_MOUSEWHEEL, 120, -3 lines, on the other div whose font-size is larger", |
|
487 message: WM_MOUSEWHEEL, delta: 120, |
|
488 target: gP2, x: 10, y: 10, window: window, |
|
489 modifiers: 0, |
|
490 additionalFlags: 0, |
|
491 expected: { |
|
492 axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, |
|
493 }, |
|
494 }, |
|
495 |
|
496 { description: "WM_MOUSEHWHEEL, 120, 3 chars, on the other div whose font-size is larger", |
|
497 message: WM_MOUSEHWHEEL, delta: 120, |
|
498 target: gP2, x: 10, y: 10, window: window, |
|
499 modifiers: 0, |
|
500 additionalFlags: 0, |
|
501 expected: { |
|
502 axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, |
|
503 }, |
|
504 }, |
|
505 |
|
506 { description: "WM_MOUSEHWHEEL, -120, -3 chars, on the other div whose font-size is larger", |
|
507 message: WM_MOUSEHWHEEL, delta: -120, |
|
508 target: gP2, x: 10, y: 10, window: window, |
|
509 modifiers: 0, |
|
510 additionalFlags: 0, |
|
511 expected: { |
|
512 axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, |
|
513 }, |
|
514 }, |
|
515 |
|
516 // Modifier key tests |
|
517 { description: "WM_MOUSEWHEEL, -40, 1 line with left Shift", |
|
518 message: WM_MOUSEWHEEL, delta: -40, |
|
519 target: gP1, x: 10, y: 10, window: window, |
|
520 modifiers: SHIFT_L, |
|
521 additionalFlags: 0, |
|
522 expected: { |
|
523 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
524 }, |
|
525 }, |
|
526 { description: "WM_MOUSEWHEEL, -40, 1 line with right Shift", |
|
527 message: WM_MOUSEWHEEL, delta: -40, |
|
528 target: gP1, x: 10, y: 10, window: window, |
|
529 modifiers: SHIFT_R, |
|
530 additionalFlags: 0, |
|
531 expected: { |
|
532 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
533 }, |
|
534 }, |
|
535 { description: "WM_MOUSEWHEEL, -40, 1 line with left Ctrl", |
|
536 message: WM_MOUSEWHEEL, delta: -40, |
|
537 target: gP1, x: 10, y: 10, window: window, |
|
538 modifiers: CTRL_L, |
|
539 additionalFlags: 0, |
|
540 expected: { |
|
541 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
542 }, |
|
543 }, |
|
544 { description: "WM_MOUSEWHEEL, -40, 1 line with right Ctrl", |
|
545 message: WM_MOUSEWHEEL, delta: -40, |
|
546 target: gP1, x: 10, y: 10, window: window, |
|
547 modifiers: CTRL_R, |
|
548 additionalFlags: 0, |
|
549 expected: { |
|
550 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
551 }, |
|
552 }, |
|
553 { description: "WM_MOUSEWHEEL, -40, 1 line with left Alt", |
|
554 message: WM_MOUSEWHEEL, delta: -40, |
|
555 target: gP1, x: 10, y: 10, window: window, |
|
556 modifiers: ALT_L, |
|
557 additionalFlags: 0, |
|
558 expected: { |
|
559 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
560 }, |
|
561 }, |
|
562 { description: "WM_MOUSEWHEEL, -40, 1 line with right Alt", |
|
563 message: WM_MOUSEWHEEL, delta: -40, |
|
564 target: gP1, x: 10, y: 10, window: window, |
|
565 modifiers: ALT_R, |
|
566 additionalFlags: 0, |
|
567 expected: { |
|
568 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
569 }, |
|
570 }, |
|
571 |
|
572 { description: "WM_MOUSEHWHEEL, 40, 1 character with left Shift", |
|
573 message: WM_MOUSEHWHEEL, delta: 40, |
|
574 target: gP1, x: 10, y: 10, window: window, |
|
575 modifiers: SHIFT_L, |
|
576 additionalFlags: 0, |
|
577 expected: { |
|
578 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
579 }, |
|
580 }, |
|
581 { description: "WM_MOUSEHWHEEL, 40, 1 character with right Shift", |
|
582 message: WM_MOUSEHWHEEL, delta: 40, |
|
583 target: gP1, x: 10, y: 10, window: window, |
|
584 modifiers: SHIFT_R, |
|
585 additionalFlags: 0, |
|
586 expected: { |
|
587 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
588 }, |
|
589 }, |
|
590 { description: "WM_MOUSEHWHEEL, 40, 1 character with left Ctrl", |
|
591 message: WM_MOUSEHWHEEL, delta: 40, |
|
592 target: gP1, x: 10, y: 10, window: window, |
|
593 modifiers: CTRL_L, |
|
594 additionalFlags: 0, |
|
595 expected: { |
|
596 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
597 }, |
|
598 }, |
|
599 { description: "WM_MOUSEHWHEEL, 40, 1 character with right Ctrl", |
|
600 message: WM_MOUSEHWHEEL, delta: 40, |
|
601 target: gP1, x: 10, y: 10, window: window, |
|
602 modifiers: CTRL_R, |
|
603 additionalFlags: 0, |
|
604 expected: { |
|
605 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
606 }, |
|
607 }, |
|
608 { description: "WM_MOUSEHWHEEL, 40, 1 character with left Alt", |
|
609 message: WM_MOUSEHWHEEL, delta: 40, |
|
610 target: gP1, x: 10, y: 10, window: window, |
|
611 modifiers: ALT_L, |
|
612 additionalFlags: 0, |
|
613 expected: { |
|
614 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
615 }, |
|
616 }, |
|
617 { description: "WM_MOUSEHWHEEL, 40, 1 character with right Alt", |
|
618 message: WM_MOUSEHWHEEL, delta: 40, |
|
619 target: gP1, x: 10, y: 10, window: window, |
|
620 modifiers: ALT_R, |
|
621 additionalFlags: 0, |
|
622 expected: { |
|
623 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
624 }, |
|
625 |
|
626 finish: function () { |
|
627 runNextTest(gScrollMessageTests, 0); |
|
628 } |
|
629 }, |
|
630 ]; |
|
631 |
|
632 var gPageScrllTests = [ |
|
633 // Pixel scroll event should be fired always but line scroll event should be |
|
634 // fired only when accumulated delta value is over a line. |
|
635 { description: "WM_MOUSEWHEEL, -60, 0.5 pages", |
|
636 message: WM_MOUSEWHEEL, delta: -60, |
|
637 target: gP1, x: 10, y: 10, window: window, |
|
638 modifiers: 0, |
|
639 additionalFlags: 0, |
|
640 expected: { |
|
641 axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / 2; }, |
|
642 }, |
|
643 }, |
|
644 { description: "WM_MOUSEWHEEL, -60, 0.5 pages (pending: 0.5 pages)", |
|
645 message: WM_MOUSEWHEEL, delta: -60, |
|
646 target: gP1, x: 10, y: 10, window: window, |
|
647 modifiers: 0, |
|
648 additionalFlags: 0, |
|
649 expected: { |
|
650 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
651 pixels: function () { return ((gPageHeight / 2) + (gPageHeight % 2)); }, |
|
652 }, |
|
653 }, |
|
654 { description: "WM_MOUSEWHEEL, -60, 0.5 pages", |
|
655 message: WM_MOUSEWHEEL, delta: -60, |
|
656 target: gP1, x: 10, y: 10, window: window, |
|
657 modifiers: 0, |
|
658 additionalFlags: 0, |
|
659 expected: { |
|
660 axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / 2; }, |
|
661 }, |
|
662 }, |
|
663 |
|
664 { description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: 0.5 pages)", |
|
665 message: WM_MOUSEWHEEL, delta: 60, |
|
666 target: gP1, x: 10, y: 10, window: window, |
|
667 modifiers: 0, |
|
668 additionalFlags: 0, |
|
669 expected: { |
|
670 axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / -2; }, |
|
671 }, |
|
672 }, |
|
673 { description: "WM_MOUSEWHEEL, 60, -0.5 pages (pending: -0.5 pages)", |
|
674 message: WM_MOUSEWHEEL, delta: 60, |
|
675 target: gP1, x: 10, y: 10, window: window, |
|
676 modifiers: 0, |
|
677 additionalFlags: 0, |
|
678 expected: { |
|
679 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
680 pixels: function () { return -((gPageHeight / 2) + (gPageHeight % 2)); }, |
|
681 }, |
|
682 }, |
|
683 { description: "WM_MOUSEWHEEL, 60, -0.5 pages", |
|
684 message: WM_MOUSEWHEEL, delta: 60, |
|
685 target: gP1, x: 10, y: 10, window: window, |
|
686 modifiers: 0, |
|
687 additionalFlags: 0, |
|
688 expected: { |
|
689 axis: kVAxis, lines: 0, pixels: function () { return gPageHeight / -2; }, |
|
690 }, |
|
691 }, |
|
692 |
|
693 { description: "WM_MOUSEHWHEEL, 60, 0.5 pages", |
|
694 message: WM_MOUSEHWHEEL, delta: 60, |
|
695 target: gP1, x: 10, y: 10, window: window, |
|
696 modifiers: 0, |
|
697 additionalFlags: 0, |
|
698 expected: { |
|
699 axis: kHAxis, lines: 0, pixels: function () { return gPageWidth / 2; }, |
|
700 }, |
|
701 }, |
|
702 { description: "WM_MOUSEHWHEEL, 60, 0.5 pages (pending: 0.5 pages)", |
|
703 message: WM_MOUSEHWHEEL, delta: 60, |
|
704 target: gP1, x: 10, y: 10, window: window, |
|
705 modifiers: 0, |
|
706 additionalFlags: 0, |
|
707 expected: { |
|
708 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
709 pixels: function () { return ((gPageWidth / 2) + (gPageWidth % 2)); }, |
|
710 }, |
|
711 }, |
|
712 { description: "WM_MOUSEHWHEEL, 60, 0.5 pages", |
|
713 message: WM_MOUSEHWHEEL, delta: 60, |
|
714 target: gP1, x: 10, y: 10, window: window, |
|
715 modifiers: 0, |
|
716 additionalFlags: 0, |
|
717 expected: { |
|
718 axis: kHAxis, lines: 0, pixels: function () { return gPageWidth / 2; }, |
|
719 }, |
|
720 }, |
|
721 |
|
722 { description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: 0.5 pages)", |
|
723 message: WM_MOUSEHWHEEL, delta: -60, |
|
724 target: gP1, x: 10, y: 10, window: window, |
|
725 modifiers: 0, |
|
726 additionalFlags: 0, |
|
727 expected: { |
|
728 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, |
|
729 }, |
|
730 }, |
|
731 { description: "WM_MOUSEHWHEEL, -60, -0.5 pages (pending: -0.5 pages)", |
|
732 message: WM_MOUSEHWHEEL, delta: -60, |
|
733 target: gP1, x: 10, y: 10, window: window, |
|
734 modifiers: 0, |
|
735 additionalFlags: 0, |
|
736 expected: { |
|
737 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
738 pixels: function () { return -((gCharWidth / 2) + (gCharWidth % 2)); }, |
|
739 }, |
|
740 }, |
|
741 { description: "WM_MOUSEHWHEEL, -60, -0.5 pages", |
|
742 message: WM_MOUSEHWHEEL, delta: -60, |
|
743 target: gP1, x: 10, y: 10, window: window, |
|
744 modifiers: 0, |
|
745 additionalFlags: 0, |
|
746 expected: { |
|
747 axis: kHAxis, lines: 0, pixels: function () { return gCharWidth / -2; }, |
|
748 }, |
|
749 }, |
|
750 ]; |
|
751 |
|
752 var gScrollMessageTests = [ |
|
753 // Widget should dispatch neither line scroll event nor pixel scroll event if |
|
754 // the WM_*SCROLL's lParam is NULL and mouse wheel emulation is disabled. |
|
755 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation disabled", |
|
756 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
757 target: gP1, x: 10, y: 10, window: window, |
|
758 modifiers: 0, |
|
759 additionalFlags: 0, |
|
760 expected: { |
|
761 axis: kVAxis, lines: 0, pixels: 0, |
|
762 }, |
|
763 init: function () { |
|
764 SpecialPowers.setIntPref(kVAmountPref, 3); |
|
765 SpecialPowers.setIntPref(kHAmountPref, 3); |
|
766 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); |
|
767 }, |
|
768 }, |
|
769 |
|
770 { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation disabled", |
|
771 message: WM_VSCROLL, delta: SB_LINEUP, |
|
772 target: gP1, x: 10, y: 10, window: window, |
|
773 modifiers: 0, |
|
774 additionalFlags: 0, |
|
775 expected: { |
|
776 axis: kVAxis, lines: 0, pixels: 0, |
|
777 }, |
|
778 }, |
|
779 |
|
780 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation disabled", |
|
781 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
782 target: gP1, x: 10, y: 10, window: window, |
|
783 modifiers: 0, |
|
784 additionalFlags: 0, |
|
785 expected: { |
|
786 axis: kHAxis, lines: 0, pixels: 0, |
|
787 }, |
|
788 }, |
|
789 |
|
790 { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation disabled", |
|
791 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
792 target: gP1, x: 10, y: 10, window: window, |
|
793 modifiers: 0, |
|
794 additionalFlags: 0, |
|
795 expected: { |
|
796 axis: kHAxis, lines: 0, pixels: 0, |
|
797 }, |
|
798 }, |
|
799 |
|
800 // Widget should emulate mouse wheel behavior for WM_*SCROLL even if the |
|
801 // kEmulateWheelByWMSCROLLPref is disabled but the message's lParam is not |
|
802 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages, |
|
803 // but ESM dispatches it instead. |
|
804 { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled", |
|
805 message: WM_VSCROLL, delta: SB_LINEUP, |
|
806 target: gP1, x: 10, y: 10, window: window, |
|
807 modifiers: 0, |
|
808 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
809 expected: { |
|
810 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
811 }, |
|
812 init: function () { |
|
813 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); |
|
814 }, |
|
815 }, |
|
816 |
|
817 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled", |
|
818 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
819 target: gP1, x: 10, y: 10, window: window, |
|
820 modifiers: 0, |
|
821 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
822 expected: { |
|
823 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
824 }, |
|
825 }, |
|
826 |
|
827 { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled", |
|
828 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
829 target: gP1, x: 10, y: 10, window: window, |
|
830 modifiers: 0, |
|
831 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
832 expected: { |
|
833 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
834 }, |
|
835 }, |
|
836 |
|
837 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled", |
|
838 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
839 target: gP1, x: 10, y: 10, window: window, |
|
840 modifiers: 0, |
|
841 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
842 expected: { |
|
843 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
844 }, |
|
845 }, |
|
846 |
|
847 { description: "WM_VSCROLL, SB_PAGEUP, lParam is not NULL, emulation disabled", |
|
848 message: WM_VSCROLL, delta: SB_PAGEUP, |
|
849 target: gP1, x: 10, y: 10, window: window, |
|
850 modifiers: 0, |
|
851 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
852 expected: { |
|
853 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
854 pixels: function () { return -gPageHeight; }, |
|
855 }, |
|
856 }, |
|
857 |
|
858 { description: "WM_VSCROLL, SB_PAGEDOWN, lParam is not NULL, emulation disabled", |
|
859 message: WM_VSCROLL, delta: SB_PAGEDOWN, |
|
860 target: gP1, x: 10, y: 10, window: window, |
|
861 modifiers: 0, |
|
862 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
863 expected: { |
|
864 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
865 pixels: function () { return gPageHeight; }, |
|
866 }, |
|
867 }, |
|
868 |
|
869 { description: "WM_HSCROLL, SB_PAGELEFT, lParam is not NULL, emulation disabled", |
|
870 message: WM_HSCROLL, delta: SB_PAGELEFT, |
|
871 target: gP1, x: 10, y: 10, window: window, |
|
872 modifiers: 0, |
|
873 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
874 expected: { |
|
875 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
876 pixels: function () { return -gPageWidth; }, |
|
877 }, |
|
878 }, |
|
879 |
|
880 { description: "WM_HSCROLL, SB_PAGERIGHT, lParam is not NULL, emulation disabled", |
|
881 message: WM_HSCROLL, delta: SB_PAGERIGHT, |
|
882 target: gP1, x: 10, y: 10, window: window, |
|
883 modifiers: 0, |
|
884 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
885 expected: { |
|
886 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
887 pixels: function () { return gPageWidth; }, |
|
888 }, |
|
889 }, |
|
890 |
|
891 // Widget should emulate mouse wheel behavior for WM_*SCROLL when the |
|
892 // kEmulateWheelByWMSCROLLPref is enabled even if the message's lParam is |
|
893 // NULL. Then, widget doesn't dispatch a pixel event for WM_*SCROLL messages, |
|
894 // but ESM dispatches it instead. |
|
895 { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled", |
|
896 message: WM_VSCROLL, delta: SB_LINEUP, |
|
897 target: gP1, x: 10, y: 10, window: window, |
|
898 modifiers: 0, |
|
899 additionalFlags: 0, |
|
900 expected: { |
|
901 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
902 }, |
|
903 init: function () { |
|
904 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); |
|
905 }, |
|
906 }, |
|
907 |
|
908 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled", |
|
909 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
910 target: gP1, x: 10, y: 10, window: window, |
|
911 modifiers: 0, |
|
912 additionalFlags: 0, |
|
913 expected: { |
|
914 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
915 }, |
|
916 }, |
|
917 |
|
918 { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled", |
|
919 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
920 target: gP1, x: 10, y: 10, window: window, |
|
921 modifiers: 0, |
|
922 additionalFlags: 0, |
|
923 expected: { |
|
924 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
925 }, |
|
926 }, |
|
927 |
|
928 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled", |
|
929 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
930 target: gP1, x: 10, y: 10, window: window, |
|
931 modifiers: 0, |
|
932 additionalFlags: 0, |
|
933 expected: { |
|
934 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
935 }, |
|
936 }, |
|
937 |
|
938 { description: "WM_VSCROLL, SB_PAGEUP, lParam is NULL, emulation enabled", |
|
939 message: WM_VSCROLL, delta: SB_PAGEUP, |
|
940 target: gP1, x: 10, y: 10, window: window, |
|
941 modifiers: 0, |
|
942 additionalFlags: 0, |
|
943 expected: { |
|
944 axis: kVAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
945 pixels: function () { return -gPageHeight; }, |
|
946 }, |
|
947 }, |
|
948 |
|
949 { description: "WM_VSCROLL, SB_PAGEDOWN, lParam is NULL, emulation enabled", |
|
950 message: WM_VSCROLL, delta: SB_PAGEDOWN, |
|
951 target: gP1, x: 10, y: 10, window: window, |
|
952 modifiers: 0, |
|
953 additionalFlags: 0, |
|
954 expected: { |
|
955 axis: kVAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
956 pixels: function () { return gPageHeight; }, |
|
957 }, |
|
958 }, |
|
959 |
|
960 { description: "WM_HSCROLL, SB_PAGELEFT, lParam is NULL, emulation enabled", |
|
961 message: WM_HSCROLL, delta: SB_PAGELEFT, |
|
962 target: gP1, x: 10, y: 10, window: window, |
|
963 modifiers: 0, |
|
964 additionalFlags: 0, |
|
965 expected: { |
|
966 axis: kHAxis, lines: -DOM_PAGE_SCROLL_DELTA, |
|
967 pixels: function () { return -gPageWidth; }, |
|
968 }, |
|
969 }, |
|
970 |
|
971 { description: "WM_HSCROLL, SB_PAGERIGHT, lParam is NULL, emulation enabled", |
|
972 message: WM_HSCROLL, delta: SB_PAGERIGHT, |
|
973 target: gP1, x: 10, y: 10, window: window, |
|
974 modifiers: 0, |
|
975 additionalFlags: 0, |
|
976 expected: { |
|
977 axis: kHAxis, lines: DOM_PAGE_SCROLL_DELTA, |
|
978 pixels: function () { return gPageWidth; }, |
|
979 }, |
|
980 }, |
|
981 |
|
982 // Modifier key tests for WM_*SCROLL |
|
983 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Shift", |
|
984 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
985 target: gP1, x: 10, y: 10, window: window, |
|
986 modifiers: SHIFT_L, |
|
987 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
988 expected: { |
|
989 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
990 }, |
|
991 init: function () { |
|
992 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); |
|
993 }, |
|
994 }, |
|
995 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Shift", |
|
996 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
997 target: gP1, x: 10, y: 10, window: window, |
|
998 modifiers: SHIFT_R, |
|
999 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1000 expected: { |
|
1001 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1002 }, |
|
1003 }, |
|
1004 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Ctrl", |
|
1005 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1006 target: gP1, x: 10, y: 10, window: window, |
|
1007 modifiers: CTRL_L, |
|
1008 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1009 expected: { |
|
1010 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1011 }, |
|
1012 }, |
|
1013 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Ctrl", |
|
1014 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1015 target: gP1, x: 10, y: 10, window: window, |
|
1016 modifiers: CTRL_L, |
|
1017 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1018 expected: { |
|
1019 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1020 }, |
|
1021 }, |
|
1022 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with left Alt", |
|
1023 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1024 target: gP1, x: 10, y: 10, window: window, |
|
1025 modifiers: ALT_L, |
|
1026 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1027 expected: { |
|
1028 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1029 }, |
|
1030 }, |
|
1031 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, with right Alt", |
|
1032 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1033 target: gP1, x: 10, y: 10, window: window, |
|
1034 modifiers: ALT_R, |
|
1035 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1036 expected: { |
|
1037 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1038 }, |
|
1039 }, |
|
1040 |
|
1041 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Shift", |
|
1042 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1043 target: gP1, x: 10, y: 10, window: window, |
|
1044 modifiers: SHIFT_L, |
|
1045 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1046 expected: { |
|
1047 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1048 }, |
|
1049 }, |
|
1050 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Shift", |
|
1051 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1052 target: gP1, x: 10, y: 10, window: window, |
|
1053 modifiers: SHIFT_R, |
|
1054 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1055 expected: { |
|
1056 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1057 }, |
|
1058 }, |
|
1059 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Ctrl", |
|
1060 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1061 target: gP1, x: 10, y: 10, window: window, |
|
1062 modifiers: CTRL_L, |
|
1063 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1064 expected: { |
|
1065 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1066 }, |
|
1067 }, |
|
1068 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Ctrl", |
|
1069 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1070 target: gP1, x: 10, y: 10, window: window, |
|
1071 modifiers: CTRL_L, |
|
1072 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1073 expected: { |
|
1074 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1075 }, |
|
1076 }, |
|
1077 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with left Alt", |
|
1078 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1079 target: gP1, x: 10, y: 10, window: window, |
|
1080 modifiers: ALT_L, |
|
1081 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1082 expected: { |
|
1083 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1084 }, |
|
1085 }, |
|
1086 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, with right Alt", |
|
1087 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1088 target: gP1, x: 10, y: 10, window: window, |
|
1089 modifiers: ALT_R, |
|
1090 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1091 expected: { |
|
1092 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1093 }, |
|
1094 |
|
1095 finish: function () { |
|
1096 runDeactiveWindowTests(); |
|
1097 } |
|
1098 }, |
|
1099 ]; |
|
1100 |
|
1101 var gDeactiveWindowTests = [ |
|
1102 // Typically, mouse drivers send wheel messages to focused window. |
|
1103 // However, we prefer to scroll a scrollable element under the mouse cursor. |
|
1104 { description: "WM_MOUSEWHEEL, -120, 3 lines, window is deactive", |
|
1105 message: WM_MOUSEWHEEL, delta: -120, |
|
1106 target: gP1, x: 10, y: 10, window: window, |
|
1107 modifiers: 0, |
|
1108 additionalFlags: 0, |
|
1109 expected: { |
|
1110 axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, |
|
1111 }, |
|
1112 init: function () { |
|
1113 SpecialPowers.setIntPref(kVAmountPref, 3); |
|
1114 SpecialPowers.setIntPref(kHAmountPref, 3); |
|
1115 }, |
|
1116 onLineScrollEvent: function (aEvent) { |
|
1117 var fm = Components.classes["@mozilla.org/focus-manager;1"]. |
|
1118 getService(Components.interfaces.nsIFocusManager); |
|
1119 is(fm.activeWindow, gOtherWindow, "The other window isn't activated"); |
|
1120 }, |
|
1121 }, |
|
1122 |
|
1123 { description: "WM_MOUSEWHEEL, 120, -3 lines, window is deactive", |
|
1124 message: WM_MOUSEWHEEL, delta: 120, |
|
1125 target: gP1, x: 10, y: 10, window: window, |
|
1126 modifiers: 0, |
|
1127 additionalFlags: 0, |
|
1128 expected: { |
|
1129 axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, |
|
1130 }, |
|
1131 }, |
|
1132 |
|
1133 { description: "WM_MOUSEHWHEEL, 120, 3 chars, window is deactive", |
|
1134 message: WM_MOUSEHWHEEL, delta: 120, |
|
1135 target: gP1, x: 10, y: 10, window: window, |
|
1136 modifiers: 0, |
|
1137 additionalFlags: 0, |
|
1138 expected: { |
|
1139 axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, |
|
1140 }, |
|
1141 }, |
|
1142 |
|
1143 { description: "WM_MOUSEHWHEEL, -120, -3 chars, window is deactive", |
|
1144 message: WM_MOUSEHWHEEL, delta: -120, |
|
1145 target: gP1, x: 10, y: 10, window: window, |
|
1146 modifiers: 0, |
|
1147 additionalFlags: 0, |
|
1148 expected: { |
|
1149 axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, |
|
1150 }, |
|
1151 }, |
|
1152 |
|
1153 // Of course, even if some drivers prefer the cursor position, we don't need |
|
1154 // to change anything. |
|
1155 { description: "WM_MOUSEWHEEL, -120, 3 lines, window is deactive (receive the message directly)", |
|
1156 message: WM_MOUSEWHEEL, delta: -120, |
|
1157 target: gP1, x: 10, y: 10, window: window, |
|
1158 modifiers: 0, |
|
1159 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1160 expected: { |
|
1161 axis: kVAxis, lines: 3, pixels: function () { return gLineHeight * 3; }, |
|
1162 }, |
|
1163 }, |
|
1164 |
|
1165 { description: "WM_MOUSEWHEEL, 120, -3 lines, window is deactive (receive the message directly)", |
|
1166 message: WM_MOUSEWHEEL, delta: 120, |
|
1167 target: gP1, x: 10, y: 10, window: window, |
|
1168 modifiers: 0, |
|
1169 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1170 expected: { |
|
1171 axis: kVAxis, lines: -3, pixels: function () { return gLineHeight * -3; }, |
|
1172 }, |
|
1173 }, |
|
1174 |
|
1175 { description: "WM_MOUSEHWHEEL, 120, 3 chars, window is deactive (receive the message directly)", |
|
1176 message: WM_MOUSEHWHEEL, delta: 120, |
|
1177 target: gP1, x: 10, y: 10, window: window, |
|
1178 modifiers: 0, |
|
1179 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1180 expected: { |
|
1181 axis: kHAxis, lines: 3, pixels: function () { return gCharWidth * 3; }, |
|
1182 }, |
|
1183 }, |
|
1184 |
|
1185 { description: "WM_MOUSEHWHEEL, -120, -3 chars, window is deactive (receive the message directly)", |
|
1186 message: WM_MOUSEHWHEEL, delta: -120, |
|
1187 target: gP1, x: 10, y: 10, window: window, |
|
1188 modifiers: 0, |
|
1189 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1190 expected: { |
|
1191 axis: kHAxis, lines: -3, pixels: function () { return gCharWidth * -3; }, |
|
1192 }, |
|
1193 }, |
|
1194 |
|
1195 // Same for WM_*SCROLL if lParam is not NULL |
|
1196 { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive", |
|
1197 message: WM_VSCROLL, delta: SB_LINEUP, |
|
1198 target: gP1, x: 10, y: 10, window: window, |
|
1199 modifiers: 0, |
|
1200 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1201 expected: { |
|
1202 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
1203 }, |
|
1204 init: function () { |
|
1205 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); |
|
1206 }, |
|
1207 }, |
|
1208 |
|
1209 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive", |
|
1210 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1211 target: gP1, x: 10, y: 10, window: window, |
|
1212 modifiers: 0, |
|
1213 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1214 expected: { |
|
1215 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1216 }, |
|
1217 }, |
|
1218 |
|
1219 { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive", |
|
1220 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
1221 target: gP1, x: 10, y: 10, window: window, |
|
1222 modifiers: 0, |
|
1223 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1224 expected: { |
|
1225 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
1226 }, |
|
1227 }, |
|
1228 |
|
1229 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive", |
|
1230 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1231 target: gP1, x: 10, y: 10, window: window, |
|
1232 modifiers: 0, |
|
1233 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL, |
|
1234 expected: { |
|
1235 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1236 }, |
|
1237 }, |
|
1238 |
|
1239 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled |
|
1240 { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive", |
|
1241 message: WM_VSCROLL, delta: SB_LINEUP, |
|
1242 target: gP1, x: 10, y: 10, window: window, |
|
1243 modifiers: 0, |
|
1244 additionalFlags: 0, |
|
1245 expected: { |
|
1246 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
1247 }, |
|
1248 init: function () { |
|
1249 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); |
|
1250 }, |
|
1251 }, |
|
1252 |
|
1253 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive", |
|
1254 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1255 target: gP1, x: 10, y: 10, window: window, |
|
1256 modifiers: 0, |
|
1257 additionalFlags: 0, |
|
1258 expected: { |
|
1259 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1260 }, |
|
1261 }, |
|
1262 |
|
1263 { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive", |
|
1264 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
1265 target: gP1, x: 10, y: 10, window: window, |
|
1266 modifiers: 0, |
|
1267 additionalFlags: 0, |
|
1268 expected: { |
|
1269 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
1270 }, |
|
1271 }, |
|
1272 |
|
1273 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive", |
|
1274 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1275 target: gP1, x: 10, y: 10, window: window, |
|
1276 modifiers: 0, |
|
1277 additionalFlags: 0, |
|
1278 expected: { |
|
1279 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1280 }, |
|
1281 }, |
|
1282 |
|
1283 // Same for WM_*SCROLL if lParam is not NULL and message sent to the deactive window directly |
|
1284 { description: "WM_VSCROLL, SB_LINEUP, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", |
|
1285 message: WM_VSCROLL, delta: SB_LINEUP, |
|
1286 target: gP1, x: 10, y: 10, window: window, |
|
1287 modifiers: 0, |
|
1288 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | |
|
1289 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1290 expected: { |
|
1291 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
1292 }, |
|
1293 init: function () { |
|
1294 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, false); |
|
1295 }, |
|
1296 }, |
|
1297 |
|
1298 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", |
|
1299 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1300 target: gP1, x: 10, y: 10, window: window, |
|
1301 modifiers: 0, |
|
1302 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | |
|
1303 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1304 expected: { |
|
1305 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1306 }, |
|
1307 }, |
|
1308 |
|
1309 { description: "WM_HSCROLL, SB_LINELEFT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", |
|
1310 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
1311 target: gP1, x: 10, y: 10, window: window, |
|
1312 modifiers: 0, |
|
1313 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | |
|
1314 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1315 expected: { |
|
1316 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
1317 }, |
|
1318 }, |
|
1319 |
|
1320 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is not NULL, emulation disabled, window is deactive (receive the message directly)", |
|
1321 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1322 target: gP1, x: 10, y: 10, window: window, |
|
1323 modifiers: 0, |
|
1324 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_WIN_SCROLL_LPARAM_NOT_NULL | |
|
1325 nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1326 expected: { |
|
1327 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1328 }, |
|
1329 }, |
|
1330 |
|
1331 // Same for WM_*SCROLL if lParam is NULL but emulation is enabled, and message sent to the deactive window directly |
|
1332 { description: "WM_VSCROLL, SB_LINEUP, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", |
|
1333 message: WM_VSCROLL, delta: SB_LINEUP, |
|
1334 target: gP1, x: 10, y: 10, window: window, |
|
1335 modifiers: 0, |
|
1336 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1337 expected: { |
|
1338 axis: kVAxis, lines: -1, pixels: function () { return -gLineHeight; }, |
|
1339 }, |
|
1340 init: function () { |
|
1341 SpecialPowers.setBoolPref(kEmulateWheelByWMSCROLLPref, true); |
|
1342 }, |
|
1343 }, |
|
1344 |
|
1345 { description: "WM_VSCROLL, SB_LINEDOWN, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", |
|
1346 message: WM_VSCROLL, delta: SB_LINEDOWN, |
|
1347 target: gP1, x: 10, y: 10, window: window, |
|
1348 modifiers: 0, |
|
1349 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1350 expected: { |
|
1351 axis: kVAxis, lines: 1, pixels: function () { return gLineHeight; }, |
|
1352 }, |
|
1353 }, |
|
1354 |
|
1355 { description: "WM_HSCROLL, SB_LINELEFT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", |
|
1356 message: WM_HSCROLL, delta: SB_LINELEFT, |
|
1357 target: gP1, x: 10, y: 10, window: window, |
|
1358 modifiers: 0, |
|
1359 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1360 expected: { |
|
1361 axis: kHAxis, lines: -1, pixels: function () { return -gCharWidth; }, |
|
1362 }, |
|
1363 }, |
|
1364 |
|
1365 { description: "WM_HSCROLL, SB_LINERIGHT, lParam is NULL, emulation enabled, window is deactive (receive the message directly)", |
|
1366 message: WM_HSCROLL, delta: SB_LINERIGHT, |
|
1367 target: gP1, x: 10, y: 10, window: window, |
|
1368 modifiers: 0, |
|
1369 additionalFlags: nsIDOMWindowUtils.MOUSESCROLL_PREFER_WIDGET_AT_POINT, |
|
1370 expected: { |
|
1371 axis: kHAxis, lines: 1, pixels: function () { return gCharWidth; }, |
|
1372 }, |
|
1373 |
|
1374 finish: function () { |
|
1375 gOtherWindow.close(); |
|
1376 gOtherWindow = null; |
|
1377 window.close(); |
|
1378 } |
|
1379 }, |
|
1380 ]; |
|
1381 |
|
1382 function runDeactiveWindowTests() |
|
1383 { |
|
1384 gOtherWindow = window.open("data:text/html,", "_blank", |
|
1385 "chrome,width=100,height=100,top=700,left=700"); |
|
1386 |
|
1387 window.opener.wrappedJSObject.SimpleTest.waitForFocus(function () { |
|
1388 runNextTest(gDeactiveWindowTests, 0); |
|
1389 }, gOtherWindow); |
|
1390 } |
|
1391 |
|
1392 function runNextTest(aTests, aIndex) |
|
1393 { |
|
1394 if (aIndex > 0 && aTests[aIndex - 1] && aTests[aIndex - 1].finish) { |
|
1395 aTests[aIndex - 1].finish(); |
|
1396 } |
|
1397 |
|
1398 if (aTests.length == aIndex) { |
|
1399 return; |
|
1400 } |
|
1401 |
|
1402 var test = aTests[aIndex++]; |
|
1403 if (test.init) { |
|
1404 test.init(); |
|
1405 } |
|
1406 test.handled = { lines: false, pixels: false }; |
|
1407 |
|
1408 switch (test.message) { |
|
1409 case WM_MOUSEWHEEL: |
|
1410 case WM_MOUSEHWHEEL: |
|
1411 case WM_VSCROLL: |
|
1412 case WM_HSCROLL: |
|
1413 var expectedLines = test.expected.lines; |
|
1414 var expectedPixels = |
|
1415 cut((typeof test.expected.pixels == "function") ? |
|
1416 test.expected.pixels() : test.expected.pixels); |
|
1417 var handler = function (aEvent) { |
|
1418 var doCommonTests = true; |
|
1419 |
|
1420 if (!aEvent) { |
|
1421 ok(!test.handled.lines, |
|
1422 test.description + ", line scroll event has been handled"); |
|
1423 ok(!test.handled.pixels, |
|
1424 test.description + ", pixel scroll event has been handled"); |
|
1425 doCommonTests = false; |
|
1426 } else if (aEvent.type == kMouseLineScrollEvent) { |
|
1427 ok(!test.handled.lines, |
|
1428 test.description + ":(" + aEvent.type + "), same event has already been handled"); |
|
1429 test.handled.lines = true; |
|
1430 isnot(expectedLines, 0, |
|
1431 test.description + ":(" + aEvent.type + "), event shouldn't be fired"); |
|
1432 if (test.onLineScrollEvent && test.onLineScrollEvent(aEvent)) { |
|
1433 doCommonTests = false; |
|
1434 } |
|
1435 } else if (aEvent.type == kMousePixelScrollEvent) { |
|
1436 ok(!test.handled.pixels, |
|
1437 test.description + ":(" + aEvent.type + "), same event has already been handled"); |
|
1438 test.handled.pixels = true; |
|
1439 isnot(expectedPixels, 0, |
|
1440 test.description + ":(" + aEvent.type + "), event shouldn't be fired"); |
|
1441 if (test.onPixelScrollEvent && test.onPixelScrollEvent(aEvent)) { |
|
1442 doCommonTests = false; |
|
1443 } |
|
1444 } |
|
1445 |
|
1446 if (doCommonTests) { |
|
1447 var expectedDelta = |
|
1448 (aEvent.type == kMouseLineScrollEvent) ? |
|
1449 expectedLines : expectedPixels; |
|
1450 is(aEvent.target.id, test.target.id, |
|
1451 test.description + ":(" + aEvent.type + "), ID mismatch"); |
|
1452 is(aEvent.axis, test.expected.axis, |
|
1453 test.description + ":(" + aEvent.type + "), axis mismatch"); |
|
1454 ok(aEvent.detail != 0, |
|
1455 test.description + ":(" + aEvent.type + "), delta must not be 0"); |
|
1456 is(aEvent.detail, expectedDelta, |
|
1457 test.description + ":(" + aEvent.type + "), delta mismatch"); |
|
1458 is(aEvent.shiftKey, (test.modifiers & (SHIFT_L | SHIFT_R)) != 0, |
|
1459 test.description + ":(" + aEvent.type + "), shiftKey mismatch"); |
|
1460 is(aEvent.ctrlKey, (test.modifiers & (CTRL_L | CTRL_R)) != 0, |
|
1461 test.description + ":(" + aEvent.type + "), ctrlKey mismatch"); |
|
1462 is(aEvent.altKey, (test.modifiers & (ALT_L | ALT_R)) != 0, |
|
1463 test.description + ":(" + aEvent.type + "), altKey mismatch"); |
|
1464 } |
|
1465 |
|
1466 if (!aEvent || (test.handled.lines || expectedLines == 0) && |
|
1467 (test.handled.pixels || expectedPixels == 0)) { |
|
1468 // Don't scroll actually. |
|
1469 if (aEvent) { |
|
1470 aEvent.preventDefault(); |
|
1471 } |
|
1472 test.target.removeEventListener(kMouseLineScrollEvent, handler, true); |
|
1473 test.target.removeEventListener(kMousePixelScrollEvent, handler, true); |
|
1474 setTimeout(runNextTest, 0, aTests, aIndex); |
|
1475 } |
|
1476 }; |
|
1477 |
|
1478 test.target.addEventListener(kMouseLineScrollEvent, handler, true); |
|
1479 test.target.addEventListener(kMousePixelScrollEvent, handler, true); |
|
1480 |
|
1481 if (expectedLines == 0 && expectedPixels == 0) { |
|
1482 // The timeout might not be enough if system is slow by other process, |
|
1483 // so, the test might be passed unexpectedly. However, it must be able |
|
1484 // to be detected by random orange. |
|
1485 setTimeout(handler, 500); |
|
1486 } |
|
1487 |
|
1488 var utils = getWindowUtils(test.window); |
|
1489 var ptInScreen = getPointInScreen(test.target, test.window); |
|
1490 var isVertical = |
|
1491 ((test.message == WM_MOUSEWHEEL) || (test.message == WM_VSCROLL)); |
|
1492 var deltaX = !isVertical ? test.delta : 0; |
|
1493 var deltaY = isVertical ? test.delta : 0; |
|
1494 utils.sendNativeMouseScrollEvent(ptInScreen.x + test.x, |
|
1495 ptInScreen.y + test.y, |
|
1496 test.message, deltaX, deltaY, 0, |
|
1497 test.modifiers, |
|
1498 test.additionalFlags, |
|
1499 test.target); |
|
1500 break; |
|
1501 default: |
|
1502 ok(false, test.description + ": invalid message"); |
|
1503 // Let's timeout. |
|
1504 } |
|
1505 } |
|
1506 |
|
1507 function prepareTests() |
|
1508 { |
|
1509 // Disable special action with modifier key |
|
1510 SpecialPowers.setIntPref(kAltKeyActionPref, 1); |
|
1511 SpecialPowers.setIntPref(kCtrlKeyActionPref, 1); |
|
1512 SpecialPowers.setIntPref(kShiftKeyActionPref, 1); |
|
1513 SpecialPowers.setIntPref(kWinKeyActionPref, 1); |
|
1514 |
|
1515 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierXPref, 100); |
|
1516 SpecialPowers.setIntPref(kAltKeyDeltaMultiplierYPref, 100); |
|
1517 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierXPref, 100); |
|
1518 SpecialPowers.setIntPref(kCtrlKeyDeltaMultiplierYPref, 100); |
|
1519 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierXPref, 100); |
|
1520 SpecialPowers.setIntPref(kShiftKeyDeltaMultiplierYPref, 100); |
|
1521 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierXPref, 100); |
|
1522 SpecialPowers.setIntPref(kWinKeyDeltaMultiplierYPref, 100); |
|
1523 |
|
1524 SpecialPowers.setBoolPref(kSystemScrollSpeedOverridePref, false); |
|
1525 SpecialPowers.setIntPref(kTimeoutPref, -1); |
|
1526 |
|
1527 runNextTest(gPreparingSteps, 0); |
|
1528 } |
|
1529 |
|
1530 </script> |
|
1531 </body> |
|
1532 |
|
1533 </html> |