1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849 |
- <!DOCTYPE HTML>
- <html>
- <head>
- <title>Test for default action of WheelEvent</title>
- <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
- <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
- <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
- </head>
- <body>
- <p id="display"></p>
- <div id="scrollable" style="overflow: auto; width: 200px; height: 200px;">
- <div id="clipper" style="margin: 0; padding: 0; overflow: hidden; width: 3000px; height: 3000px;">
- <div id="scrolled" style="width: 5000px; height: 5000px;">
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- 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>
- </div>
- </div>
- </div>
- <div id="spacerForBody"></div>
- <div id="content" style="display: none">
- </div>
- <pre id="test">
- <script type="application/javascript">
- SimpleTest.waitForFocus(runTests, window);
- SimpleTest.requestFlakyTimeout("untriaged");
- var winUtils = SpecialPowers.getDOMWindowUtils(window);
- // grab refresh driver
- winUtils.advanceTimeAndRefresh(100);
- var gScrollableElement = document.getElementById("scrollable");
- var gScrolledElement = document.getElementById("scrolled");
- var gSpacerForBodyElement = document.getElementById("spacerForBody");
- function is()
- {
- window.opener.is.apply(window.opener, arguments);
- }
- function ok()
- {
- window.opener.ok.apply(window.opener, arguments);
- }
- function sendWheelAndWait(aX, aY, aEvent, aCallback)
- {
- sendWheelAndPaint(gScrollableElement, aX, aY, aEvent, aCallback);
- }
- function hitEventLoop(aFunc, aTimes)
- {
- winUtils.advanceTimeAndRefresh(100);
- if (--aTimes) {
- setTimeout(hitEventLoop, 0, aFunc, aTimes);
- } else {
- setTimeout(aFunc, 20);
- }
- }
- const zoomResetTopic = "browser-fullZoom:zoomReset";
- SpecialPowers.registerObservers(zoomResetTopic);
- function onZoomReset(aCallback) {
- var specialPowersTopic = "specialpowers-" + zoomResetTopic;
- SpecialPowers.addObserver(function observe() {
- SpecialPowers.removeObserver(observe, specialPowersTopic);
- SimpleTest.executeSoon(aCallback);
- }, specialPowersTopic, false);
- }
- function setDeltaMultiplierSettings(aSettings, aCallback)
- {
- SpecialPowers.pushPrefEnv({"set": [
- ["mousewheel.default.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.default.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.default.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
- ["mousewheel.with_alt.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.with_alt.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.with_alt.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
- ["mousewheel.with_control.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.with_control.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.with_control.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
- ["mousewheel.with_meta.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.with_meta.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.with_meta.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
- ["mousewheel.with_shift.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.with_shift.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.with_shift.delta_multiplier_z", aSettings.deltaMultiplierZ * 100],
- ["mousewheel.with_win.delta_multiplier_x", aSettings.deltaMultiplierX * 100],
- ["mousewheel.with_win.delta_multiplier_y", aSettings.deltaMultiplierY * 100],
- ["mousewheel.with_win.delta_multiplier_z", aSettings.deltaMultiplierZ * 100]
- ]}, aCallback);
- }
- function doTestScroll(aSettings, aCallback)
- {
- const kNoScroll = 0x00;
- const kScrollUp = 0x01;
- const kScrollDown = 0x02;
- const kScrollLeft = 0x04;
- const kScrollRight = 0x08;
- const kTests = [
- { description: "Scroll to bottom by pixel scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to bottom by pixel scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to top by pixel scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to top by pixel scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to right by pixel scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to right by pixel scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to left by pixel scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to left by pixel scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to bottom-right by pixel scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollRight },
- { description: "Scroll to bottom-left by pixel scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollLeft },
- { description: "Scroll to top-left by pixel scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollLeft },
- { description: "Scroll to top-right by pixel scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollRight },
- { description: "Not Scroll by pixel scroll for z",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Scroll to bottom by line scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to bottom by line scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to top by line scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to top by line scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to right by line scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to right by line scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to left by line scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to left by line scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to bottom-right by line scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollRight },
- { description: "Scroll to bottom-left by line scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollLeft },
- { description: "Scroll to top-left by line scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollLeft },
- { description: "Scroll to top-right by line scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollRight },
- { description: "Not Scroll by line scroll for z",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Scroll to bottom by page scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to bottom by page scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to top by page scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to top by page scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to right by page scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to right by page scroll when lineOrPageDelta is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to left by page scroll even if lineOrPageDelta is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to left by page scroll when lineOrPageDelta is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to bottom-right by page scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollRight },
- { description: "Scroll to bottom-left by page scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollLeft },
- { description: "Scroll to top-left by page scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollLeft },
- { description: "Scroll to top-right by page scroll",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollRight },
- { description: "Not Scroll by page scroll for z",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: false,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- // special cases.
- // momentum scroll should cause scroll even if the action is zoom, but if the default action is none,
- // shouldn't do it.
- { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 1, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is -1, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 1, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is 0, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is -1, even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to bottom-right by momentum pixel scroll even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollRight },
- { description: "Scroll to bottom-left by momentum pixel scroll even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollLeft },
- { description: "Scroll to top-left by momentum pixel scroll even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollLeft },
- { description: "Scroll to top-right by momentum pixel scroll even if the action is zoom",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollRight },
- { description: "Not Scroll by momentum pixel scroll for z (action is zoom)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Not Scroll by momentum pixel scroll if default action is none (action is zoom)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: true, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll,
- prepare: function (cb) { SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.action", 0]]}, cb); },
- cleanup: function (cb) { SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.action", 1]]}, cb); } },
- // momentum scroll should cause scroll even if the action is history, but if the default action is none,
- // shouldn't do it.
- { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to bottom by momentum pixel scroll when lineOrPageDelta is 1, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to top by momentum pixel scroll when lineOrPageDelta is -1, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to right by momentum pixel scroll when lineOrPageDelta is 1, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is 0, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to left by momentum pixel scroll when lineOrPageDelta is -1, even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to bottom-right by momentum pixel scroll even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollRight },
- { description: "Scroll to bottom-left by momentum pixel scroll even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown | kScrollLeft },
- { description: "Scroll to top-left by momentum pixel scroll even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollLeft },
- { description: "Scroll to top-right by momentum pixel scroll even if the action is history",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp | kScrollRight },
- { description: "Not Scroll by momentum pixel scroll for z (action is history)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Not Scroll by momentum pixel scroll if default action is none (action is history)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0, isMomentum: true,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: true, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll,
- prepare: function (cb) { SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.action", 0]]}, cb); },
- cleanup: function (cb) { SpecialPowers.pushPrefEnv({"set": [["mousewheel.default.action", 1]]}, cb); } },
- // Don't scroll along axis whose overflow style is hidden.
- { description: "Scroll to only bottom by oblique pixel wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown,
- prepare: function(cb) { gScrollableElement.style.overflowX = "hidden"; cb(); } },
- { description: "Scroll to only bottom by oblique line wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to only bottom by oblique page wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to only top by oblique pixel wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to only top by oblique line wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to only top by oblique page wheel event with overflow-x: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp,
- cleanup: function (cb) { gScrollableElement.style.overflowX = "auto"; cb(); } },
- { description: "Scroll to only right by oblique pixel wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight,
- prepare: function(cb) { gScrollableElement.style.overflowY = "hidden"; cb(); } },
- { description: "Scroll to only right by oblique line wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to only right by oblique page wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to only left by oblique pixel wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to only top by oblique line wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to only top by oblique page wheel event with overflow-y: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft,
- cleanup: function (cb) { gScrollableElement.style.overflowY = "auto"; cb(); } },
- { description: "Don't be scrolled by oblique pixel wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll,
- prepare: function(cb) { gScrollableElement.style.overflow = "hidden"; cb(); } },
- { description: "Don't be scrolled by oblique line wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Don't be scrolled by oblique page wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 1, expectedOverflowDeltaY: 1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Don't be scrolled by oblique pixel wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Don't be scrolled by oblique line wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll },
- { description: "Don't be scrolled by oblique page wheel event with overflow: hidden",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: -1, expectedOverflowDeltaY: -1,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kNoScroll,
- cleanup: function (cb) { gScrollableElement.style.overflow = "auto"; cb(); } },
- // Don't scroll along axis whose overflow style is hidden and overflow delta values should
- // be zero if there is ancestor scrollable element.
- { description: "Scroll to only bottom by oblique pixel wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown,
- prepare: function(cb) {
- gScrollableElement.style.overflowX = "hidden";
- gScrollableElement.style.position = "fixed";
- gScrollableElement.style.top = "30px";
- gScrollableElement.style.left = "30px";
- // Make body element scrollable.
- gSpacerForBodyElement.style.width = "5000px";
- gSpacerForBodyElement.style.height = "5000px";
- document.documentElement.scrollTop = 500;
- document.documentElement.scrollLeft = 500;
- cb();
- } },
- { description: "Scroll to only bottom by oblique line wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to only bottom by oblique page wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollDown },
- { description: "Scroll to only top by oblique pixel wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to only top by oblique line wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp },
- { description: "Scroll to only top by oblique page wheel event with overflow-x: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollUp,
- cleanup: function (cb) { gScrollableElement.style.overflowX = "auto"; cb(); } },
- { description: "Scroll to only right by oblique pixel wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0, deltaY: 16.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight,
- prepare: function(cb) { gScrollableElement.style.overflowY = "hidden"; cb(); } },
- { description: "Scroll to only right by oblique line wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to only right by oblique page wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 1.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollRight },
- { description: "Scroll to only left by oblique pixel wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -16.0, deltaY: -16.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to only top by oblique line wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft },
- { description: "Scroll to only top by oblique page wheel event with overflow-y: hidden (body is scrollable)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: -1.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
- shiftKey: false, ctrlKey: false, altKey: false, metaKey: false, osKey: false },
- expected: kScrollLeft,
- cleanup: function (cb) {
- gScrollableElement.style.overflowY = "auto";
- gScrollableElement.style.position = "static";
- gSpacerForBodyElement.style.width = "";
- gSpacerForBodyElement.style.height = "";
- cb();
- } },
- ];
- var description;
- var currentTestIndex = -1;
- var isXReverted = (aSettings.deltaMultiplierX < 0);
- var isYReverted = (aSettings.deltaMultiplierY < 0);
- function doNextTest()
- {
- if (++currentTestIndex >= kTests.length) {
- SimpleTest.executeSoon(aCallback);
- return;
- }
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- var currentTest = kTests[currentTestIndex];
- description = "doTestScroll(aSettings=" + aSettings.description + "), " + currentTest.description + ": ";
- if (currentTest.prepare) {
- currentTest.prepare(doTestCurrentScroll);
- } else {
- doTestCurrentScroll();
- }
- }
- function doTestCurrentScroll() {
- var currentTest = kTests[currentTestIndex];
- sendWheelAndWait(10, 10, currentTest.event, function () {
- if (currentTest.expected == kNoScroll) {
- is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
- is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
- } else {
- var scrollUp = !isYReverted ? (currentTest.expected & kScrollUp) :
- (currentTest.expected & kScrollDown);
- var scrollDown = !isYReverted ? (currentTest.expected & kScrollDown) :
- (currentTest.expected & kScrollUp);
- if (scrollUp) {
- ok(gScrollableElement.scrollTop < 1000, description + "not scrolled up, got " + gScrollableElement.scrollTop);
- } else if (scrollDown) {
- ok(gScrollableElement.scrollTop > 1000, description + "not scrolled down, got " + gScrollableElement.scrollTop);
- } else {
- is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
- }
- var scrollLeft = !isXReverted ? (currentTest.expected & kScrollLeft) :
- (currentTest.expected & kScrollRight);
- var scrollRight = !isXReverted ? (currentTest.expected & kScrollRight) :
- (currentTest.expected & kScrollLeft);
- if (scrollLeft) {
- ok(gScrollableElement.scrollLeft < 1000, description + "not scrolled to left, got " + gScrollableElement.scrollLeft);
- } else if (scrollRight) {
- ok(gScrollableElement.scrollLeft > 1000, description + "not scrolled to right, got " + gScrollableElement.scrollLeft);
- } else {
- is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
- }
- }
- if (currentTest.cleanup) {
- currentTest.cleanup(nextStep);
- } else {
- nextStep();
- }
- function nextStep() {
- winUtils.advanceTimeAndRefresh(100);
- doNextTest();
- }
- });
- }
- doNextTest();
- }
- function doTestZoom(aSettings, aCallback)
- {
- if ((aSettings.deltaMultiplierX != 1.0 && aSettings.deltaMultiplierX != -1.0) ||
- (aSettings.deltaMultiplierY != 1.0 && aSettings.deltaMultiplierY != -1.0)) {
- todo(false, "doTestZoom doesn't support to test with aSettings=" + aSettings.description);
- SimpleTest.executeSoon(aCallback);
- return;
- }
- const kNone = 0x00;
- const kPositive = 0x01;
- const kNegative = 0x02;
- const kUseX = 0x10;
- const kUseY = 0x20;
- const kTests = [
- { description: "by vertical/positive pixel event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/positive pixel event when its lineOrPageDeltaY is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseY },
- { description: "by vertical/negative pixel event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/negative pixel event when its lineOrPageDeltaY is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -8.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseY },
- { description: "by horizotal/positive pixel event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/positive pixel event when its lineOrPageDeltaX is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseX },
- { description: "by horizotal/negative pixel event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/negative pixel event when its lineOrPageDeltaX is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -8.0, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseX },
- { description: "by z pixel event",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 16.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/positive line event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/positive line event when its lineOrPageDeltaY is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseY },
- { description: "by vertical/negative line event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/negative line event when its lineOrPageDeltaY is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseY },
- { description: "by horizotal/positive line event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/positive line event when its lineOrPageDeltaX is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseX },
- { description: "by horizotal/negative line event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/negative line event when its lineOrPageDeltaX is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseX },
- { description: "by z line event",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/positive page event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/positive page event when its lineOrPageDeltaY is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseY },
- { description: "by vertical/negative page event when its lineOrPageDeltaY is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by vertical/negative page event when its lineOrPageDeltaY is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: -0.5, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseY },
- { description: "by horizotal/positive page event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/positive page event when its lineOrPageDeltaX is 1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kPositive | kUseX },
- { description: "by horizotal/negative page event when its lineOrPageDeltaX is 0",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- { description: "by horizotal/negative page event when its lineOrPageDeltaX is -1",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -0.5, deltaY: 0.0, deltaZ: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNegative | kUseX },
- { description: "by z page event",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 0.0, deltaZ: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0,
- expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0 },
- expected: kNone },
- ];
- var description, currentTest;
- var currentTestIndex = -1;
- var isXReverted = (aSettings.deltaMultiplierX < 0);
- var isYReverted = (aSettings.deltaMultiplierY < 0);
- function doNextTest()
- {
- if (++currentTestIndex >= kTests.length) {
- SimpleTest.executeSoon(aCallback);
- return;
- }
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- currentTest = kTests[currentTestIndex];
- description = "doTestZoom(aSettings=" + aSettings.description + "), ";
- if (currentTest.expected == kNone) {
- description += "Shouldn't ";
- } else {
- description += "Should ";
- }
- description += "zoom " + currentTest.description + ": ";
- var event = currentTest.event;
- event.ctrlKey = true;
- // NOTE: Zooming might change scrollTop and scrollLeft by rounding fraction.
- // This test assume that zoom happens synchronously and scrolling
- // happens asynchronously.
- var scrollTop = gScrollableElement.scrollTop;
- var scrollLeft = gScrollableElement.scrollLeft;
- sendWheelAndWait(10, 10, event, function () {
- is(gScrollableElement.scrollTop, scrollTop, description + "scrolled vertical");
- is(gScrollableElement.scrollLeft, scrollLeft, description + "scrolled horizontal");
- if (!(currentTest.expected & (kNegative | kPositive))) {
- is(SpecialPowers.getFullZoom(window), 1.0, description + "zoomed");
- } else {
- var isReverted = (currentTest.expected & kUseX) ? isXReverted :
- (currentTest.expected & kUseY) ? isYReverted : false;
- if ((!isReverted && (currentTest.expected & kNegative)) ||
- (isReverted && (currentTest.expected & kPositive))) {
- ok(SpecialPowers.getFullZoom(window) > 1.0,
- description + "not zoomed in, got " + SpecialPowers.getFullZoom(window));
- } else {
- ok(SpecialPowers.getFullZoom(window) < 1.0,
- description + "not zoomed out, got " + SpecialPowers.getFullZoom(window));
- }
- }
- synthesizeKey("0", { accelKey: true });
- onZoomReset(function () {
- hitEventLoop(doNextTest, 20);
- });
- });
- }
- doNextTest();
- }
- function doTestZoomedScroll(aCallback)
- {
- var zoom = 1.0;
- function setFullZoom(aWindow, aZoom)
- {
- zoom = aZoom;
- SpecialPowers.setFullZoom(aWindow, aZoom);
- }
- function prepareTestZoomedPixelScroll()
- {
- // Reset zoom and store the scroll amount into the data.
- synthesizeKey("0", { accelKey: true });
- zoom = 1.0;
- onZoomReset(testZoomedPixelScroll);
- }
- function testZoomedPixelScroll()
- {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- // Ensure not to be in reflow.
- hitEventLoop(function () {
- function mousePixelScrollHandler(aEvent)
- {
- if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
- is(aEvent.detail, 16,
- "doTestZoomedScroll: The detail of horizontal MozMousePixelScroll for pixel wheel event is wrong");
- } else if (aEvent.axis == MouseScrollEvent.VERTICAL_AXIS) {
- is(aEvent.detail, 16,
- "doTestZoomedScroll: The detail of vertical MozMousePixelScroll for pixel wheel event is wrong");
- } else {
- ok(false, "doTestZoomedScroll: The axis of MozMousePixelScroll for pixel wheel event is invalid, got " + aEvent.axis);
- }
- }
- function wheelHandler(aEvent)
- {
- is(aEvent.deltaX, 16.0 / zoom,
- "doTestZoomedScroll: The deltaX of wheel for pixel is wrong");
- is(aEvent.deltaY, 16.0 / zoom,
- "doTestZoomedScroll: The deltaY of wheel for pixel is wrong");
- }
- window.addEventListener("MozMousePixelScroll", mousePixelScrollHandler, true);
- window.addEventListener("wheel", wheelHandler, true);
- var event = {
- deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0,
- deltaY: 16.0,
- lineOrPageDeltaX: 0,
- lineOrPageDeltaY: 0
- };
- // wait scrolled actually.
- sendWheelAndWait(10, 10, event, function () {
- var scrolledX = gScrollableElement.scrollLeft;
- var scrolledY = gScrollableElement.scrollTop;
- ok(scrolledX > 1000,
- "doTestZoomedScroll: scrolledX must be larger than 1000 for pixel wheel event, got " + scrolledX);
- ok(scrolledY > 1000,
- "doTestZoomedScroll: scrolledY must be larger than 1000 for pixel wheel event, got " + scrolledY);
- // Zoom
- setFullZoom(window, 2.0);
- // Ensure not to be in reflow.
- hitEventLoop(function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- var event = {
- deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 16.0,
- deltaY: 16.0,
- lineOrPageDeltaX: 0,
- lineOrPageDeltaY: 0
- };
- // wait scrolled actually.
- sendWheelAndWait(10, 10, event, function () {
- ok(Math.abs(gScrollableElement.scrollLeft - (1000 + (scrolledX - 1000) / 2)) <= 1,
- "doTestZoomedScroll: zoomed horizontal scroll amount by pixel wheel event is different from normal, scrollLeft=" +
- gScrollableElement.scrollLeft + ", scrolledX=" + scrolledX);
- ok(Math.abs(gScrollableElement.scrollTop - (1000 + (scrolledY - 1000) / 2)) <= 1,
- "doTestZoomedScroll: zoomed vertical scroll amount by pixel wheel event is different from normal, scrollTop=" +
- gScrollableElement.scrollTop + ", scrolledY=" + scrolledY);
- window.removeEventListener("MozMousePixelScroll", mousePixelScrollHandler, true);
- window.removeEventListener("wheel", wheelHandler, true);
- synthesizeKey("0", { accelKey: true });
- onZoomReset(prepareTestZoomedLineScroll);
- });
- }, 20);
- });
- }, 20);
- }
- function prepareTestZoomedLineScroll()
- {
- // Reset zoom and store the scroll amount into the data.
- synthesizeKey("0", { accelKey: true });
- zoom = 1.0;
- onZoomReset(testZoomedLineScroll);
- }
- function testZoomedLineScroll()
- {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- // Ensure not to be in reflow.
- hitEventLoop(function () {
- var lineHeightX, lineHeightY;
- function handler(aEvent)
- {
- if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
- if (lineHeightX == undefined) {
- lineHeightX = aEvent.detail;
- } else {
- ok(Math.abs(aEvent.detail - lineHeightX) <= 1,
- "doTestZoomedScroll: The detail of horizontal MozMousePixelScroll for line wheel event is wrong, aEvent.detail=" +
- aEvent.detail + ", lineHeightX=" + lineHeightX);
- }
- } else if (aEvent.axis == MouseScrollEvent.VERTICAL_AXIS) {
- if (lineHeightY == undefined) {
- lineHeightY = aEvent.detail;
- } else {
- ok(Math.abs(aEvent.detail - lineHeightY) <= 1,
- "doTestZoomedScroll: The detail of vertical MozMousePixelScroll for line wheel event is wrong, aEvent.detail=" +
- aEvent.detail + ", lineHeightY=" + lineHeightY);
- }
- } else {
- ok(false, "doTestZoomedScroll: The axis of MozMousePixelScroll for line wheel event is invalid, got " + aEvent.axis);
- }
- }
- window.addEventListener("MozMousePixelScroll", handler, true);
- var event = {
- deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0,
- deltaY: 1.0,
- lineOrPageDeltaX: 1,
- lineOrPageDeltaY: 1
- };
- // wait scrolled actually.
- sendWheelAndWait(10, 10, event, function () {
- var scrolledX = gScrollableElement.scrollLeft;
- var scrolledY = gScrollableElement.scrollTop;
- ok(scrolledX > 1000,
- "doTestZoomedScroll: scrolledX must be larger than 1000 for line wheel event, got " + scrolledX);
- ok(scrolledY > 1000,
- "doTestZoomedScroll: scrolledY must be larger than 1000 for line wheel event, got " + scrolledY);
- // Zoom
- setFullZoom(window, 2.0);
- // Ensure not to be in reflow.
- hitEventLoop(function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- var event = {
- deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0,
- deltaY: 1.0,
- lineOrPageDeltaX: 1,
- lineOrPageDeltaY: 1
- };
- // wait scrolled actually.
- sendWheelAndWait(10, 10, event, function () {
- ok(Math.abs(gScrollableElement.scrollLeft - scrolledX) <= 1,
- "doTestZoomedScroll: zoomed horizontal scroll amount by line wheel event is different from normal, scrollLeft=" +
- gScrollableElement.scrollLeft + ", scrolledX=" + scrolledX);
- ok(Math.abs(gScrollableElement.scrollTop - scrolledY) <= 1,
- "doTestZoomedScroll: zoomed vertical scroll amount by line wheel event is different from normal, scrollTop=" +
- gScrollableElement.scrollTop + ", scrolledY=" + scrolledY);
- window.removeEventListener("MozMousePixelScroll", handler, true);
- synthesizeKey("0", { accelKey: true });
- onZoomReset(aCallback);
- });
- }, 20);
- });
- }, 20);
- }
- // XXX It's too difficult to test page scroll because the page scroll amount
- // is computed by complex logic.
- prepareTestZoomedPixelScroll();
- }
- function doTestWholeScroll(aCallback)
- {
- SpecialPowers.pushPrefEnv({"set": [
- ["mousewheel.default.delta_multiplier_x", 999999],
- ["mousewheel.default.delta_multiplier_y", 999999]]},
- function() { doTestWholeScroll2(aCallback); });
- }
- function doTestWholeScroll2(aCallback)
- {
- const kTests = [
- { description: "try whole-scroll to top (line)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to top when scrollTop is already top-most (line)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom (line)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom when scrollTop is already bottom-most (line)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to left (line)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to left when scrollLeft is already left-most (line)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: -1.0, deltaY: 0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to right (line)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- { description: "try whole-scroll to right when scrollLeft is already right-most (line)",
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- { description: "try whole-scroll to top (pixel)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to top when scrollTop is already top-most (pixel)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom (pixel)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0.0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom when scrollTop is already bottom-most (pixel)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to left (pixel)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -1.0, deltaY: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to left when scrollLeft is already left-most (pixel)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: -1.0, deltaY: 0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to right (pixel)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- { description: "try whole-scroll to right when scrollLeft is already right-most (pixel)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PIXEL,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- { description: "try whole-scroll to top (page)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to top when scrollTop is already top-most (page)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: -1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: -1 },
- expectedScrollTop: 0,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom (page)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0.0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to bottom when scrollTop is already bottom-most (page)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 0, deltaY: 1.0,
- lineOrPageDeltaX: 0, lineOrPageDeltaY: 1 },
- expectedScrollTop: gScrollableElement.scrollTopMax,
- expectedScrollLeft: 1000
- },
- { description: "try whole-scroll to left (page)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: 0.0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to left when scrollLeft is already left-most (page)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: -1.0, deltaY: 0,
- lineOrPageDeltaX: -1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: 0
- },
- { description: "try whole-scroll to right (page)",
- prepare: function () {
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- },
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- { description: "try whole-scroll to right when scrollLeft is already right-most (page)",
- event: { deltaMode: WheelEvent.DOM_DELTA_PAGE,
- deltaX: 1.0, deltaY: 0.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 0 },
- expectedScrollTop: 1000,
- expectedScrollLeft: gScrollableElement.scrollLeftMax
- },
- ];
- var index = 0;
- function doIt()
- {
- const kTest = kTests[index];
- if (kTest.prepare) {
- kTest.prepare();
- }
- sendWheelAndWait(10, 10, kTest.event, function () {
- is(gScrollableElement.scrollTop, kTest.expectedScrollTop,
- "doTestWholeScroll, " + kTest.description + ": unexpected scrollTop");
- is(gScrollableElement.scrollLeft, kTest.expectedScrollLeft,
- "doTestWholeScroll, " + kTest.description + ": unexpected scrollLeft");
- if (++index == kTests.length) {
- SimpleTest.executeSoon(aCallback);
- } else {
- doIt();
- }
- });
- }
- doIt();
- }
- function doTestActionOverride(aCallback)
- {
- const kNoScroll = 0x00;
- const kScrollUp = 0x01;
- const kScrollDown = 0x02;
- const kScrollLeft = 0x04;
- const kScrollRight = 0x08;
- const kTests = [
- { action: 1, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 0, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 1, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 1, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 0, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 1.0, deltaY: 0.5,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 1, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kScrollDown | kScrollRight
- },
- { action: 0, override_x: -1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 0,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- { action: 0, override_x: 1,
- event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
- deltaX: 0.5, deltaY: 1.0,
- lineOrPageDeltaX: 1, lineOrPageDeltaY: 1 },
- expected: kNoScroll
- },
- ];
- var index = 0;
- function doIt()
- {
- const kTest = kTests[index];
- SpecialPowers.pushPrefEnv({"set": [
- ["mousewheel.default.action", kTest.action],
- ["mousewheel.default.action.override_x", kTest.override_x]]},
- doIt2
- );
- }
- function doIt2()
- {
- const kTest = kTests[index];
- description = "doTestActionOverride(action=" + kTest.action + ", " +
- "override_x=" + kTest.override_x + ", " +
- "deltaX=" + kTest.event.deltaX + ", " +
- "deltaY=" + kTest.event.deltaY + "): ";
- gScrollableElement.scrollTop = 1000;
- gScrollableElement.scrollLeft = 1000;
- sendWheelAndWait(10, 10, kTest.event, function () {
- if (kTest.expected & kScrollUp) {
- ok(gScrollableElement.scrollTop < 1000, description + "not scrolled up, got " + gScrollableElement.scrollTop);
- } else if (kTest.expected & kScrollDown) {
- ok(gScrollableElement.scrollTop > 1000, description + "not scrolled down, got " + gScrollableElement.scrollTop);
- } else {
- is(gScrollableElement.scrollTop, 1000, description + "scrolled vertical");
- }
- if (kTest.expected & kScrollLeft) {
- ok(gScrollableElement.scrollLeft < 1000, description + "not scrolled to left, got " + gScrollableElement.scrollLeft);
- } else if (kTest.expected & kScrollRight) {
- ok(gScrollableElement.scrollLeft > 1000, description + "not scrolled to right, got " + gScrollableElement.scrollLeft);
- } else {
- is(gScrollableElement.scrollLeft, 1000, description + "scrolled horizontal");
- }
- if (++index == kTests.length) {
- SimpleTest.executeSoon(aCallback);
- } else {
- doIt();
- }
- });
- }
- doIt();
- }
- function runTests()
- {
- SpecialPowers.pushPrefEnv({"set": [
- ["test.events.async.enabled", true],
- ["general.smoothScroll", false],
- ["mousewheel.default.action", 1], // scroll
- ["mousewheel.default.action.override_x", -1],
- ["mousewheel.with_shift.action", 2], // history
- ["mousewheel.with_shift.action.override_x", -1],
- ["mousewheel.with_control.action", 3], // zoom
- ["mousewheel.with_control.action.override_x", -1]]},
- runTests2);
- }
- function runTests2()
- {
- const kSettings = [
- { description: "all delta values are not customized",
- deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
- { description: "deltaX is reverted",
- deltaMultiplierX: -1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
- { description: "deltaY is reverted",
- deltaMultiplierX: 1.0, deltaMultiplierY: -1.0, deltaMultiplierZ: 1.0 },
- { description: "deltaZ is reverted",
- deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: -1.0 },
- { description: "deltaX is 2.0",
- deltaMultiplierX: 2.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
- { description: "deltaY is 2.0",
- deltaMultiplierX: 1.0, deltaMultiplierY: 2.0, deltaMultiplierZ: 1.0 },
- { description: "deltaZ is 2.0",
- deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 2.0 },
- { description: "deltaX is -2.0",
- deltaMultiplierX: -2.0, deltaMultiplierY: 1.0, deltaMultiplierZ: 1.0 },
- { description: "deltaY is -2.0",
- deltaMultiplierX: 1.0, deltaMultiplierY: -2.0, deltaMultiplierZ: 1.0 },
- { description: "deltaZ is -2.0",
- deltaMultiplierX: 1.0, deltaMultiplierY: 1.0, deltaMultiplierZ: -2.0 },
- ];
- var index = 0;
- function doTest() {
- setDeltaMultiplierSettings(kSettings[index], function () {
- doTestScroll(kSettings[index], function () {
- doTestZoom(kSettings[index], function() {
- if (++index == kSettings.length) {
- setDeltaMultiplierSettings(kSettings[0], function() {
- doTestZoomedScroll(function() {
- doTestWholeScroll(function() {
- doTestActionOverride(function() {
- finishTests();
- });
- });
- });
- });
- } else {
- doTest();
- }
- });
- });
- });
- }
- doTest();
- }
- function finishTests()
- {
- winUtils.restoreNormalRefresh();
- window.opener.finish();
- }
- </script>
- </pre>
- </body>
- </html>
|