products/Sources/formale Sprachen/C/Firefox/dom/events/test/window_wheel_default_action.html
<!DOCTYPE HTML >
<html >
<head >
<title >Test for default action of WheelEvent</title >
<script src="/tests/SimpleTest/SimpleTest.js" ></script >
<script src="/tests/SimpleTest/EventUtils.js" ></script >
<script 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" >
// Until the first non-blank paint, the parent will set the opacity of our
// browser to 0 using the 'blank' attribute.
// Until the blank attribute is removed, we can't send scroll events.
SimpleTest.waitForFocus(function() {
let chromeScript = SpecialPowers.loadChromeScript(_ => {
/* eslint-env mozilla/chrome-script */
let win = Services.wm.getMostRecentWindow("navigator:browser" );
win.requestAnimationFrame(() => {
win.gBrowser.selectedBrowser.removeAttribute("blank" );
win.requestAnimationFrame(() => {
sendAsyncMessage("blank-attribute-removed" );
});
});
});
chromeScript.promiseOneMessage("blank-attribute-removed" ).then(() => {
chromeScript.destroy();
runTests();
});
}, window);
SimpleTest.requestLongerTimeout(6);
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" );
const kDefaultActionNone = 0;
const kDefaultActionScroll = 1;
const kDefaultActionHistory = 2;
const kDefaultActionZoom = 3;
const kDefaultActionHorizontalizedScroll = 4;
const kDefaultActionOverrideXNoOverride = -1;
const kDefaultActionOverrideXNone = kDefaultActionNone;
const kDefaultActionOverrideXScroll = kDefaultActionScroll;
const kDefaultActionOverrideXHistory = kDefaultActionHistory;
const kDefaultActionOverrideXZoom = kDefaultActionZoom;
// We sometimes rely on the scroll position not getting preserved across tests.
function resetScrollPosition(element) {
element.style .display = "none" ;
element.offsetTop;
element.style .display = "" ;
}
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);
}
}
function onZoomReset(aCallback) {
var fullZoom = SpecialPowers.getFullZoom(window);
if (fullZoom == 1) {
SimpleTest.executeSoon(aCallback);
return;
}
// Zoom causes a resize of the viewport.
window.addEventListener("resize" , function onResize(event) {
is(SpecialPowers.getFullZoom(window), 1, "Zoom should be reset to 1" );
window.removeEventListener("resize" , onResize);
SimpleTest.executeSoon(aCallback);
});
}
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],
]}, 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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
expected: kScrollDown },
{ description: "Scroll to top 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: 0, isMomentum: false,
expectedOverflowDeltaX: 0, expectedOverflowDeltaY: 0,
shiftKey: false, ctrlKey: false, altKey: false, metaKey: 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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
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 },
expected: kNoScroll,
prepare (cb) { SpecialPowers.pushPrefEnv({"set" : [["mousewheel.default.action" , 0]]}, cb); },
cleanup (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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: 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: false, ctrlKey: false, altKey: true, metaKey: false },
expected: kNoScroll,
prepare (cb) { SpecialPowers.pushPrefEnv({"set" : [["mousewheel.default.action" , 0]]}, cb); },
cleanup (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 },
expected: kScrollDown,
prepare(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 },
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 },
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 },
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 },
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 },
expected: kScrollUp,
cleanup (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 },
expected: kScrollRight,
prepare(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 },
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 },
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 },
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 },
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 },
expected: kScrollLeft,
cleanup (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 },
expected: kNoScroll,
prepare(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 },
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 },
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 },
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 },
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 },
expected: kNoScroll,
cleanup (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 },
expected: kScrollDown,
prepare(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 },
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 },
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 },
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 },
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 },
expected: kScrollUp,
cleanup (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 },
expected: kScrollRight,
prepare(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 },
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 },
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 },
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 },
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 },
expected: kScrollLeft,
cleanup (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) {
// prepare() can make changes to a page such as
// changing the 'overflow' property which requires
// a repaint to take effect before sending
// scroll-wheel events.
currentTest.prepare(doWaitForPaintsAndScroll);
} else {
doTestCurrentScroll();
}
}
function doWaitForPaintsAndScroll() {
waitForAllPaintsFlushed(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 doTestHorizontalizedScroll(aSettings, aCallback)
{
const kNoScroll = 0x00;
const kScrollLeft = 0x01;
const kScrollRight = 0x02;
const kTests = [
{ description: "Scroll to right 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll to right 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll to left 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Scroll to left 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Don't scroll by deltaX (pixel scroll, 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kNoScroll },
{ description: "Don't scroll by deltaX (pixel scroll, 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kNoScroll },
{ description: "Don't scroll by negative deltaX (pixel scroll, 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kNoScroll },
{ description: "Don't scroll by negative deltaX (pixel scroll, 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kNoScroll },
{ description: "Scroll only to right by diagonal pixel scroll (to bottom-right)" ,
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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll only to right by diagonal pixel scroll (to bottom-left)" ,
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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll only to left by diagonal pixel scroll (to top-left)" ,
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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Scroll only to left by pixel scroll (to bottom-right)" ,
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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Don't scroll by pixel scroll for z-axis" ,
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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kNoScroll },
{ description: "Scroll to right 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll to right 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollRight },
{ description: "Scroll to left 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Scroll to left 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: true, ctrlKey: false, altKey: false, metaKey: false },
expected: kScrollLeft },
{ description: "Don't scroll by deltaX (line scroll, lineOrPageDelta is 0)" ,
event: { deltaMode: WheelEvent.DOM_DELTA_LINE,
--> --------------------
--> maximum size reached
--> --------------------
Messung V0.5 C=96 H=94 G=94
¤ Dauer der Verarbeitung: 0.18 Sekunden
(vorverarbeitet)
¤
*© Formatika GbR, Deutschland