dom/events/test/window_wheel_default_action.html

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>Test for default action of WheelEvent</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 </head>
michael@0 9 <body>
michael@0 10 <p id="display"></p>
michael@0 11 <div id="scrollable" style="overflow: auto; width: 200px; height: 200px;">
michael@0 12 <div id="clipper" style="margin: 0; padding: 0; overflow: hidden; width: 3000px; height: 3000px;">
michael@0 13 <div id="scrolled" style="width: 5000px; height: 5000px;">
michael@0 14 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 15 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 16 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 17 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 18 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 19 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 20 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 21 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 22 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 23 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 24 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 25 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 26 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 27 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 28 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 29 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 30 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 31 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 32 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 33 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 34 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 35 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 36 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 37 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 38 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 39 Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
michael@0 40 </div>
michael@0 41 </div>
michael@0 42 </div>
michael@0 43 <div id="spacerForBody"></div>
michael@0 44 <div id="content" style="display: none">
michael@0 45
michael@0 46 </div>
michael@0 47 <pre id="test">
michael@0 48 <script type="application/javascript">
michael@0 49
michael@0 50 SimpleTest.waitForFocus(runTests, window);
michael@0 51
michael@0 52 var winUtils = SpecialPowers.getDOMWindowUtils(window);
michael@0 53 // grab refresh driver
michael@0 54 winUtils.advanceTimeAndRefresh(100);
michael@0 55
michael@0 56 var gScrollableElement = document.getElementById("scrollable");
michael@0 57 var gScrolledElement = document.getElementById("scrolled");
michael@0 58 var gSpacerForBodyElement = document.getElementById("spacerForBody");
michael@0 59
michael@0 60 function is()
michael@0 61 {
michael@0 62 window.opener.is.apply(window.opener, arguments);
michael@0 63 }
michael@0 64
michael@0 65 function ok()
michael@0 66 {
michael@0 67 window.opener.ok.apply(window.opener, arguments);
michael@0 68 }
michael@0 69
michael@0 70 function hitEventLoop(aFunc, aTimes)
michael@0 71 {
michael@0 72 winUtils.advanceTimeAndRefresh(100);
michael@0 73
michael@0 74 if (--aTimes) {
michael@0 75 setTimeout(hitEventLoop, 0, aFunc, aTimes);
michael@0 76 } else {
michael@0 77 setTimeout(aFunc, 20);
michael@0 78 }
michael@0 79 }
michael@0 80
michael@0 81 function onZoomReset(aCallback) {
michael@0 82 var topic = "browser-fullZoom:zoomReset";
michael@0 83 SpecialPowers.addObserver(function observe() {
michael@0 84 SpecialPowers.removeObserver(observe, topic);
michael@0 85 SimpleTest.executeSoon(aCallback);
michael@0 86 }, topic, false);
michael@0 87 }
michael@0 88
michael@0 89 function setDeltaMultiplierSettings(aSettings)
michael@0 90 {
michael@0 91 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 92 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 93 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 94 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 95 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 96 SpecialPowers.setIntPref("mousewheel.with_alt.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 97 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 98 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 99 SpecialPowers.setIntPref("mousewheel.with_control.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 100 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 101 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 102 SpecialPowers.setIntPref("mousewheel.with_meta.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 103 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 104 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 105 SpecialPowers.setIntPref("mousewheel.with_shift.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 106 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_x", aSettings.deltaMultiplierX * 100);
michael@0 107 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_y", aSettings.deltaMultiplierY * 100);
michael@0 108 SpecialPowers.setIntPref("mousewheel.with_win.delta_multiplier_z", aSettings.deltaMultiplierZ * 100);
michael@0 109 }
michael@0 110
michael@0 111 function doTestScroll(aSettings, aCallback)
michael@0 112 {
michael@0 113 const kNoScroll = 0x00;
michael@0 114 const kScrollUp = 0x01;
michael@0 115 const kScrollDown = 0x02;
michael@0 116 const kScrollLeft = 0x04;
michael@0 117 const kScrollRight = 0x08;
michael@0 118
michael@0 119 const kTests = [
michael@0 120 { description: "Scroll to bottom by pixel scroll even if lineOrPageDelta is 0",
michael@0 121 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 122 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 123 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 124 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 125 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 126 expected: kScrollDown },
michael@0 127 { description: "Scroll to bottom by pixel scroll when lineOrPageDelta is 1",
michael@0 128 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 129 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 130 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
michael@0 131 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 132 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 133 expected: kScrollDown },
michael@0 134 { description: "Scroll to top by pixel scroll even if lineOrPageDelta is 0",
michael@0 135 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 136 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 137 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 138 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 139 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 140 expected: kScrollUp },
michael@0 141 { description: "Scroll to top by pixel scroll when lineOrPageDelta is -1",
michael@0 142 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 143 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 144 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
michael@0 145 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 146 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 147 expected: kScrollUp },
michael@0 148 { description: "Scroll to right by pixel scroll even if lineOrPageDelta is 0",
michael@0 149 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 150 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 151 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 152 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 153 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 154 expected: kScrollRight },
michael@0 155 { description: "Scroll to right by pixel scroll when lineOrPageDelta is 1",
michael@0 156 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 157 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 158 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 159 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 160 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 161 expected: kScrollRight },
michael@0 162 { description: "Scroll to left by pixel scroll even if lineOrPageDelta is 0",
michael@0 163 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 164 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 165 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 166 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 167 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 168 expected: kScrollLeft },
michael@0 169 { description: "Scroll to left by pixel scroll when lineOrPageDelta is -1",
michael@0 170 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 171 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 172 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 173 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 174 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 175 expected: kScrollLeft },
michael@0 176 { description: "Scroll to bottom-right by pixel scroll",
michael@0 177 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 178 deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 179 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 180 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 181 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 182 expected: kScrollDown | kScrollRight },
michael@0 183 { description: "Scroll to bottom-left by pixel scroll",
michael@0 184 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 185 deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 186 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 187 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 188 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 189 expected: kScrollDown | kScrollLeft },
michael@0 190 { description: "Scroll to top-left by pixel scroll",
michael@0 191 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 192 deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 193 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 194 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 195 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 196 expected: kScrollUp | kScrollLeft },
michael@0 197 { description: "Scroll to top-right by pixel scroll",
michael@0 198 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 199 deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 200 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 201 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 202 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 203 expected: kScrollUp | kScrollRight },
michael@0 204 { description: "Not Scroll by pixel scroll for z",
michael@0 205 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 206 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 207 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 208 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 209 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 210 expected: kNoScroll },
michael@0 211
michael@0 212 { description: "Scroll to bottom by line scroll even if lineOrPageDelta is 0",
michael@0 213 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 214 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 215 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
michael@0 216 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 217 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 218 expected: kScrollDown },
michael@0 219 { description: "Scroll to bottom by line scroll when lineOrPageDelta is 1",
michael@0 220 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 221 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 222 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
michael@0 223 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 224 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 225 expected: kScrollDown },
michael@0 226 { description: "Scroll to top by line scroll even if lineOrPageDelta is 0",
michael@0 227 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 228 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 229 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 230 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 231 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 232 expected: kScrollUp },
michael@0 233 { description: "Scroll to top by line scroll when lineOrPageDelta is -1",
michael@0 234 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 235 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 236 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
michael@0 237 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 238 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 239 expected: kScrollUp },
michael@0 240 { description: "Scroll to right by line scroll even if lineOrPageDelta is 0",
michael@0 241 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 242 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 243 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 244 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 245 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 246 expected: kScrollRight },
michael@0 247 { description: "Scroll to right by line scroll when lineOrPageDelta is 1",
michael@0 248 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 249 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 250 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 251 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 252 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 253 expected: kScrollRight },
michael@0 254 { description: "Scroll to left by line scroll even if lineOrPageDelta is 0",
michael@0 255 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 256 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 257 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 258 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 259 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 260 expected: kScrollLeft },
michael@0 261 { description: "Scroll to left by line scroll when lineOrPageDelta is -1",
michael@0 262 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 263 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 264 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 265 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 266 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 267 expected: kScrollLeft },
michael@0 268 { description: "Scroll to bottom-right by line scroll",
michael@0 269 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 270 deltaX: 0.5, deltaY: 0.5, deltaZ: 0.0,
michael@0 271 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 272 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 273 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 274 expected: kScrollDown | kScrollRight },
michael@0 275 { description: "Scroll to bottom-left by line scroll",
michael@0 276 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 277 deltaX: -0.5, deltaY: 0.5, deltaZ: 0.0,
michael@0 278 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 279 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 280 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 281 expected: kScrollDown | kScrollLeft },
michael@0 282 { description: "Scroll to top-left by line scroll",
michael@0 283 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 284 deltaX: -0.5, deltaY: -0.5, deltaZ: 0.0,
michael@0 285 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 286 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 287 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 288 expected: kScrollUp | kScrollLeft },
michael@0 289 { description: "Scroll to top-right by line scroll",
michael@0 290 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 291 deltaX: 0.5, deltaY: -0.5, deltaZ: 0.0,
michael@0 292 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 293 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 294 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 295 expected: kScrollUp | kScrollRight },
michael@0 296 { description: "Not Scroll by line scroll for z",
michael@0 297 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 298 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 299 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 300 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 301 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 302 expected: kNoScroll },
michael@0 303
michael@0 304 { description: "Scroll to bottom by page scroll even if lineOrPageDelta is 0",
michael@0 305 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 306 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 307 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
michael@0 308 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 309 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 310 expected: kScrollDown },
michael@0 311 { description: "Scroll to bottom by page scroll when lineOrPageDelta is 1",
michael@0 312 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 313 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 314 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
michael@0 315 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 316 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 317 expected: kScrollDown },
michael@0 318 { description: "Scroll to top by page scroll even if lineOrPageDelta is 0",
michael@0 319 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 320 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 321 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 322 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 323 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 324 expected: kScrollUp },
michael@0 325 { description: "Scroll to top by page scroll when lineOrPageDelta is -1",
michael@0 326 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 327 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 328 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
michael@0 329 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 330 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 331 expected: kScrollUp },
michael@0 332 { description: "Scroll to right by page scroll even if lineOrPageDelta is 0",
michael@0 333 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 334 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 335 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 336 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 337 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 338 expected: kScrollRight },
michael@0 339 { description: "Scroll to right by page scroll when lineOrPageDelta is 1",
michael@0 340 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 341 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 342 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 343 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 344 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 345 expected: kScrollRight },
michael@0 346 { description: "Scroll to left by page scroll even if lineOrPageDelta is 0",
michael@0 347 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 348 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 349 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 350 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 351 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 352 expected: kScrollLeft },
michael@0 353 { description: "Scroll to left by page scroll when lineOrPageDelta is -1",
michael@0 354 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 355 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 356 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 357 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 358 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 359 expected: kScrollLeft },
michael@0 360 { description: "Scroll to bottom-right by page scroll",
michael@0 361 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 362 deltaX: 0.5, deltaY: 0.5, deltaZ: 0.0,
michael@0 363 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 364 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 365 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 366 expected: kScrollDown | kScrollRight },
michael@0 367 { description: "Scroll to bottom-left by page scroll",
michael@0 368 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 369 deltaX: -0.5, deltaY: 0.5, deltaZ: 0.0,
michael@0 370 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 371 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 372 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 373 expected: kScrollDown | kScrollLeft },
michael@0 374 { description: "Scroll to top-left by page scroll",
michael@0 375 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 376 deltaX: -0.5, deltaY: -0.5, deltaZ: 0.0,
michael@0 377 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 378 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 379 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 380 expected: kScrollUp | kScrollLeft },
michael@0 381 { description: "Scroll to top-right by page scroll",
michael@0 382 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 383 deltaX: 0.5, deltaY: -0.5, deltaZ: 0.0,
michael@0 384 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 385 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 386 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 387 expected: kScrollUp | kScrollRight },
michael@0 388 { description: "Not Scroll by page scroll for z",
michael@0 389 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 390 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 391 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
michael@0 392 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 393 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 394 expected: kNoScroll },
michael@0 395
michael@0 396 // special cases.
michael@0 397
michael@0 398 // momentum scroll should cause scroll even if the action is zoom, but if the default action is none,
michael@0 399 // shouldn't do it.
michael@0 400 { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
michael@0 401 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 402 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 403 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 404 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 405 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 406 expected: kScrollDown },
michael@0 407 { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 1, even if the action is zoom",
michael@0 408 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 409 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 410 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: true,
michael@0 411 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 412 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 413 expected: kScrollDown },
michael@0 414 { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
michael@0 415 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 416 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 417 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 418 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 419 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 420 expected: kScrollUp },
michael@0 421 { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is -1, even if the action is zoom",
michael@0 422 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 423 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 424 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: true,
michael@0 425 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 426 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 427 expected: kScrollUp },
michael@0 428 { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
michael@0 429 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 430 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 431 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 432 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 433 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 434 expected: kScrollRight },
michael@0 435 { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 1, even if the action is zoom",
michael@0 436 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 437 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 438 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 439 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 440 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 441 expected: kScrollRight },
michael@0 442 { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
michael@0 443 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 444 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 445 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 446 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 447 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 448 expected: kScrollLeft },
michael@0 449 { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is -1, even if the action is zoom",
michael@0 450 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 451 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 452 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 453 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 454 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 455 expected: kScrollLeft },
michael@0 456 { description: "Scroll to bottom-right by momentum pixel scroll even if the action is zoom",
michael@0 457 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 458 deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 459 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 460 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 461 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 462 expected: kScrollDown | kScrollRight },
michael@0 463 { description: "Scroll to bottom-left by momentum pixel scroll even if the action is zoom",
michael@0 464 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 465 deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 466 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 467 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 468 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 469 expected: kScrollDown | kScrollLeft },
michael@0 470 { description: "Scroll to top-left by momentum pixel scroll even if the action is zoom",
michael@0 471 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 472 deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 473 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 474 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 475 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 476 expected: kScrollUp | kScrollLeft },
michael@0 477 { description: "Scroll to top-right by momentum pixel scroll even if the action is zoom",
michael@0 478 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 479 deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 480 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 481 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 482 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 483 expected: kScrollUp | kScrollRight },
michael@0 484 { description: "Not Scroll by momentum pixel scroll for z (action is zoom)",
michael@0 485 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 486 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 487 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 488 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 489 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 490 expected: kNoScroll },
michael@0 491 { description: "Not Scroll by momentum pixel scroll if default action is none (action is zoom)",
michael@0 492 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 493 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 494 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 495 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 496 shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
michael@0 497 expected: kNoScroll,
michael@0 498 prepare: function () { SpecialPowers.setIntPref("mousewheel.default.action", 0); },
michael@0 499 cleanup: function () { SpecialPowers.setIntPref("mousewheel.default.action", 1); } },
michael@0 500
michael@0 501 // momentum scroll should cause scroll even if the action is history, but if the default action is none,
michael@0 502 // shouldn't do it.
michael@0 503 { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
michael@0 504 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 505 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 506 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 507 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 508 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 509 expected: kScrollDown },
michael@0 510 { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 1, even if the action is history",
michael@0 511 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 512 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 513 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: true,
michael@0 514 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 515 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 516 expected: kScrollDown },
michael@0 517 { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
michael@0 518 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 519 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 520 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 521 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 522 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 523 expected: kScrollUp },
michael@0 524 { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is -1, even if the action is history",
michael@0 525 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 526 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 527 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: true,
michael@0 528 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 529 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 530 expected: kScrollUp },
michael@0 531 { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
michael@0 532 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 533 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 534 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 535 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 536 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 537 expected: kScrollRight },
michael@0 538 { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 1, even if the action is history",
michael@0 539 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 540 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 541 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 542 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 543 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 544 expected: kScrollRight },
michael@0 545 { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
michael@0 546 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 547 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 548 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 549 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 550 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 551 expected: kScrollLeft },
michael@0 552 { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is -1, even if the action is history",
michael@0 553 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 554 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 555 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 556 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 557 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 558 expected: kScrollLeft },
michael@0 559 { description: "Scroll to bottom-right by momentum pixel scroll even if the action is history",
michael@0 560 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 561 deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 562 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 563 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 564 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 565 expected: kScrollDown | kScrollRight },
michael@0 566 { description: "Scroll to bottom-left by momentum pixel scroll even if the action is history",
michael@0 567 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 568 deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 569 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 570 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 571 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 572 expected: kScrollDown | kScrollLeft },
michael@0 573 { description: "Scroll to top-left by momentum pixel scroll even if the action is history",
michael@0 574 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 575 deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 576 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 577 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 578 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 579 expected: kScrollUp | kScrollLeft },
michael@0 580 { description: "Scroll to top-right by momentum pixel scroll even if the action is history",
michael@0 581 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 582 deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 583 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 584 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 585 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 586 expected: kScrollUp | kScrollRight },
michael@0 587 { description: "Not Scroll by momentum pixel scroll for z (action is history)",
michael@0 588 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 589 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 590 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 591 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 592 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 593 expected: kNoScroll },
michael@0 594 { description: "Not Scroll by momentum pixel scroll if default action is none (action is history)",
michael@0 595 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 596 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 597 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
michael@0 598 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 599 shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 600 expected: kNoScroll,
michael@0 601 prepare: function () { SpecialPowers.setIntPref("mousewheel.default.action", 0); },
michael@0 602 cleanup: function () { SpecialPowers.setIntPref("mousewheel.default.action", 1); } },
michael@0 603
michael@0 604 // Don't scroll along axis whose overflow style is hidden.
michael@0 605 { description: "Scroll to only bottom by oblique pixel wheel event with overflow-x: hidden",
michael@0 606 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 607 deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
michael@0 608 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 609 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
michael@0 610 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 611 expected: kScrollDown,
michael@0 612 prepare: function() { gScrollableElement.style.overflowX = "hidden"; } },
michael@0 613 { description: "Scroll to only bottom by oblique line wheel event with overflow-x: hidden",
michael@0 614 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 615 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 616 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 617 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
michael@0 618 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 619 expected: kScrollDown },
michael@0 620 { description: "Scroll to only bottom by oblique page wheel event with overflow-x: hidden",
michael@0 621 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 622 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 623 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 624 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
michael@0 625 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 626 expected: kScrollDown },
michael@0 627 { description: "Scroll to only top by oblique pixel wheel event with overflow-x: hidden",
michael@0 628 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 629 deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
michael@0 630 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 631 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
michael@0 632 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 633 expected: kScrollUp },
michael@0 634 { description: "Scroll to only top by oblique line wheel event with overflow-x: hidden",
michael@0 635 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 636 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 637 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 638 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
michael@0 639 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 640 expected: kScrollUp },
michael@0 641 { description: "Scroll to only top by oblique page wheel event with overflow-x: hidden",
michael@0 642 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 643 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 644 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 645 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
michael@0 646 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 647 expected: kScrollUp,
michael@0 648 cleanup: function () { gScrollableElement.style.overflowX = "auto"; } },
michael@0 649 { description: "Scroll to only right by oblique pixel wheel event with overflow-y: hidden",
michael@0 650 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 651 deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
michael@0 652 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 653 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
michael@0 654 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 655 expected: kScrollRight,
michael@0 656 prepare: function() { gScrollableElement.style.overflowY = "hidden"; } },
michael@0 657 { description: "Scroll to only right by oblique line wheel event with overflow-y: hidden",
michael@0 658 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 659 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 660 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 661 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
michael@0 662 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 663 expected: kScrollRight },
michael@0 664 { description: "Scroll to only right by oblique page wheel event with overflow-y: hidden",
michael@0 665 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 666 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 667 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 668 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
michael@0 669 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 670 expected: kScrollRight },
michael@0 671 { description: "Scroll to only left by oblique pixel wheel event with overflow-y: hidden",
michael@0 672 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 673 deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
michael@0 674 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 675 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
michael@0 676 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 677 expected: kScrollLeft },
michael@0 678 { description: "Scroll to only top by oblique line wheel event with overflow-y: hidden",
michael@0 679 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 680 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 681 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 682 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
michael@0 683 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 684 expected: kScrollLeft },
michael@0 685 { description: "Scroll to only top by oblique page wheel event with overflow-y: hidden",
michael@0 686 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 687 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 688 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 689 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
michael@0 690 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 691 expected: kScrollLeft,
michael@0 692 cleanup: function () { gScrollableElement.style.overflowY = "auto"; } },
michael@0 693 { description: "Don't be scrolled by oblique pixel wheel event with overflow: hidden",
michael@0 694 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 695 deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
michael@0 696 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 697 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
michael@0 698 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 699 expected: kNoScroll,
michael@0 700 prepare: function() { gScrollableElement.style.overflow = "hidden"; } },
michael@0 701 { description: "Don't be scrolled by oblique line wheel event with overflow: hidden",
michael@0 702 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 703 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 704 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 705 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
michael@0 706 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 707 expected: kNoScroll },
michael@0 708 { description: "Don't be scrolled by oblique page wheel event with overflow: hidden",
michael@0 709 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 710 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 711 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 712 expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
michael@0 713 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 714 expected: kNoScroll },
michael@0 715 { description: "Don't be scrolled by oblique pixel wheel event with overflow: hidden",
michael@0 716 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 717 deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
michael@0 718 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 719 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
michael@0 720 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 721 expected: kNoScroll },
michael@0 722 { description: "Don't be scrolled by oblique line wheel event with overflow: hidden",
michael@0 723 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 724 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 725 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 726 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
michael@0 727 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 728 expected: kNoScroll },
michael@0 729 { description: "Don't be scrolled by oblique page wheel event with overflow: hidden",
michael@0 730 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 731 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 732 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 733 expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
michael@0 734 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 735 expected: kNoScroll,
michael@0 736 cleanup: function () { gScrollableElement.style.overflow = "auto"; } },
michael@0 737
michael@0 738 // Don't scroll along axis whose overflow style is hidden and overflow delta values should
michael@0 739 // be zero if there is ancestor scrollable element.
michael@0 740 { description: "Scroll to only bottom by oblique pixel wheel event with overflow-x: hidden (body is scrollable)",
michael@0 741 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 742 deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
michael@0 743 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 744 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 745 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 746 expected: kScrollDown,
michael@0 747 prepare: function() {
michael@0 748 gScrollableElement.style.overflowX = "hidden";
michael@0 749 gScrollableElement.style.position = "fixed";
michael@0 750 gScrollableElement.style.top = "30px";
michael@0 751 gScrollableElement.style.left = "30px";
michael@0 752 // Make body element scrollable.
michael@0 753 gSpacerForBodyElement.style.width = "5000px";
michael@0 754 gSpacerForBodyElement.style.height = "5000px";
michael@0 755 document.documentElement.scrollTop = 500;
michael@0 756 document.documentElement.scrollLeft = 500;
michael@0 757 } },
michael@0 758 { description: "Scroll to only bottom by oblique line wheel event with overflow-x: hidden (body is scrollable)",
michael@0 759 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 760 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 761 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 762 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 763 expected: kScrollDown },
michael@0 764 { description: "Scroll to only bottom by oblique page wheel event with overflow-x: hidden (body is scrollable)",
michael@0 765 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 766 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 767 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 768 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 769 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 770 expected: kScrollDown },
michael@0 771 { description: "Scroll to only top by oblique pixel wheel event with overflow-x: hidden (body is scrollable)",
michael@0 772 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 773 deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
michael@0 774 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 775 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 776 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 777 expected: kScrollUp },
michael@0 778 { description: "Scroll to only top by oblique line wheel event with overflow-x: hidden (body is scrollable)",
michael@0 779 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 780 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 781 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 782 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 783 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 784 expected: kScrollUp },
michael@0 785 { description: "Scroll to only top by oblique page wheel event with overflow-x: hidden (body is scrollable)",
michael@0 786 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 787 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 788 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 789 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 790 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 791 expected: kScrollUp,
michael@0 792 cleanup: function () { gScrollableElement.style.overflowX = "auto"; } },
michael@0 793 { description: "Scroll to only right by oblique pixel wheel event with overflow-y: hidden (body is scrollable)",
michael@0 794 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 795 deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
michael@0 796 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 797 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 798 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 799 expected: kScrollRight,
michael@0 800 prepare: function() { gScrollableElement.style.overflowY = "hidden"; } },
michael@0 801 { description: "Scroll to only right by oblique line wheel event with overflow-y: hidden (body is scrollable)",
michael@0 802 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 803 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 804 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 805 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 806 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 807 expected: kScrollRight },
michael@0 808 { description: "Scroll to only right by oblique page wheel event with overflow-y: hidden (body is scrollable)",
michael@0 809 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 810 deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
michael@0 811 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
michael@0 812 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 813 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 814 expected: kScrollRight },
michael@0 815 { description: "Scroll to only left by oblique pixel wheel event with overflow-y: hidden (body is scrollable)",
michael@0 816 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 817 deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
michael@0 818 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 819 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 820 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 821 expected: kScrollLeft },
michael@0 822 { description: "Scroll to only top by oblique line wheel event with overflow-y: hidden (body is scrollable)",
michael@0 823 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 824 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 825 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 826 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 827 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 828 expected: kScrollLeft },
michael@0 829 { description: "Scroll to only top by oblique page wheel event with overflow-y: hidden (body is scrollable)",
michael@0 830 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 831 deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
michael@0 832 lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
michael@0 833 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
michael@0 834 shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
michael@0 835 expected: kScrollLeft,
michael@0 836 cleanup: function () {
michael@0 837 gScrollableElement.style.overflowY = "auto";
michael@0 838 gScrollableElement.style.position = "static";
michael@0 839 gSpacerForBodyElement.style.width = "";
michael@0 840 gSpacerForBodyElement.style.height = "";
michael@0 841 } },
michael@0 842 ];
michael@0 843
michael@0 844 var description;
michael@0 845
michael@0 846 var currentTestIndex = -1;
michael@0 847 var isXReverted = (aSettings.deltaMultiplierX < 0);
michael@0 848 var isYReverted = (aSettings.deltaMultiplierY < 0);
michael@0 849
michael@0 850 function doNextTest()
michael@0 851 {
michael@0 852 if (++currentTestIndex >= kTests.length) {
michael@0 853 SimpleTest.executeSoon(aCallback);
michael@0 854 return;
michael@0 855 }
michael@0 856
michael@0 857 gScrollableElement.scrollTop = 1000;
michael@0 858 gScrollableElement.scrollLeft = 1000;
michael@0 859
michael@0 860 var currentTest = kTests[currentTestIndex];
michael@0 861 description = "doTestScroll(aSettings=" + aSettings.description + "), " + currentTest.description + ": ";
michael@0 862 if (currentTest.prepare) {
michael@0 863 currentTest.prepare();
michael@0 864 }
michael@0 865
michael@0 866 synthesizeWheel(gScrollableElement, 10, 10, currentTest.event);
michael@0 867
michael@0 868 hitEventLoop(function () {
michael@0 869 if (currentTest.expected == kNoScroll) {
michael@0 870 is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
michael@0 871 is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
michael@0 872 } else {
michael@0 873 var scrollUp = !isYReverted ? (currentTest.expected & kScrollUp) :
michael@0 874 (currentTest.expected & kScrollDown);
michael@0 875 var scrollDown = !isYReverted ? (currentTest.expected & kScrollDown) :
michael@0 876 (currentTest.expected & kScrollUp);
michael@0 877 if (scrollUp) {
michael@0 878 ok(gScrollableElement.scrollTop < 1000, description + "not scrolled up, got " + gScrollableElement.scrollTop);
michael@0 879 } else if (scrollDown) {
michael@0 880 ok(gScrollableElement.scrollTop > 1000, description + "not scrolled down, got " + gScrollableElement.scrollTop);
michael@0 881 } else {
michael@0 882 is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
michael@0 883 }
michael@0 884 var scrollLeft = !isXReverted ? (currentTest.expected & kScrollLeft) :
michael@0 885 (currentTest.expected & kScrollRight);
michael@0 886 var scrollRight = !isXReverted ? (currentTest.expected & kScrollRight) :
michael@0 887 (currentTest.expected & kScrollLeft);
michael@0 888 if (scrollLeft) {
michael@0 889 ok(gScrollableElement.scrollLeft < 1000, description + "not scrolled to left, got " + gScrollableElement.scrollLeft);
michael@0 890 } else if (scrollRight) {
michael@0 891 ok(gScrollableElement.scrollLeft > 1000, description + "not scrolled to right, got " + gScrollableElement.scrollLeft);
michael@0 892 } else {
michael@0 893 is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
michael@0 894 }
michael@0 895 }
michael@0 896 if (currentTest.cleanup) {
michael@0 897 currentTest.cleanup();
michael@0 898 }
michael@0 899 winUtils.advanceTimeAndRefresh(100);
michael@0 900 doNextTest();
michael@0 901 }, 10);
michael@0 902 }
michael@0 903 doNextTest();
michael@0 904 }
michael@0 905
michael@0 906 function doTestZoom(aSettings, aCallback)
michael@0 907 {
michael@0 908 if ((aSettings.deltaMultiplierX != 1.0 && aSettings.deltaMultiplierX != -1.0) ||
michael@0 909 (aSettings.deltaMultiplierY != 1.0 && aSettings.deltaMultiplierY != -1.0)) {
michael@0 910 todo(false, "doTestZoom doesn't support to test with aSettings=" + aSettings.description);
michael@0 911 SimpleTest.executeSoon(aCallback);
michael@0 912 return;
michael@0 913 }
michael@0 914
michael@0 915 const kNone = 0x00;
michael@0 916 const kPositive = 0x01;
michael@0 917 const kNegative = 0x02;
michael@0 918 const kUseX = 0x10;
michael@0 919 const kUseY = 0x20;
michael@0 920 const kTests = [
michael@0 921 { description: "by vertical/positive pixel event when its lineOrPageDeltaY is 0",
michael@0 922 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 923 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 924 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 925 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 926 expected: kNone },
michael@0 927 { description: "by vertical/positive pixel event when its lineOrPageDeltaY is 1",
michael@0 928 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 929 deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
michael@0 930 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
michael@0 931 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 932 expected: kPositive | kUseY },
michael@0 933 { description: "by vertical/negative pixel event when its lineOrPageDeltaY is 0",
michael@0 934 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 935 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 936 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 937 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 938 expected: kNone },
michael@0 939 { description: "by vertical/negative pixel event when its lineOrPageDeltaY is -1",
michael@0 940 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 941 deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
michael@0 942 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
michael@0 943 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 944 expected: kNegative | kUseY },
michael@0 945 { description: "by horizotal/positive pixel event when its lineOrPageDeltaX is 0",
michael@0 946 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 947 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 948 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 949 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 950 expected: kNone },
michael@0 951 { description: "by horizotal/positive pixel event when its lineOrPageDeltaX is 1",
michael@0 952 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 953 deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 954 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
michael@0 955 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 956 expected: kPositive | kUseX },
michael@0 957 { description: "by horizotal/negative pixel event when its lineOrPageDeltaX is 0",
michael@0 958 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 959 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 960 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 961 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 962 expected: kNone },
michael@0 963 { description: "by horizotal/negative pixel event when its lineOrPageDeltaX is -1",
michael@0 964 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 965 deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
michael@0 966 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
michael@0 967 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 968 expected: kNegative | kUseX },
michael@0 969 { description: "by z pixel event",
michael@0 970 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 971 deltaX: 0.0, deltaY: 0.0, deltaZ: 16.0,
michael@0 972 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 973 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 974 expected: kNone },
michael@0 975
michael@0 976 { description: "by vertical/positive line event when its lineOrPageDeltaY is 0",
michael@0 977 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 978 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 979 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 980 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 981 expected: kNone },
michael@0 982 { description: "by vertical/positive line event when its lineOrPageDeltaY is 1",
michael@0 983 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 984 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 985 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
michael@0 986 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 987 expected: kPositive | kUseY },
michael@0 988 { description: "by vertical/negative line event when its lineOrPageDeltaY is 0",
michael@0 989 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 990 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 991 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 992 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 993 expected: kNone },
michael@0 994 { description: "by vertical/negative line event when its lineOrPageDeltaY is -1",
michael@0 995 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 996 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 997 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
michael@0 998 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 999 expected: kNegative | kUseY },
michael@0 1000 { description: "by horizotal/positive line event when its lineOrPageDeltaX is 0",
michael@0 1001 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1002 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1003 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1004 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1005 expected: kNone },
michael@0 1006 { description: "by horizotal/positive line event when its lineOrPageDeltaX is 1",
michael@0 1007 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1008 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1009 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
michael@0 1010 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1011 expected: kPositive | kUseX },
michael@0 1012 { description: "by horizotal/negative line event when its lineOrPageDeltaX is 0",
michael@0 1013 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1014 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1015 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1016 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1017 expected: kNone },
michael@0 1018 { description: "by horizotal/negative line event when its lineOrPageDeltaX is -1",
michael@0 1019 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1020 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1021 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
michael@0 1022 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1023 expected: kNegative | kUseX },
michael@0 1024 { description: "by z line event",
michael@0 1025 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1026 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 1027 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1028 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1029 expected: kNone },
michael@0 1030
michael@0 1031 { description: "by vertical/positive page event when its lineOrPageDeltaY is 0",
michael@0 1032 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1033 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 1034 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1035 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1036 expected: kNone },
michael@0 1037 { description: "by vertical/positive page event when its lineOrPageDeltaY is 1",
michael@0 1038 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1039 deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
michael@0 1040 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
michael@0 1041 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1042 expected: kPositive | kUseY },
michael@0 1043 { description: "by vertical/negative page event when its lineOrPageDeltaY is 0",
michael@0 1044 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1045 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 1046 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1047 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1048 expected: kNone },
michael@0 1049 { description: "by vertical/negative page event when its lineOrPageDeltaY is -1",
michael@0 1050 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1051 deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
michael@0 1052 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
michael@0 1053 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1054 expected: kNegative | kUseY },
michael@0 1055 { description: "by horizotal/positive page event when its lineOrPageDeltaX is 0",
michael@0 1056 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1057 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1058 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1059 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1060 expected: kNone },
michael@0 1061 { description: "by horizotal/positive page event when its lineOrPageDeltaX is 1",
michael@0 1062 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1063 deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1064 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
michael@0 1065 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1066 expected: kPositive | kUseX },
michael@0 1067 { description: "by horizotal/negative page event when its lineOrPageDeltaX is 0",
michael@0 1068 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1069 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1070 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1071 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1072 expected: kNone },
michael@0 1073 { description: "by horizotal/negative page event when its lineOrPageDeltaX is -1",
michael@0 1074 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1075 deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
michael@0 1076 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
michael@0 1077 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1078 expected: kNegative | kUseX },
michael@0 1079 { description: "by z page event",
michael@0 1080 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1081 deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
michael@0 1082 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
michael@0 1083 expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
michael@0 1084 expected: kNone },
michael@0 1085 ];
michael@0 1086
michael@0 1087 var description, currentTest;
michael@0 1088 var currentTestIndex = -1;
michael@0 1089 var isXReverted = (aSettings.deltaMultiplierX < 0);
michael@0 1090 var isYReverted = (aSettings.deltaMultiplierY < 0);
michael@0 1091
michael@0 1092 function doNextTest()
michael@0 1093 {
michael@0 1094 if (++currentTestIndex >= kTests.length) {
michael@0 1095 SimpleTest.executeSoon(aCallback);
michael@0 1096 return;
michael@0 1097 }
michael@0 1098
michael@0 1099 gScrollableElement.scrollTop = 1000;
michael@0 1100 gScrollableElement.scrollLeft = 1000;
michael@0 1101
michael@0 1102 currentTest = kTests[currentTestIndex];
michael@0 1103 description = "doTestZoom(aSettings=" + aSettings.description + "), ";
michael@0 1104 if (currentTest.expected == kNone) {
michael@0 1105 description += "Shouldn't ";
michael@0 1106 } else {
michael@0 1107 description += "Should ";
michael@0 1108 }
michael@0 1109 description += "zoom " + currentTest.description + ": ";
michael@0 1110
michael@0 1111 var event = currentTest.event;
michael@0 1112 event.ctrlKey = true;
michael@0 1113 synthesizeWheel(gScrollableElement, 10, 10, event);
michael@0 1114
michael@0 1115 // NOTE: Zooming might change scrollTop and scrollLeft by rounding fraction.
michael@0 1116 // This test assume that zoom happens synchronously and scrolling
michael@0 1117 // happens asynchronously.
michael@0 1118 var scrollTop = gScrollableElement.scrollTop;
michael@0 1119 var scrollLeft = gScrollableElement.scrollLeft;
michael@0 1120
michael@0 1121 hitEventLoop(function () {
michael@0 1122 is(gScrollableElement.scrollTop, scrollTop, description + "scrolled vertical");
michael@0 1123 is(gScrollableElement.scrollLeft, scrollLeft, description + "scrolled horizontal");
michael@0 1124 if (!(currentTest.expected & (kNegative | kPositive))) {
michael@0 1125 is(SpecialPowers.getFullZoom(window), 1.0, description + "zoomed");
michael@0 1126 } else {
michael@0 1127 var isReverted = (currentTest.expected & kUseX) ? isXReverted :
michael@0 1128 (currentTest.expected & kUseY) ? isYReverted : false;
michael@0 1129 if ((!isReverted && (currentTest.expected & kNegative)) ||
michael@0 1130 (isReverted && (currentTest.expected & kPositive))) {
michael@0 1131 ok(SpecialPowers.getFullZoom(window) > 1.0,
michael@0 1132 description + "not zoomed in, got " + SpecialPowers.getFullZoom(window));
michael@0 1133 } else {
michael@0 1134 ok(SpecialPowers.getFullZoom(window) < 1.0,
michael@0 1135 description + "not zoomed out, got " + SpecialPowers.getFullZoom(window));
michael@0 1136 }
michael@0 1137 }
michael@0 1138
michael@0 1139 synthesizeKey("0", { accelKey: true });
michael@0 1140 onZoomReset(function () {
michael@0 1141 hitEventLoop(doNextTest, 20);
michael@0 1142 });
michael@0 1143 }, 20);
michael@0 1144 }
michael@0 1145 doNextTest();
michael@0 1146 }
michael@0 1147
michael@0 1148 function doTestZoomedScroll(aCallback)
michael@0 1149 {
michael@0 1150 var zoom = 1.0;
michael@0 1151 function setFullZoom(aWindow, aZoom)
michael@0 1152 {
michael@0 1153 zoom = aZoom;
michael@0 1154 SpecialPowers.setFullZoom(aWindow, aZoom);
michael@0 1155 }
michael@0 1156
michael@0 1157 function prepareTestZoomedPixelScroll()
michael@0 1158 {
michael@0 1159 // Reset zoom and store the scroll amount into the data.
michael@0 1160 synthesizeKey("0", { accelKey: true });
michael@0 1161 zoom = 1.0;
michael@0 1162 onZoomReset(testZoomedPixelScroll);
michael@0 1163 }
michael@0 1164
michael@0 1165 function testZoomedPixelScroll()
michael@0 1166 {
michael@0 1167 gScrollableElement.scrollTop = 1000;
michael@0 1168 gScrollableElement.scrollLeft = 1000;
michael@0 1169 // Ensure not to be in reflow.
michael@0 1170 hitEventLoop(function () {
michael@0 1171 function mousePixelScrollHandler(aEvent)
michael@0 1172 {
michael@0 1173 if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
michael@0 1174 is(aEvent.detail, 16,
michael@0 1175 "doTestZoomedScroll: The detail of horizontal MozMousePixelScroll for pixel wheel event is wrong");
michael@0 1176 } else if (aEvent.axis == MouseScrollEvent.VERTICAL_AXIS) {
michael@0 1177 is(aEvent.detail, 16,
michael@0 1178 "doTestZoomedScroll: The detail of vertical MozMousePixelScroll for pixel wheel event is wrong");
michael@0 1179 } else {
michael@0 1180 ok(false, "doTestZoomedScroll: The axis of MozMousePixelScroll for pixel wheel event is invalid, got " + aEvent.axis);
michael@0 1181 }
michael@0 1182 }
michael@0 1183 function wheelHandler(aEvent)
michael@0 1184 {
michael@0 1185 is(aEvent.deltaX, 16.0 / zoom,
michael@0 1186 "doTestZoomedScroll: The deltaX of wheel for pixel is wrong");
michael@0 1187 is(aEvent.deltaY, 16.0 / zoom,
michael@0 1188 "doTestZoomedScroll: The deltaY of wheel for pixel is wrong");
michael@0 1189 }
michael@0 1190 window.addEventListener("MozMousePixelScroll", mousePixelScrollHandler, true);
michael@0 1191 window.addEventListener("wheel", wheelHandler, true);
michael@0 1192 synthesizeWheel(gScrollableElement, 10, 10,
michael@0 1193 { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1194 deltaX: 16.0, deltaY: 16.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
michael@0 1195 // wait scrolled actually.
michael@0 1196 hitEventLoop(function () {
michael@0 1197 var scrolledX = gScrollableElement.scrollLeft;
michael@0 1198 var scrolledY = gScrollableElement.scrollTop;
michael@0 1199 ok(scrolledX > 1000,
michael@0 1200 "doTestZoomedScroll: scrolledX must be larger than 1000 for pixel wheel event, got " + scrolledX);
michael@0 1201 ok(scrolledY > 1000,
michael@0 1202 "doTestZoomedScroll: scrolledY must be larger than 1000 for pixel wheel event, got " + scrolledY);
michael@0 1203
michael@0 1204 // Zoom
michael@0 1205 setFullZoom(window, 2.0);
michael@0 1206 // Ensure not to be in reflow.
michael@0 1207 hitEventLoop(function () {
michael@0 1208 gScrollableElement.scrollTop = 1000;
michael@0 1209 gScrollableElement.scrollLeft = 1000;
michael@0 1210 synthesizeWheel(gScrollableElement, 10, 10,
michael@0 1211 { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1212 deltaX: 16.0, deltaY: 16.0, lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 });
michael@0 1213 // wait scrolled actually.
michael@0 1214 hitEventLoop(function () {
michael@0 1215 ok(Math.abs(gScrollableElement.scrollLeft - (1000 + (scrolledX - 1000) / 2)) <= 1,
michael@0 1216 "doTestZoomedScroll: zoomed horizontal scroll amount by pixel wheel event is different from normal, scrollLeft=" +
michael@0 1217 gScrollableElement.scrollLeft + ", scrolledX=" + scrolledX);
michael@0 1218 ok(Math.abs(gScrollableElement.scrollTop - (1000 + (scrolledY - 1000) / 2)) <= 1,
michael@0 1219 "doTestZoomedScroll: zoomed vertical scroll amount by pixel wheel event is different from normal, scrollTop=" +
michael@0 1220 gScrollableElement.scrollTop + ", scrolledY=" + scrolledY);
michael@0 1221 window.removeEventListener("MozMousePixelScroll", mousePixelScrollHandler, true);
michael@0 1222 window.removeEventListener("wheel", wheelHandler, true);
michael@0 1223
michael@0 1224 synthesizeKey("0", { accelKey: true });
michael@0 1225 onZoomReset(prepareTestZoomedLineScroll);
michael@0 1226 }, 20);
michael@0 1227 }, 20);
michael@0 1228 }, 20);
michael@0 1229 }, 20);
michael@0 1230 }
michael@0 1231
michael@0 1232 function prepareTestZoomedLineScroll()
michael@0 1233 {
michael@0 1234 // Reset zoom and store the scroll amount into the data.
michael@0 1235 synthesizeKey("0", { accelKey: true });
michael@0 1236 zoom = 1.0;
michael@0 1237 onZoomReset(testZoomedLineScroll);
michael@0 1238 }
michael@0 1239 function testZoomedLineScroll()
michael@0 1240 {
michael@0 1241 gScrollableElement.scrollTop = 1000;
michael@0 1242 gScrollableElement.scrollLeft = 1000;
michael@0 1243 // Ensure not to be in reflow.
michael@0 1244 hitEventLoop(function () {
michael@0 1245 var lineHeightX, lineHeightY;
michael@0 1246 function handler(aEvent)
michael@0 1247 {
michael@0 1248 if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
michael@0 1249 if (lineHeightX == undefined) {
michael@0 1250 lineHeightX = aEvent.detail;
michael@0 1251 } else {
michael@0 1252 ok(Math.abs(aEvent.detail - lineHeightX) <= 1,
michael@0 1253 "doTestZoomedScroll: The detail of horizontal MozMousePixelScroll for line wheel event is wrong, aEvent.detail=" +
michael@0 1254 aEvent.detail + ", lineHeightX=" + lineHeightX);
michael@0 1255 }
michael@0 1256 } else if (aEvent.axis == MouseScrollEvent.VERTICAL_AXIS) {
michael@0 1257 if (lineHeightY == undefined) {
michael@0 1258 lineHeightY = aEvent.detail;
michael@0 1259 } else {
michael@0 1260 ok(Math.abs(aEvent.detail - lineHeightY) <= 1,
michael@0 1261 "doTestZoomedScroll: The detail of vertical MozMousePixelScroll for line wheel event is wrong, aEvent.detail=" +
michael@0 1262 aEvent.detail + ", lineHeightY=" + lineHeightY);
michael@0 1263 }
michael@0 1264 } else {
michael@0 1265 ok(false, "doTestZoomedScroll: The axis of MozMousePixelScroll for line wheel event is invalid, got " + aEvent.axis);
michael@0 1266 }
michael@0 1267 }
michael@0 1268 window.addEventListener("MozMousePixelScroll", handler, true);
michael@0 1269 synthesizeWheel(gScrollableElement, 10, 10,
michael@0 1270 { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1271 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 });
michael@0 1272 // wait scrolled actually.
michael@0 1273 hitEventLoop(function () {
michael@0 1274 var scrolledX = gScrollableElement.scrollLeft;
michael@0 1275 var scrolledY = gScrollableElement.scrollTop;
michael@0 1276 ok(scrolledX > 1000,
michael@0 1277 "doTestZoomedScroll: scrolledX must be larger than 1000 for line wheel event, got " + scrolledX);
michael@0 1278 ok(scrolledY > 1000,
michael@0 1279 "doTestZoomedScroll: scrolledY must be larger than 1000 for line wheel event, got " + scrolledY);
michael@0 1280
michael@0 1281 // Zoom
michael@0 1282 setFullZoom(window, 2.0);
michael@0 1283 // Ensure not to be in reflow.
michael@0 1284 hitEventLoop(function () {
michael@0 1285 gScrollableElement.scrollTop = 1000;
michael@0 1286 gScrollableElement.scrollLeft = 1000;
michael@0 1287 synthesizeWheel(gScrollableElement, 10, 10,
michael@0 1288 { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1289 deltaX: 1.0, deltaY: 1.0, lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 });
michael@0 1290 // wait scrolled actually.
michael@0 1291 hitEventLoop(function () {
michael@0 1292 ok(Math.abs(gScrollableElement.scrollLeft - scrolledX) <= 1,
michael@0 1293 "doTestZoomedScroll: zoomed horizontal scroll amount by line wheel event is different from normal, scrollLeft=" +
michael@0 1294 gScrollableElement.scrollLeft + ", scrolledX=" + scrolledX);
michael@0 1295 ok(Math.abs(gScrollableElement.scrollTop - scrolledY) <= 1,
michael@0 1296 "doTestZoomedScroll: zoomed vertical scroll amount by line wheel event is different from normal, scrollTop=" +
michael@0 1297 gScrollableElement.scrollTop + ", scrolledY=" + scrolledY);
michael@0 1298
michael@0 1299 window.removeEventListener("MozMousePixelScroll", handler, true);
michael@0 1300
michael@0 1301 synthesizeKey("0", { accelKey: true });
michael@0 1302 onZoomReset(aCallback);
michael@0 1303 }, 20);
michael@0 1304 }, 20);
michael@0 1305 }, 20);
michael@0 1306 }, 20);
michael@0 1307 }
michael@0 1308
michael@0 1309 // XXX It's too difficult to test page scroll because the page scroll amount
michael@0 1310 // is computed by complex logic.
michael@0 1311
michael@0 1312 prepareTestZoomedPixelScroll();
michael@0 1313 }
michael@0 1314
michael@0 1315 function doTestWholeScroll(aCallback)
michael@0 1316 {
michael@0 1317 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 99999999);
michael@0 1318 SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 99999999);
michael@0 1319
michael@0 1320 const kTests = [
michael@0 1321 { description: "try whole-scroll to top (line)",
michael@0 1322 prepare: function () {
michael@0 1323 gScrollableElement.scrollTop = 1000;
michael@0 1324 gScrollableElement.scrollLeft = 1000;
michael@0 1325 },
michael@0 1326 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1327 deltaX: 0.0, deltaY: -1.0,
michael@0 1328 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
michael@0 1329 expectedScrollTop: 0,
michael@0 1330 expectedScrollLeft: 1000
michael@0 1331 },
michael@0 1332 { description: "try whole-scroll to top when scrollTop is already top-most (line)",
michael@0 1333 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1334 deltaX: 0.0, deltaY: -1.0,
michael@0 1335 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
michael@0 1336 expectedScrollTop: 0,
michael@0 1337 expectedScrollLeft: 1000
michael@0 1338 },
michael@0 1339 { description: "try whole-scroll to bottom (line)",
michael@0 1340 prepare: function () {
michael@0 1341 gScrollableElement.scrollTop = 1000;
michael@0 1342 gScrollableElement.scrollLeft = 1000;
michael@0 1343 },
michael@0 1344 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1345 deltaX: 0.0, deltaY: 1.0,
michael@0 1346 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
michael@0 1347 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1348 expectedScrollLeft: 1000
michael@0 1349 },
michael@0 1350 { description: "try whole-scroll to bottom when scrollTop is already bottom-most (line)",
michael@0 1351 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1352 deltaX: 0, deltaY: 1.0,
michael@0 1353 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
michael@0 1354 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1355 expectedScrollLeft: 1000
michael@0 1356 },
michael@0 1357 { description: "try whole-scroll to left (line)",
michael@0 1358 prepare: function () {
michael@0 1359 gScrollableElement.scrollTop = 1000;
michael@0 1360 gScrollableElement.scrollLeft = 1000;
michael@0 1361 },
michael@0 1362 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1363 deltaX: -1.0, deltaY: 0.0,
michael@0 1364 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
michael@0 1365 expectedScrollTop: 1000,
michael@0 1366 expectedScrollLeft: 0
michael@0 1367 },
michael@0 1368 { description: "try whole-scroll to left when scrollLeft is already left-most (line)",
michael@0 1369 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1370 deltaX: -1.0, deltaY: 0,
michael@0 1371 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
michael@0 1372 expectedScrollTop: 1000,
michael@0 1373 expectedScrollLeft: 0
michael@0 1374 },
michael@0 1375 { description: "try whole-scroll to right (line)",
michael@0 1376 prepare: function () {
michael@0 1377 gScrollableElement.scrollTop = 1000;
michael@0 1378 gScrollableElement.scrollLeft = 1000;
michael@0 1379 },
michael@0 1380 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1381 deltaX: 1.0, deltaY: 0.0,
michael@0 1382 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
michael@0 1383 expectedScrollTop: 1000,
michael@0 1384 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1385 },
michael@0 1386 { description: "try whole-scroll to right when scrollLeft is already right-most (line)",
michael@0 1387 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1388 deltaX: 1.0, deltaY: 0.0,
michael@0 1389 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
michael@0 1390 expectedScrollTop: 1000,
michael@0 1391 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1392 },
michael@0 1393
michael@0 1394
michael@0 1395 { description: "try whole-scroll to top (pixel)",
michael@0 1396 prepare: function () {
michael@0 1397 gScrollableElement.scrollTop = 1000;
michael@0 1398 gScrollableElement.scrollLeft = 1000;
michael@0 1399 },
michael@0 1400 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1401 deltaX: 0.0, deltaY: -1.0,
michael@0 1402 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1403 expectedScrollTop: 0,
michael@0 1404 expectedScrollLeft: 1000
michael@0 1405 },
michael@0 1406 { description: "try whole-scroll to top when scrollTop is already top-most (pixel)",
michael@0 1407 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1408 deltaX: 0.0, deltaY: -1.0,
michael@0 1409 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1410 expectedScrollTop: 0,
michael@0 1411 expectedScrollLeft: 1000
michael@0 1412 },
michael@0 1413 { description: "try whole-scroll to bottom (pixel)",
michael@0 1414 prepare: function () {
michael@0 1415 gScrollableElement.scrollTop = 1000;
michael@0 1416 gScrollableElement.scrollLeft = 1000;
michael@0 1417 },
michael@0 1418 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1419 deltaX: 0.0, deltaY: 1.0,
michael@0 1420 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1421 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1422 expectedScrollLeft: 1000
michael@0 1423 },
michael@0 1424 { description: "try whole-scroll to bottom when scrollTop is already bottom-most (pixel)",
michael@0 1425 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1426 deltaX: 0, deltaY: 1.0,
michael@0 1427 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1428 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1429 expectedScrollLeft: 1000
michael@0 1430 },
michael@0 1431 { description: "try whole-scroll to left (pixel)",
michael@0 1432 prepare: function () {
michael@0 1433 gScrollableElement.scrollTop = 1000;
michael@0 1434 gScrollableElement.scrollLeft = 1000;
michael@0 1435 },
michael@0 1436 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1437 deltaX: -1.0, deltaY: 0.0,
michael@0 1438 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1439 expectedScrollTop: 1000,
michael@0 1440 expectedScrollLeft: 0
michael@0 1441 },
michael@0 1442 { description: "try whole-scroll to left when scrollLeft is already left-most (pixel)",
michael@0 1443 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1444 deltaX: -1.0, deltaY: 0,
michael@0 1445 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1446 expectedScrollTop: 1000,
michael@0 1447 expectedScrollLeft: 0
michael@0 1448 },
michael@0 1449 { description: "try whole-scroll to right (pixel)",
michael@0 1450 prepare: function () {
michael@0 1451 gScrollableElement.scrollTop = 1000;
michael@0 1452 gScrollableElement.scrollLeft = 1000;
michael@0 1453 },
michael@0 1454 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1455 deltaX: 1.0, deltaY: 0.0,
michael@0 1456 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1457 expectedScrollTop: 1000,
michael@0 1458 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1459 },
michael@0 1460 { description: "try whole-scroll to right when scrollLeft is already right-most (pixel)",
michael@0 1461 event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
michael@0 1462 deltaX: 1.0, deltaY: 0.0,
michael@0 1463 lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
michael@0 1464 expectedScrollTop: 1000,
michael@0 1465 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1466 },
michael@0 1467
michael@0 1468
michael@0 1469 { description: "try whole-scroll to top (page)",
michael@0 1470 prepare: function () {
michael@0 1471 gScrollableElement.scrollTop = 1000;
michael@0 1472 gScrollableElement.scrollLeft = 1000;
michael@0 1473 },
michael@0 1474 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1475 deltaX: 0.0, deltaY: -1.0,
michael@0 1476 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
michael@0 1477 expectedScrollTop: 0,
michael@0 1478 expectedScrollLeft: 1000
michael@0 1479 },
michael@0 1480 { description: "try whole-scroll to top when scrollTop is already top-most (page)",
michael@0 1481 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1482 deltaX: 0.0, deltaY: -1.0,
michael@0 1483 lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
michael@0 1484 expectedScrollTop: 0,
michael@0 1485 expectedScrollLeft: 1000
michael@0 1486 },
michael@0 1487 { description: "try whole-scroll to bottom (page)",
michael@0 1488 prepare: function () {
michael@0 1489 gScrollableElement.scrollTop = 1000;
michael@0 1490 gScrollableElement.scrollLeft = 1000;
michael@0 1491 },
michael@0 1492 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1493 deltaX: 0.0, deltaY: 1.0,
michael@0 1494 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
michael@0 1495 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1496 expectedScrollLeft: 1000
michael@0 1497 },
michael@0 1498 { description: "try whole-scroll to bottom when scrollTop is already bottom-most (page)",
michael@0 1499 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1500 deltaX: 0, deltaY: 1.0,
michael@0 1501 lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
michael@0 1502 expectedScrollTop: gScrollableElement.scrollTopMax,
michael@0 1503 expectedScrollLeft: 1000
michael@0 1504 },
michael@0 1505 { description: "try whole-scroll to left (page)",
michael@0 1506 prepare: function () {
michael@0 1507 gScrollableElement.scrollTop = 1000;
michael@0 1508 gScrollableElement.scrollLeft = 1000;
michael@0 1509 },
michael@0 1510 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1511 deltaX: -1.0, deltaY: 0.0,
michael@0 1512 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
michael@0 1513 expectedScrollTop: 1000,
michael@0 1514 expectedScrollLeft: 0
michael@0 1515 },
michael@0 1516 { description: "try whole-scroll to left when scrollLeft is already left-most (page)",
michael@0 1517 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1518 deltaX: -1.0, deltaY: 0,
michael@0 1519 lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
michael@0 1520 expectedScrollTop: 1000,
michael@0 1521 expectedScrollLeft: 0
michael@0 1522 },
michael@0 1523 { description: "try whole-scroll to right (page)",
michael@0 1524 prepare: function () {
michael@0 1525 gScrollableElement.scrollTop = 1000;
michael@0 1526 gScrollableElement.scrollLeft = 1000;
michael@0 1527 },
michael@0 1528 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1529 deltaX: 1.0, deltaY: 0.0,
michael@0 1530 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
michael@0 1531 expectedScrollTop: 1000,
michael@0 1532 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1533 },
michael@0 1534 { description: "try whole-scroll to right when scrollLeft is already right-most (page)",
michael@0 1535 event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
michael@0 1536 deltaX: 1.0, deltaY: 0.0,
michael@0 1537 lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
michael@0 1538 expectedScrollTop: 1000,
michael@0 1539 expectedScrollLeft: gScrollableElement.scrollLeftMax
michael@0 1540 },
michael@0 1541 ];
michael@0 1542
michael@0 1543 var index = 0;
michael@0 1544
michael@0 1545 function doIt()
michael@0 1546 {
michael@0 1547 const kTest = kTests[index];
michael@0 1548 if (kTest.prepare) {
michael@0 1549 kTest.prepare();
michael@0 1550 }
michael@0 1551 synthesizeWheel(gScrollableElement, 10, 10, kTest.event);
michael@0 1552 hitEventLoop(function () {
michael@0 1553 is(gScrollableElement.scrollTop, kTest.expectedScrollTop,
michael@0 1554 "doTestWholeScroll, " + kTest.description + ": unexpected scrollTop");
michael@0 1555 is(gScrollableElement.scrollLeft, kTest.expectedScrollLeft,
michael@0 1556 "doTestWholeScroll, " + kTest.description + ": unexpected scrollLeft");
michael@0 1557 if (++index == kTests.length) {
michael@0 1558 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
michael@0 1559 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");
michael@0 1560 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_z");
michael@0 1561 SimpleTest.executeSoon(aCallback);
michael@0 1562 } else {
michael@0 1563 doIt();
michael@0 1564 }
michael@0 1565 }, 20);
michael@0 1566 }
michael@0 1567 doIt();
michael@0 1568 }
michael@0 1569
michael@0 1570 function doTestActionOverride(aCallback)
michael@0 1571 {
michael@0 1572 const kNoScroll = 0x00;
michael@0 1573 const kScrollUp = 0x01;
michael@0 1574 const kScrollDown = 0x02;
michael@0 1575 const kScrollLeft = 0x04;
michael@0 1576 const kScrollRight = 0x08;
michael@0 1577
michael@0 1578 const kTests = [
michael@0 1579 { action: 1, override_x: -1,
michael@0 1580 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1581 deltaX: 1.0, deltaY: 1.0,
michael@0 1582 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1583 expected: kScrollDown | kScrollRight
michael@0 1584 },
michael@0 1585 { action: 1, override_x: 0,
michael@0 1586 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1587 deltaX: 1.0, deltaY: 1.0,
michael@0 1588 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1589 expected: kScrollDown | kScrollRight
michael@0 1590 },
michael@0 1591 { action: 1, override_x: 1,
michael@0 1592 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1593 deltaX: 1.0, deltaY: 1.0,
michael@0 1594 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1595 expected: kScrollDown | kScrollRight
michael@0 1596 },
michael@0 1597 { action: 0, override_x: -1,
michael@0 1598 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1599 deltaX: 1.0, deltaY: 1.0,
michael@0 1600 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1601 expected: kNoScroll
michael@0 1602 },
michael@0 1603 { action: 0, override_x: 0,
michael@0 1604 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1605 deltaX: 1.0, deltaY: 1.0,
michael@0 1606 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1607 expected: kNoScroll
michael@0 1608 },
michael@0 1609 { action: 0, override_x: 1,
michael@0 1610 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1611 deltaX: 1.0, deltaY: 1.0,
michael@0 1612 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1613 expected: kNoScroll
michael@0 1614 },
michael@0 1615 { action: 1, override_x: -1,
michael@0 1616 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1617 deltaX: 1.0, deltaY: 0.5,
michael@0 1618 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1619 expected: kScrollDown | kScrollRight
michael@0 1620 },
michael@0 1621 { action: 1, override_x: 0,
michael@0 1622 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1623 deltaX: 1.0, deltaY: 0.5,
michael@0 1624 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1625 expected: kNoScroll
michael@0 1626 },
michael@0 1627 { action: 1, override_x: 1,
michael@0 1628 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1629 deltaX: 1.0, deltaY: 0.5,
michael@0 1630 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1631 expected: kScrollDown | kScrollRight
michael@0 1632 },
michael@0 1633 { action: 0, override_x: -1,
michael@0 1634 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1635 deltaX: 1.0, deltaY: 0.5,
michael@0 1636 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1637 expected: kNoScroll
michael@0 1638 },
michael@0 1639 { action: 0, override_x: 0,
michael@0 1640 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1641 deltaX: 1.0, deltaY: 0.5,
michael@0 1642 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1643 expected: kNoScroll
michael@0 1644 },
michael@0 1645 { action: 0, override_x: 1,
michael@0 1646 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1647 deltaX: 1.0, deltaY: 0.5,
michael@0 1648 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1649 expected: kScrollDown | kScrollRight
michael@0 1650 },
michael@0 1651 { action: 1, override_x: -1,
michael@0 1652 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1653 deltaX: 0.5, deltaY: 1.0,
michael@0 1654 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1655 expected: kScrollDown | kScrollRight
michael@0 1656 },
michael@0 1657 { action: 1, override_x: 0,
michael@0 1658 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1659 deltaX: 0.5, deltaY: 1.0,
michael@0 1660 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1661 expected: kScrollDown | kScrollRight
michael@0 1662 },
michael@0 1663 { action: 1, override_x: 1,
michael@0 1664 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1665 deltaX: 0.5, deltaY: 1.0,
michael@0 1666 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1667 expected: kScrollDown | kScrollRight
michael@0 1668 },
michael@0 1669 { action: 0, override_x: -1,
michael@0 1670 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1671 deltaX: 0.5, deltaY: 1.0,
michael@0 1672 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1673 expected: kNoScroll
michael@0 1674 },
michael@0 1675 { action: 0, override_x: 0,
michael@0 1676 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1677 deltaX: 0.5, deltaY: 1.0,
michael@0 1678 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1679 expected: kNoScroll
michael@0 1680 },
michael@0 1681 { action: 0, override_x: 1,
michael@0 1682 event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
michael@0 1683 deltaX: 0.5, deltaY: 1.0,
michael@0 1684 lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
michael@0 1685 expected: kNoScroll
michael@0 1686 },
michael@0 1687 ];
michael@0 1688
michael@0 1689 var index = 0;
michael@0 1690
michael@0 1691 function doIt()
michael@0 1692 {
michael@0 1693 const kTest = kTests[index];
michael@0 1694 description = "doTestActionOverride(action=" + kTest.action + ", " +
michael@0 1695 "override_x=" + kTest.override_x + ", " +
michael@0 1696 "deltaX=" + kTest.event.deltaX + ", " +
michael@0 1697 "deltaY=" + kTest.event.deltaY + "): ";
michael@0 1698 SpecialPowers.setIntPref("mousewheel.default.action", kTest.action);
michael@0 1699 SpecialPowers.setIntPref("mousewheel.default.action.override_x", kTest.override_x);
michael@0 1700 gScrollableElement.scrollTop = 1000;
michael@0 1701 gScrollableElement.scrollLeft = 1000;
michael@0 1702 synthesizeWheel(gScrollableElement, 10, 10, kTest.event);
michael@0 1703 hitEventLoop(function () {
michael@0 1704 if (kTest.expected & kScrollUp) {
michael@0 1705 ok(gScrollableElement.scrollTop < 1000, description + "not scrolled up, got " + gScrollableElement.scrollTop);
michael@0 1706 } else if (kTest.expected & kScrollDown) {
michael@0 1707 ok(gScrollableElement.scrollTop > 1000, description + "not scrolled down, got " + gScrollableElement.scrollTop);
michael@0 1708 } else {
michael@0 1709 is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
michael@0 1710 }
michael@0 1711 if (kTest.expected & kScrollLeft) {
michael@0 1712 ok(gScrollableElement.scrollLeft < 1000, description + "not scrolled to left, got " + gScrollableElement.scrollLeft);
michael@0 1713 } else if (kTest.expected & kScrollRight) {
michael@0 1714 ok(gScrollableElement.scrollLeft > 1000, description + "not scrolled to right, got " + gScrollableElement.scrollLeft);
michael@0 1715 } else {
michael@0 1716 is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
michael@0 1717 }
michael@0 1718 if (++index == kTests.length) {
michael@0 1719 SpecialPowers.setIntPref("mousewheel.default.action", 1);
michael@0 1720 SpecialPowers.setIntPref("mousewheel.default.action.override_x", -1);
michael@0 1721 SimpleTest.executeSoon(aCallback);
michael@0 1722 } else {
michael@0 1723 doIt();
michael@0 1724 }
michael@0 1725 }, 20);
michael@0 1726 }
michael@0 1727 doIt();
michael@0 1728 }
michael@0 1729
michael@0 1730 function runTests()
michael@0 1731 {
michael@0 1732 SpecialPowers.setBoolPref("general.smoothScroll", false);
michael@0 1733
michael@0 1734 SpecialPowers.setIntPref("mousewheel.default.action", 1); // scroll
michael@0 1735 SpecialPowers.setIntPref("mousewheel.default.action.override_x", -1);
michael@0 1736 SpecialPowers.setIntPref("mousewheel.with_shift.action", 2); // history
michael@0 1737 SpecialPowers.setIntPref("mousewheel.with_shift.action.override_x", -1);
michael@0 1738 SpecialPowers.setIntPref("mousewheel.with_control.action", 3); // zoom
michael@0 1739 SpecialPowers.setIntPref("mousewheel.with_control.action.override_x", -1);
michael@0 1740
michael@0 1741 const kSettings = [
michael@0 1742 { description: "all delta values are not customized",
michael@0 1743 deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
michael@0 1744 { description: "deltaX is reverted",
michael@0 1745 deltaMultiplierX: -1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
michael@0 1746 { description: "deltaY is reverted",
michael@0 1747 deltaMultiplierX: 1.0, deltaMultiplierY: -1.0, deltaMultiplierZ: 1.0 },
michael@0 1748 { description: "deltaZ is reverted",
michael@0 1749 deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: -1.0 },
michael@0 1750 { description: "deltaX is 2.0",
michael@0 1751 deltaMultiplierX: 2.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
michael@0 1752 { description: "deltaY is 2.0",
michael@0 1753 deltaMultiplierX: 1.0, deltaMultiplierY: 2.0, deltaMultiplierZ: 1.0 },
michael@0 1754 { description: "deltaZ is 2.0",
michael@0 1755 deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 2.0 },
michael@0 1756 { description: "deltaX is -2.0",
michael@0 1757 deltaMultiplierX: -2.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
michael@0 1758 { description: "deltaY is -2.0",
michael@0 1759 deltaMultiplierX: 1.0, deltaMultiplierY: -2.0, deltaMultiplierZ: 1.0 },
michael@0 1760 { description: "deltaZ is -2.0",
michael@0 1761 deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: -2.0 },
michael@0 1762 ];
michael@0 1763
michael@0 1764 var index = 0;
michael@0 1765
michael@0 1766 function doTest() {
michael@0 1767 setDeltaMultiplierSettings(kSettings[index]);
michael@0 1768 doTestScroll(kSettings[index], function () {
michael@0 1769 doTestZoom(kSettings[index], function() {
michael@0 1770 if (++index == kSettings.length) {
michael@0 1771 setDeltaMultiplierSettings(kSettings[0]);
michael@0 1772 doTestZoomedScroll(function() {
michael@0 1773 doTestWholeScroll(function() {
michael@0 1774 doTestActionOverride(function() {
michael@0 1775 finishTests();
michael@0 1776 });
michael@0 1777 });
michael@0 1778 });
michael@0 1779 } else {
michael@0 1780 doTest();
michael@0 1781 }
michael@0 1782 });
michael@0 1783 });
michael@0 1784 }
michael@0 1785 doTest();
michael@0 1786 }
michael@0 1787
michael@0 1788 function finishTests()
michael@0 1789 {
michael@0 1790 SpecialPowers.clearUserPref("general.smoothScroll");
michael@0 1791
michael@0 1792 SpecialPowers.clearUserPref("mousewheel.default.action");
michael@0 1793 SpecialPowers.clearUserPref("mousewheel.default.action.override_x");
michael@0 1794 SpecialPowers.clearUserPref("mousewheel.with_shift.action");
michael@0 1795 SpecialPowers.clearUserPref("mousewheel.with_shift.action.override_x");
michael@0 1796 SpecialPowers.clearUserPref("mousewheel.with_control.action");
michael@0 1797 SpecialPowers.clearUserPref("mousewheel.with_control.action.override_x");
michael@0 1798
michael@0 1799 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
michael@0 1800 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");
michael@0 1801 SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_z");
michael@0 1802 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_x");
michael@0 1803 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_y");
michael@0 1804 SpecialPowers.clearUserPref("mousewheel.with_alt.delta_multiplier_z");
michael@0 1805 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_x");
michael@0 1806 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_y");
michael@0 1807 SpecialPowers.clearUserPref("mousewheel.with_control.delta_multiplier_z");
michael@0 1808 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_x");
michael@0 1809 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_y");
michael@0 1810 SpecialPowers.clearUserPref("mousewheel.with_meta.delta_multiplier_z");
michael@0 1811 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_x");
michael@0 1812 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_y");
michael@0 1813 SpecialPowers.clearUserPref("mousewheel.with_shift.delta_multiplier_z");
michael@0 1814 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_x");
michael@0 1815 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_y");
michael@0 1816 SpecialPowers.clearUserPref("mousewheel.with_win.delta_multiplier_z");
michael@0 1817
michael@0 1818 winUtils.restoreNormalRefresh();
michael@0 1819
michael@0 1820 window.opener.finish();
michael@0 1821 }
michael@0 1822
michael@0 1823 </script>
michael@0 1824 </pre>
michael@0 1825 </body>
michael@0 1826 </html>

mercurial