Bug 1148219 - Improve reliability of the test_scroll_snapping.html mochitest. r=roc

- The test_scroll_snapping.html mochitest now waits up to 30 frames for
  scrolling to start before giving up and reporting a failure.
This commit is contained in:
Kearwood (Kip) Gilbert 2015-04-06 13:32:00 +02:00
Родитель 1ba703e3dd
Коммит f7ef919657
1 изменённых файлов: 31 добавлений и 13 удалений

Просмотреть файл

@ -233,6 +233,7 @@ var sd; // Scrolled Div
var lastScrollTop;
var lastScrollLeft;
var stopFrameCount;
var winUtils = SpecialPowers.DOMWindowUtils;
function doTest() {
var testCase = testCases[step];
@ -255,21 +256,38 @@ function doTest() {
testCase.mousePosition.y + testCase.mouseOffset.y,
{ type: "mousemove" });
window.requestAnimationFrame(function() {
isnot("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
"(" + testCase.startScroll.x +"," + testCase.startScroll.y + ")",
"Step " + step + ": Synthesized mouse events move scroll position. ("
+ testCase.description + ")");
stopFrameCount = 0;
waitForScrollStart();
}
window.setTimeout(function() {
synthesizeMouse(sc,
testCase.mousePosition.x + testCase.mouseOffset.x,
testCase.mousePosition.y + testCase.mouseOffset.y,
{ type: "mouseup" });
function waitForScrollStart() {
// Wait for up to 30 frames for scrolling to start
var testCase = testCases[step];
if (testCase.startScroll.y != sc.scrollTop
|| testCase.startScroll.x != sc.scrollLeft
|| ++stopFrameCount < 30) {
window.requestAnimationFrame(doMouseUp);
} else {
window.requestAnimationFrame(waitForScrollStart);
}
}
window.requestAnimationFrame(waitForScrollStop);
}, testCase.duration);
});
function doMouseUp() {
var testCase = testCases[step];
isnot("(" + sc.scrollLeft + "," + sc.scrollTop + ")",
"(" + testCase.startScroll.x +"," + testCase.startScroll.y + ")",
"Step " + step + ": Synthesized mouse events move scroll position. ("
+ testCase.description + ")");
window.setTimeout(function() {
synthesizeMouse(sc,
testCase.mousePosition.x + testCase.mouseOffset.x,
testCase.mousePosition.y + testCase.mouseOffset.y,
{ type: "mouseup" });
stopFrameCount = 0;
window.requestAnimationFrame(waitForScrollStop);
}, testCase.duration);
}
function waitForScrollStop() {