dom/events/test/test_moz_mouse_pixel_scroll_event.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial