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