Make test_bug422132.html compatible with APZ. (bug 1149128, r=kats)

--HG--
extra : rebase_source : 398f39855839dd34b1eaa5acb5835e54f1b065fc
This commit is contained in:
David Anderson 2015-04-15 16:41:26 -04:00
parent 02b584280a
commit 0150518a62

View File

@ -8,6 +8,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=422132
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script> <script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script> <script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head> </head>
<body> <body>
@ -25,22 +26,13 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=422132
/** Test for Bug 422132 **/ /** Test for Bug 422132 **/
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
SimpleTest.requestFlakyTimeout("untriaged");
SimpleTest.waitForFocus(function() { SimpleTest.waitForFocus(function() {
SpecialPowers.pushPrefEnv({ SpecialPowers.pushPrefEnv({
"set":[["general.smoothScroll", false], "set":[["general.smoothScroll", false],
["mousewheel.min_line_scroll_amount", 1], ["mousewheel.min_line_scroll_amount", 1],
["mousewheel.system_scroll_override_on_root_content.enabled", false],
["mousewheel.transaction.timeout", 100000]]}, runTests)}, window); ["mousewheel.transaction.timeout", 100000]]}, runTests)}, window);
function hitEventLoop(aFunc, aTimes)
{
if (--aTimes) {
setTimeout(hitEventLoop, 0, aFunc, aTimes);
} else {
setTimeout(aFunc, 20);
}
}
function runTests() function runTests()
{ {
var target = document.getElementById("target"); var target = document.getElementById("target");
@ -50,6 +42,10 @@ function runTests()
var tests = [ var tests = [
{ {
prepare: function() {
scrollLeft = target.scrollLeft;
scrollTop = target.scrollTop;
},
event: { event: {
deltaMode: WheelEvent.DOM_DELTA_PIXEL, deltaMode: WheelEvent.DOM_DELTA_PIXEL,
deltaX: 0.5, deltaX: 0.5,
@ -57,10 +53,6 @@ function runTests()
lineOrPageDeltaX: 0, lineOrPageDeltaX: 0,
lineOrPageDeltaY: 0 lineOrPageDeltaY: 0
}, },
check: function() {
is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5px delta value");
is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5px delta value");
}
}, { }, {
event: { event: {
deltaMode: WheelEvent.DOM_DELTA_PIXEL, deltaMode: WheelEvent.DOM_DELTA_PIXEL,
@ -70,12 +62,16 @@ function runTests()
lineOrPageDeltaY: 0 lineOrPageDeltaY: 0
}, },
check: function() { check: function() {
ok(target.scrollLeft > scrollLeft, is(target.scrollLeft - scrollLeft, 1,
"not scrolled to right by 0.5px delta value with pending 0.5px delta"); "not scrolled to right by 0.5px delta value with pending 0.5px delta");
ok(target.scrollTop > scrollTop, is(target.scrollTop - scrollTop, 1,
"not scrolled to bottom by 0.5px delta value with pending 0.5px delta"); "not scrolled to bottom by 0.5px delta value with pending 0.5px delta");
}, },
}, { }, {
prepare: function() {
scrollLeft = target.scrollLeft;
scrollTop = target.scrollTop;
},
event: { event: {
deltaMode: WheelEvent.DOM_DELTA_LINE, deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 0.5, deltaX: 0.5,
@ -83,10 +79,6 @@ function runTests()
lineOrPageDeltaX: 0, lineOrPageDeltaX: 0,
lineOrPageDeltaY: 0 lineOrPageDeltaY: 0
}, },
check: function() {
is(target.scrollLeft, scrollLeft, "scrolled to right by 0.5 line delta value");
is(target.scrollTop, scrollTop, "scrolled to bottom by 0.5 line delta value");
}
}, { }, {
event: { event: {
deltaMode: WheelEvent.DOM_DELTA_LINE, deltaMode: WheelEvent.DOM_DELTA_LINE,
@ -96,9 +88,9 @@ function runTests()
lineOrPageDeltaY: 1 lineOrPageDeltaY: 1
}, },
check: function() { check: function() {
ok(target.scrollLeft > scrollLeft, is(target.scrollLeft - scrollLeft, 1,
"not scrolled to right by 0.5 line delta value with pending 0.5 line delta"); "not scrolled to right by 0.5 line delta value with pending 0.5 line delta");
ok(target.scrollTop > scrollTop, is(target.scrollTop - scrollTop, 1,
"not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta"); "not scrolled to bottom by 0.5 line delta value with pending 0.5 line delta");
} }
} }
@ -106,19 +98,21 @@ function runTests()
var nextTest = function() { var nextTest = function() {
var test = tests.shift(); var test = tests.shift();
synthesizeWheel(target, 10, 10, test.event); if (test.prepare) {
hitEventLoop(function() { test.prepare();
test.check(); }
sendWheelAndPaint(target, 10, 10, test.event, function() {
if (test.check) {
test.check();
}
if (tests.length == 0) { if (tests.length == 0) {
SimpleTest.finish(); SimpleTest.finish();
return; return;
} }
scrollLeft = target.scrollLeft;
scrollTop = target.scrollTop;
setTimeout(nextTest, 0); setTimeout(nextTest, 0);
}, 20); });
} }
nextTest(); nextTest();