--- a/content/events/test/window_wheel_default_action.html
+++ b/content/events/test/window_wheel_default_action.html
@@ -1130,17 +1130,17 @@ function doTestZoom(aSettings, aCallback
synthesizeKey("0", { accelKey: true });
hitEventLoop(doNextTest, 20);
}, 20);
}
doNextTest();
}
-function doTestZoomedScroll()
+function doTestZoomedScroll(aCallback)
{
function testZoomedPixelScroll()
{
// Reset zoom and store the scroll amount into the data.
synthesizeKey("0", { accelKey: true });
gScrollableElement.scrollTop = 1000;
gScrollableElement.scrollLeft = 1000;
// Ensure not to be in reflow.
@@ -1257,28 +1257,285 @@ function doTestZoomedScroll()
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 });
+
+ SimpleTest.executeSoon(aCallback);
}, 20);
}, 20);
}, 20);
}, 20);
}
// XXX It's too difficult to test page scroll because the page scroll amount
// is computed by complex logic.
testZoomedPixelScroll();
}
+function doTestWholeScroll(aCallback)
+{
+ SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 99999999);
+ SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_y", 99999999);
+
+ 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();
+ }
+ synthesizeWheel(gScrollableElement, 10, 10, kTest.event);
+ hitEventLoop(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) {
+ SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
+ SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");
+ SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_z");
+ SimpleTest.executeSoon(aCallback);
+ } else {
+ doIt();
+ }
+ }, 20);
+ }
+ doIt();
+}
+
function runTests()
{
SpecialPowers.setBoolPref("general.smoothScroll", false);
SpecialPowers.setIntPref("mousewheel.default.action", 1); // scroll
SpecialPowers.setIntPref("mousewheel.with_shift.action", 2); // history
SpecialPowers.setIntPref("mousewheel.with_control.action", 3); // zoom
@@ -1308,18 +1565,21 @@ function runTests()
var index = 0;
function doTest() {
setDeltaMultiplierSettings(kSettings[index]);
doTestScroll(kSettings[index], function () {
doTestZoom(kSettings[index], function() {
if (++index == kSettings.length) {
setDeltaMultiplierSettings(kSettings[0]);
- doTestZoomedScroll();
- finishTests();
+ doTestZoomedScroll(function() {
+ doTestWholeScroll(function() {
+ finishTests();
+ });
+ });
} else {
doTest();
}
});
});
}
doTest();
}