Bug 1697585 - Ask some tests to wait for a tick in browser_click_event_during_autoscrolling.js r=smaug

Some tests need to wait for a full tick cycle to ensure the expected
input tasks are run.

Differential Revision: https://phabricator.services.mozilla.com/D110848
This commit is contained in:
Sean Feng 2021-04-06 13:10:52 +00:00
Родитель f3dd06d79b
Коммит 1134da1e94
1 изменённых файлов: 12 добавлений и 0 удалений

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

@ -35,6 +35,16 @@ add_task(async function() {
});
}
function promiseContentTick() {
return SpecialPowers.spawn(browser, [], async () => {
await new Promise(r => {
content.requestAnimationFrame(() => {
content.requestAnimationFrame(r);
});
});
});
}
let autoScroller;
function promiseWaitForAutoScrollerOpen() {
if (autoScroller?.state == "open") {
@ -169,6 +179,7 @@ add_task(async function() {
button: 1, // middle button
});
await promiseFlushLayoutInContent();
await promiseContentTick();
await eventsInContent.promiseMouseEvents(
["mouseup"],
"At starting autoscrolling"
@ -302,6 +313,7 @@ add_task(async function() {
button: aButton,
});
await promiseFlushLayoutInContent();
await promiseContentTick();
await eventsInContent.promiseMouseEvents(
aButton != 2 ? ["mouseup"] : ["mouseup", "contextmenu"],
aDescription