Bug 1664446. Properly wait to make sure any potential scroll events get fired in several tests. r=kats

Doing rAF rAF flushApzRepaints is not enough to make sure that any potential scroll events are sent to content. The reason is that if the apz repaint request causes us to do scrolling on the main thread then the scrolling will be finished after flushApzRepaints, and the scroll event will be pending, but it's not sent until the next refresh driver tick. So we need to do at least one rAF after flushApzRepaints.

Differential Revision: https://phabricator.services.mozilla.com/D90035
This commit is contained in:
Timothy Nikkel 2020-09-13 20:21:11 +00:00
Родитель 7d6987f54e
Коммит 30f528e804
6 изменённых файлов: 12 добавлений и 10 удалений

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

@ -38,18 +38,18 @@ function waitAndCheckNoScrollEvent(aWindow) {
}
aWindow.addEventListener("scroll", recordScroll, {capture: true});
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
() => { flushApzRepaints(
() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
function() {
aWindow.removeEventListener("scroll", recordScroll, {capture: true});
is(gotScroll, false, "check that we didn't get a scroll");
resolve();
}, aWindow
}); } ); }, aWindow
); }
); }); });
}
function waitToClearOutAnyPotentialScrolls(aWindow) {
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
}
SimpleTest.waitForFocus(function() {

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

@ -39,18 +39,18 @@ function waitAndCheckNoScrollEvent(aWindow) {
}
aWindow.addEventListener("scroll", recordScroll, {capture: true});
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
() => { flushApzRepaints(
() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
function() {
aWindow.removeEventListener("scroll", recordScroll, {capture: true});
is(gotScroll, false, "check that we didn't get a scroll");
resolve();
}, aWindow
}); } ); }, aWindow
); }
); }); });
}
function waitToClearOutAnyPotentialScrolls(aWindow) {
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
}
SimpleTest.waitForFocus(function() {

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

@ -209,7 +209,7 @@ async function testRunner() {
break;
}
await promise;
await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(resolve, win); }); }); });
await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(() => { win.requestAnimationFrame(() => { win.requestAnimationFrame(resolve); } ); }, win); }); }); });
}
}

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

@ -52,7 +52,7 @@ function clickDownButton() {
}
function waitToClearOutAnyPotentialScrolls(aWindow) {
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
}
function waitForScrollEvent(aWindow) {

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

@ -63,9 +63,10 @@ async function doTests(aWindow) {
}
function waitToClearOutAnyPotentialScrolls() {
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(resolve, aWindow); }); }); });
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
}
async function doPageDown() {
let waitForScrolling = waitForScrollEvent();
if (kUseKeyboardEvent) {

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

@ -33,7 +33,8 @@ async function runTests() {
win.focus();
// clear out any potential scroll events so we can listen for the one we want without false positives
await new Promise(resolve => {window.requestAnimationFrame(() => { window.requestAnimationFrame(() => { flushApzRepaints(resolve, window); }); }); });
await new Promise(resolve => {window.requestAnimationFrame(() => { window.requestAnimationFrame(() => { flushApzRepaints(() => { window.requestAnimationFrame(() => { window.requestAnimationFrame(resolve); } ); }, window); }); }); });
step2();
}