Bug 719320 part.11 Fix new test failures r=smaug

This commit is contained in:
Masayuki Nakano 2012-08-12 10:42:36 +09:00
parent a380d0bab6
commit 3ca9a6e26d
13 changed files with 189 additions and 141 deletions

View File

@ -72,11 +72,11 @@ function runOverflowTests(aEvent) {
"(" + left(scrollbox) + " <= " + firstScrollableLeft + ")");
for (var i = 2; i; i--)
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: -1});
EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: -1.0, deltaMode: WheelEvent.DOM_DELTA_LINE });
is(left(firstScrollable()), firstScrollableLeft, "Remained at the start with the mouse wheel");
element = nextRightElement();
EventUtils.synthesizeMouseScroll(scrollbox, 1, 1, {axis: "horizontal", delta: 1});
EventUtils.synthesizeWheel(scrollbox, 1, 1, { deltaX: 1.0, deltaMode: WheelEvent.DOM_DELTA_LINE});
isRight(element, "Scrolled one tab to the right with the mouse wheel");
while (tabs.length > 1)

View File

@ -51,8 +51,8 @@ function performScrollingTest()
InspectorUI.highlighter.removeListener("nodeselected", performScrollingTest);
executeSoon(function() {
EventUtils.synthesizeMouseScroll(div, 10, 10,
{axis:"vertical", delta:50, type:"MozMousePixelScroll"},
EventUtils.synthesizeWheel(div, 10, 10,
{ deltaY: 50.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL },
iframe.contentWindow);
});

View File

@ -23,25 +23,17 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=574663
function sendTouchpadScrollMotion(scrollbox, direction, ctrl, momentum) {
var win = scrollbox.ownerDocument.defaultView;
let event = {
'type': "DOMMouseScroll",
'axis': "vertical",
'delta': direction,
'hasPixels': true,
'ctrlKey': ctrl,
'isMomentum': momentum,
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: direction * 3,
lineOrPageDeltaY: direction,
ctrlKey: ctrl,
isMomentum: momentum
};
// first a line scroll
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// Then a line scroll with hasPixels set to false
event.hasPixels = false;
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// then 5 pixel scrolls
event.hasPixels = true;
event.delta *= 3;
event.type = "MozMousePixelScroll";
event.hasPixels = false;
synthesizeWheel(scrollbox, 10, 10, event, win);
// then 5 additional pixel scrolls
event.lineOrPageDeltaY = 0;
for (let i = 0; i < 5; ++i) {
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
synthesizeWheel(scrollbox, 10, 10, event, win);
}
}

View File

@ -26,19 +26,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=607464
function scrollDown15PxWithPixelScrolling(scrollbox) {
var win = scrollbox.ownerDocument.defaultView;
let event = {
'type': "DOMMouseScroll",
'axis': "vertical",
'delta': 1,
'hasPixels': true,
deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaY: 3.0,
lineOrPageDeltaY: 1
};
// first a line scroll
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// then 5 pixel scrolls with 3px each
event.delta *= 3;
event.type = "MozMousePixelScroll";
event.hasPixels = false;
for (let i = 0; i < 5; ++i) {
synthesizeMouseScroll(scrollbox, 10, 10, event, win);
// A pixel scroll with lineOrPageDeltaY.
synthesizeWheel(scrollbox, 10, 10, event, win);
// then 4 pixel scrolls without lineOrPageDeltaY.
event.lineOrPageDeltaY = 0;
for (let i = 0; i < 4; ++i) {
synthesizeWheel(scrollbox, 10, 10, event, win);
}
// Note: the line scroll shouldn't have any effect because it has

View File

@ -198,6 +198,7 @@ var interfaceNamesInGlobalScope =
"NSEvent",
"HTMLBRElement",
"MouseScrollEvent",
"WheelEvent",
"HashChangeEvent",
"TreeWalker",
"HTMLTitleElement",

View File

@ -36,6 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602
this.mouseUp = false;
this.mouseClick = false;
this.mouseScroll = false;
this.wheel = false;
}
var parent = document.getElementById("parent")
@ -49,12 +50,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602
is(childStats.mouseUp, false, "Child should not receive mouseup event.");
is(childStats.mouseClick, false, "Child should not receive click event.");
is(childStats.mouseScroll, false, "Child should not receive DOMMouseScroll event.");
is(childStats.wheel, false, "Child should not receive wheel event.");
ok(parentStats.mouseMove, "Parent should receive mousemove event.");
ok(parentStats.mouseDown, "Parent should receive mousedown event.");
ok(parentStats.mouseUp, "Parent should receive mouseup event.");
ok(parentStats.mouseClick, "Parent should receive click event.");
ok(parentStats.mouseScroll, "Parent should receive DOMMouseScroll event.");
ok(parentStats.wheel, "Parent should receive wheel event.");
}
@ -84,18 +87,33 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=633602
childStats.mouseScroll = true;
};
var childWheelTest = function() {
childStats.wheel = true;
};
// Event listeners for the parent element
var startMouseTests = function() {
parent.removeEventListener("mousemove", startMouseTests);
parent.addEventListener("DOMMouseScroll", parentScrollTest);
child.addEventListener("DOMMouseScroll", childScrollTest);
synthesizeMouseScroll(child, 5, 5, {'delta': 10, 'type': "DOMMouseScroll"});
synthesizeWheel(child, 5, 5, {'deltaY': 10, 'lineOrPageDeltaY': 10,
'deltaMode': WheelEvent.DOM_DELTA_LINE});
};
var parentScrollTest = function (e) {
parentStats.mouseScroll = true;
parent.removeEventListener("DOMMouseScroll", parentScrollTest);
child.removeEventListener("DOMMouseScroll", childScrollTest);
parent.addEventListener("wheel", parentWheelTest);
child.addEventListener("wheel", childWheelTest);
synthesizeWheel(child, 5, 5, {'deltaY': 10, 'lineOrPageDeltaY': 10,
'deltaMode': WheelEvent.DOM_DELTA_LINE});
};
var parentWheelTest = function (e) {
parentStats.wheel = true;
parent.removeEventListener("wheel", parentWheelTest);
child.removeEventListener("wheel", childWheelTest);
parent.addEventListener("mousedown", parentDownTest);
child.addEventListener("mousedown", childDownTest);
synthesizeMouseAtCenter(child, {type: "mousedown"}, window);

View File

@ -36,10 +36,10 @@ function doTest() {
synthesizeMouse(scrollbox, 8, 8, { type: "mousemove" });
// Now scroll 10px down.
synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});
synthesizeWheel(scrollbox, 10, 10, { deltaY: 10.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL });
// Send a 0-delta scroll.
synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:0, type:"MozMousePixelScroll"});
synthesizeWheel(scrollbox, 10, 10, { deltaY: 0.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL });
setTimeout(function() {
// Check if the 10px were scrolled.
@ -50,7 +50,7 @@ function doTest() {
scrollbox.scrollTop = 20;
// Start an async scroll to 30.
synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});
synthesizeWheel(scrollbox, 10, 10, { deltaY: 10.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL });
// Start a sync scroll to 30.
scrollbox.scrollTop = 30;
@ -62,13 +62,13 @@ function doTest() {
scrollbox.scrollTop = 40;
// Start an async scroll to 50.
synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:10, type:"MozMousePixelScroll"});
synthesizeWheel(scrollbox, 10, 10, { deltaY: 10.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL });
// Cancel the async scroll.
scrollbox.scrollTop = 40;
// Send a 0-delta scroll.
synthesizeMouseScroll(scrollbox, 10, 10, {axis:"vertical", delta:0, type:"MozMousePixelScroll"});
synthesizeWheel(scrollbox, 10, 10, { deltaY: 0.0, deltaMode: WheelEvent.DOM_DELTA_PIXEL });
setTimeout(function() {
is(scrollbox.scrollTop, 40, "Canceling an async scroll should reset the point of reference for relative scrolls (mDestinationX/Y).");

View File

@ -55,7 +55,8 @@ function testtag_finish()
ok(!document.getElementById("datepicker-popup").open, "datepicker popup open false again");
var dpgrid = document.getElementById("datepicker-grid");
synthesizeMouseScroll(dpgrid, 5, 5, { delta: 10 });
synthesizeWheel(dpgrid, 5, 5, { deltaY: 10.0,
deltaMode: WheelEvent.DOM_DELTA_LINE });
is(mouseScrolled, true, "mouse scrolled");
is(dpgrid.displayedMonth, 2, "mouse scroll changed month");

View File

@ -200,7 +200,8 @@ function test_menulist_open(element, scroller)
var scrolled = false;
var mouseScrolled = function (event) { scrolled = true; }
window.addEventListener("DOMMouseScroll", mouseScrolled, false);
synthesizeMouseScroll(element, 2, 2, { delta: 10 });
synthesizeWheel(element, 2, 2, { deltaY: 10,
deltaMode: WheelEvent.DOM_DELTA_LINE });
is(scrolled, true, "mousescroll " + element.id);
is(scroller.scrollTop, 0, "scroll position on mousescroll " + element.id);
window.removeEventListener("DOMMouseScroll", mouseScrolled, false);

View File

@ -81,49 +81,52 @@ var smoothScrollPref = "general.smoothScroll";
SpecialPowers.setBoolPref(smoothScrollPref, false);
SimpleTest.waitForExplicitFinish();
/* There are three kinds of scroll events:
1. line scrolls without hasPixels
2. line scrolls with hasPixels
3. pixel scrolls
Listboxes and arrowscrollboxes (DOM event scrolling) should only react to
line scrolls and ignore hasPixels.
Richlistboxes ("native" scrolling) should be scrollable by kind 1 and 3.
*/
const kinds = [
{ eventType: "DOMMouseScroll", hasPixels: false, shouldScrollDOM: true, shouldScrollNative: true },
{ eventType: "DOMMouseScroll", hasPixels: true, shouldScrollDOM: true, shouldScrollNative: false },
{ eventType: "MozMousePixelScroll", hasPixels: false, shouldScrollDOM: false, shouldScrollNative: true }
const deltaModes = [
WheelEvent.DOM_DELTA_PIXEL, // 0
WheelEvent.DOM_DELTA_LINE, // 1
WheelEvent.DOM_DELTA_PAGE // 2
];
function testListbox(id)
{
var listbox = document.getElementById(id);
function helper(aStart, aDelta, aKind)
function helper(aStart, aDelta, aIntDelta, aDeltaMode)
{
listbox.scrollToIndex(aStart);
synthesizeMouseScroll(listbox, 10, 10,
{axis:"vertical", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
is(listbox.getIndexOfFirstVisibleRow(), aKind.shouldScrollDOM ? aStart + aDelta : aStart,
"mouse-scroll of '" + id + "' vertical starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaY: aDelta,
lineOrPageDeltaY: aIntDelta });
var expectedPos = aStart;
if (aIntDelta) {
if (aDeltaMode == WheelEvent.DOM_DELTA_PAGE) {
expectedPos += aIntDelta > 0 ? listbox.getNumberOfVisibleRows() :
-listbox.getNumberOfVisibleRows();
} else {
expectedPos += aIntDelta;
}
}
is(listbox.getIndexOfFirstVisibleRow(), expectedPos,
"testListbox(" + id + "): vertical, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
// Check that horizontal scrolling has no effect
listbox.scrollToIndex(aStart);
synthesizeMouseScroll(listbox, 10, 10,
{axis:"horizontal", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaX: aDelta,
lineOrPageDeltaX: aIntDelta });
is(listbox.getIndexOfFirstVisibleRow(), aStart,
"mouse-scroll of '" + id + "' horizontal starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
"testListbox(" + id + "): horizontal, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
}
kinds.forEach(function(aKind) {
helper(2, -1, aKind);
helper(2, 1, aKind);
helper(2, -2, aKind);
helper(2, 2, aKind);
deltaModes.forEach(function(aDeltaMode) {
let delta = (aDeltaMode == WheelEvent.DOM_DELTA_PIXEL) ? 5.0 : 0.3;
helper(5, -delta, 0, aDeltaMode);
helper(5, -delta, -1, aDeltaMode);
helper(5, delta, 1, aDeltaMode);
helper(5, delta, 0, aDeltaMode);
});
}
@ -134,29 +137,31 @@ function testRichListbox(id, andThen)
function helper()
{
var [aStart, aDelta, aKind] = tests[0];
var [aStart, aDelta, aIntDelta, aDeltaMode] = tests[0];
tests.shift();
listbox.scrollToIndex(aStart);
synthesizeMouseScroll(listbox, 10, 10,
{axis:"vertical", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaY: aDelta,
lineOrPageDeltaY: aIntDelta });
setTimeout(function() {
var change = listbox.getIndexOfFirstVisibleRow() - aStart;
var direction = (change > 0) - (change < 0);
var expected = aKind.shouldScrollNative && (aDelta > 0) - (aDelta < 0);
var expected = (aDelta > 0) - (aDelta < 0);
is(direction, expected,
"mouse-scroll of '" + id + "' vertical starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
"testRichListbox(" + id + "): vertical, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
// Check that horizontal scrolling has no effect
listbox.scrollToIndex(aStart);
synthesizeMouseScroll(listbox, 10, 10,
{axis:"horizontal", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
synthesizeWheel(listbox, 10, 10,
{ deltaMode: aDeltaMode, deltaX: aDelta,
lineOrPageDeltaX: aIntDelta });
setTimeout(function() {
is(listbox.getIndexOfFirstVisibleRow(), aStart,
"mouse-scroll of '" + id + "' horizontal starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
"testRichListbox(" + id + "): horizontal, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
if (tests.length)
helper();
else
@ -168,9 +173,12 @@ function testRichListbox(id, andThen)
// richlistbox currently uses native XUL scrolling, so the "line"
// amounts don't necessarily correspond 1-to-1 with listbox items. So
// we just check that scrolling up/down scrolls in the right direction.
kinds.forEach(function(aKind) {
tests.push([2, -100, aKind]);
tests.push([2, 100, aKind]);
deltaModes.forEach(function(aDeltaMode) {
let delta = (aDeltaMode == WheelEvent.DOM_DELTA_PIXEL) ? 32.0 : 2.0;
tests.push([5, -delta, -1, aDeltaMode]);
tests.push([5, -delta, 0, aDeltaMode]);
tests.push([5, delta, 1, aDeltaMode]);
tests.push([5, delta, 0, aDeltaMode]);
});
helper();
}
@ -181,39 +189,43 @@ function testArrowScrollbox(id)
var scrollBoxObject = scrollbox.scrollBoxObject;
var orient = scrollbox.getAttribute("orient");
function helper(aStart, aDelta, aExpected, aKind)
function helper(aStart, aDelta, aIntDelta, aDeltaMode, aExpected)
{
var xpos = {};
var ypos = {};
var pos = orient == "horizontal" ? xpos : ypos;
var orientIsHorizontal = (orient == "horizontal");
var pos = orientIsHorizontal ? xpos : ypos;
scrollBoxObject.scrollTo(aStart, aStart);
for (var i = (orient == "horizontal") ? 2 : 0; i >= 0; i--) {
synthesizeMouseScroll(scrollbox, 5, 5,
{axis:"vertical", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
for (var i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
synthesizeWheel(scrollbox, 5, 5,
{ deltaMode: aDeltaMode, deltaY: aDelta,
lineOrPageDeltaY: aIntDelta });
scrollBoxObject.getPosition(xpos, ypos);
// Note, vertical mouse scrolling is allowed to scroll horizontal
// arrowscrollboxes, because many users have no horizontal mouse scroll
// capability
var expected = (aKind.shouldScrollDOM && !i) ? aExpected : aStart;
let expected = !i ? aExpected : aStart;
is(pos.value, expected,
"mouse-scroll of '" + id + "' vertical starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
"testArrowScrollbox(" + id + "): vertical, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
}
for (var i = (orient == "horizontal") ? 2 : 0; i >= 0; i--) {
scrollBoxObject.scrollTo(aStart, aStart);
synthesizeMouseScroll(scrollbox, 5, 5,
{axis:"horizontal", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
scrollBoxObject.scrollTo(aStart, aStart);
for (var i = orientIsHorizontal ? 2 : 0; i >= 0; i--) {
synthesizeWheel(scrollbox, 5, 5,
{ deltaMode: aDeltaMode, deltaX: aDelta,
lineOrPageDeltaX: aIntDelta });
// horizontal mouse scrolling is never allowed to scroll vertical
// arrowscrollboxes
scrollBoxObject.getPosition(xpos, ypos);
var expected = (aKind.shouldScrollDOM && !i && (orient == "horizontal")) ? aExpected : aStart;
let expected = (!i && orientIsHorizontal) ? aExpected : aStart;
is(pos.value, expected,
"mouse-scroll of '" + id + "' horizontal starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
"testArrowScrollbox(" + id + "): horizontal, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
}
}
@ -224,9 +236,14 @@ function testArrowScrollbox(id)
var scrollMaxY = scrolledHeight.value - scrollBoxObject.height;
var scrollMax = orient == "horizontal" ? scrollMaxX : scrollMaxY;
kinds.forEach(function(aKind) {
helper(50, -100, 0, aKind);
helper(50, 100, scrollMax, aKind);
deltaModes.forEach(function(aDeltaMode) {
// These lineOrPageDelta values are not realistic. However, it's enough to
// test if it's scrolled by the lineOrPageDelta value.
let delta = (aDeltaMode == WheelEvent.DOM_DELTA_PIXEL) ? 5.0 : 0.3;
helper(50, -delta, -100, aDeltaMode, 0);
helper(50, delta, 100, aDeltaMode, scrollMax);
helper(50, -delta, 0, aDeltaMode, 50);
helper(50, delta, 0, aDeltaMode, 50);
});
}

View File

@ -119,7 +119,7 @@ function testtag_tree(treeid, treerowinfoid, seltype, columnstype, testid)
if (testid !="tree view")
testtag_tree_TreeView_rows_sort(tree, testid, rowInfo);
testtag_tree_mousescroll(tree);
testtag_tree_wheel(tree);
document.removeEventListener("keypress", preventDefault, false);
@ -1165,49 +1165,66 @@ function testtag_tree_column_reorder()
SimpleTest.finish();
}
function testtag_tree_mousescroll(aTree)
function testtag_tree_wheel(aTree)
{
/* Scroll event kinds, see test_mousescroll.xul */
const kinds = [
{ eventType: "DOMMouseScroll", hasPixels: false, shouldScrollDOM: true, shouldScrollNative: true },
{ eventType: "DOMMouseScroll", hasPixels: true, shouldScrollDOM: true, shouldScrollNative: false },
{ eventType: "MozMousePixelScroll", hasPixels: false, shouldScrollDOM: false, shouldScrollNative: true }
const deltaModes = [
WheelEvent.DOM_DELTA_PIXEL, // 0
WheelEvent.DOM_DELTA_LINE, // 1
WheelEvent.DOM_DELTA_PAGE // 2
];
function helper(aStart, aDelta, aKind)
function helper(aStart, aDelta, aIntDelta, aDeltaMode)
{
aTree.treeBoxObject.scrollToRow(aStart);
synthesizeMouseScroll(aTree.body, 1, 1,
{axis:"vertical", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
var expected = aKind.shouldScrollDOM ? aStart + aDelta : aStart;
is(aTree.treeBoxObject.getFirstVisibleRow(), expected, "mouse-scroll vertical starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
var expected = !aIntDelta ? aStart :
aDeltaMode != WheelEvent.DOM_DELTA_PAGE ? aStart + aIntDelta :
aIntDelta > 0 ? aStart + aTree.treeBoxObject.getPageLength() :
aStart - aTree.treeBoxObject.getPageLength();
if (expected < 0) {
expected = 0;
}
if (expected > aTree.view.rowCount - aTree.treeBoxObject.getPageLength()) {
expected = aTree.view.rowCount - aTree.treeBoxObject.getPageLength();
}
synthesizeWheel(aTree.body, 1, 1,
{ deltaMode: aDeltaMode, deltaY: aDelta,
lineOrPageDeltaY: aIntDelta });
is(aTree.treeBoxObject.getFirstVisibleRow(), expected,
"testtag_tree_wheel: vertical, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
aTree.treeBoxObject.scrollToRow(aStart);
// Check that horizontal scrolling has no effect
synthesizeMouseScroll(aTree.body, 1, 1,
{axis:"horizontal", delta:aDelta, type:aKind.eventType,
hasPixels:aKind.hasPixels});
is(aTree.treeBoxObject.getFirstVisibleRow(), aStart, "mouse-scroll horizontal starting " + aStart + " delta " + aDelta
+ " eventType " + aKind.eventType + " hasPixels " + aKind.hasPixels);
synthesizeWheel(aTree.body, 1, 1,
{ deltaMode: aDeltaMode, deltaX: aDelta,
lineOrPageDeltaX: aIntDelta });
is(aTree.treeBoxObject.getFirstVisibleRow(), aStart,
"testtag_tree_wheel: horizontal, starting " + aStart +
" delta " + aDelta + " lineOrPageDelta " + aIntDelta +
" aDeltaMode " + aDeltaMode);
}
var defaultPrevented = 0;
function mouseScrollListener(event) {
function wheelListener(event) {
defaultPrevented++;
}
window.addEventListener("DOMMouseScroll", mouseScrollListener, false);
window.addEventListener("wheel", wheelListener, false);
kinds.forEach(function(aKind) {
helper(2, -1, aKind);
helper(2, 1, aKind);
helper(2, -2, aKind);
helper(2, 2, aKind);
deltaModes.forEach(function(aDeltaMode) {
var delta = (aDeltaMode == WheelEvent.DOM_DELTA_PIXEL) ? 5.0 : 0.3;
helper(2, -delta, 0, aDeltaMode);
helper(2, -delta, -1, aDeltaMode);
helper(2, delta, 0, aDeltaMode);
helper(2, delta, 1, aDeltaMode);
helper(2, -2 * delta, 0, aDeltaMode);
helper(2, -2 * delta, -1, aDeltaMode);
helper(2, 2 * delta, 0, aDeltaMode);
helper(2, 2 * delta, 1, aDeltaMode);
});
window.removeEventListener("DOMMouseScroll", mouseScrollListener, false);
is(defaultPrevented, 16, "mouse scroll event default prevented");
window.removeEventListener("wheel", wheelListener, false);
is(defaultPrevented, 48, "wheel event default prevented");
}
function synthesizeColumnDrag(aTree, aMouseDownColumnNumber, aMouseUpColumnNumber, aAfter)

View File

@ -169,9 +169,9 @@ function retryAllTests()
function fireWheelScrollEvent(aForward)
{
gIgnoreScrollEvent = false;
var event = { axis: "vertical", delta: aForward ? 4 : -4,
type: "DOMMouseScroll" };
synthesizeMouseScroll(gView, 5, 5, event, window);
var event = { deltaY: aForward ? 4.0 : -4.0,
deltaMode: WheelEvent.DOM_DELTA_LINE };
synthesizeWheel(gView, 5, 5, event, window);
}
function onScrollView(aEvent)

View File

@ -1089,9 +1089,13 @@ function _fireMouseMoveEvent(aOffset)
function _fireWheelScrollEvent(aOffset, aIsVertical, aForward, aDelta)
{
var event = { axis: aIsVertical ? "vertical" : "horizontal",
delta: aForward ? aDelta : -aDelta, type: "DOMMouseScroll" };
synthesizeMouseScroll(gRootView, aOffset.x, aOffset.y, event, window);
var event = { deltaMode: WheelEvent.DOM_DELTA_LINE };
if (aIsVertical) {
event.deltaY = aForward ? aDelta : -aDelta;
} else {
event.deltaX = aForward ? aDelta : -aDelta;
}
synthesizeWheel(gRootView, aOffset.x, aOffset.y, event, window);
}
function _canScroll(aElement, aIsVertical, aForward)