зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1667612. Factor waitToClearOutAnyPotentialScrolls out from various tests and put it in apz_test_utils.js. r=kats
Differential Revision: https://phabricator.services.mozilla.com/D92318
This commit is contained in:
Родитель
4352fb7b0d
Коммит
223e9bb630
|
@ -53,10 +53,6 @@ scroll
|
|||
/** Test for Bug 1303704 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
let link1 = window.document.getElementById("link1");
|
||||
let mouseEvents = ["mousedown", "mouseup", "mousemove"];
|
||||
|
|
|
@ -37,19 +37,10 @@ function waitAndCheckNoScrollEvent(aWindow) {
|
|||
gotScroll = true;
|
||||
}
|
||||
aWindow.addEventListener("scroll", recordScroll, {capture: true});
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
|
||||
() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
|
||||
function() {
|
||||
return waitToClearOutAnyPotentialScrolls(aWindow).then(function() {
|
||||
aWindow.removeEventListener("scroll", recordScroll, {capture: true});
|
||||
is(gotScroll, false, "check that we didn't get a scroll");
|
||||
resolve();
|
||||
}); } ); }, aWindow
|
||||
); }
|
||||
); }); });
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
|
|
|
@ -38,19 +38,10 @@ function waitAndCheckNoScrollEvent(aWindow) {
|
|||
gotScroll = true;
|
||||
}
|
||||
aWindow.addEventListener("scroll", recordScroll, {capture: true});
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
|
||||
() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(
|
||||
function() {
|
||||
return waitToClearOutAnyPotentialScrolls(aWindow).then(function() {
|
||||
aWindow.removeEventListener("scroll", recordScroll, {capture: true});
|
||||
is(gotScroll, false, "check that we didn't get a scroll");
|
||||
resolve();
|
||||
}); } ); }, aWindow
|
||||
); }
|
||||
); }); });
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
});
|
||||
}
|
||||
|
||||
SimpleTest.waitForFocus(function() {
|
||||
|
|
|
@ -200,7 +200,7 @@ async function testRunner() {
|
|||
is(body.getBoundingClientRect().height, 400,
|
||||
"Body height should be what we set it to");
|
||||
|
||||
await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(resolve, win); }); }); });
|
||||
await waitToClearOutAnyPotentialScrolls(win);
|
||||
|
||||
let curTest = runTests();
|
||||
while (true) {
|
||||
|
@ -208,8 +208,10 @@ async function testRunner() {
|
|||
if ((await curTest.next()).done) {
|
||||
break;
|
||||
}
|
||||
// wait for the scroll
|
||||
await promise;
|
||||
await new Promise(resolve => {win.requestAnimationFrame(() => { win.requestAnimationFrame(() => { flushApzRepaints(() => { win.requestAnimationFrame(() => { win.requestAnimationFrame(resolve); } ); }, win); }); }); });
|
||||
// clear out any other pending scrolls
|
||||
await waitToClearOutAnyPotentialScrolls(win);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1163,3 +1163,17 @@ function assertNotCheckerboarded(utils, scrollerId, msgPrefix) {
|
|||
ok(found, `${msgPrefix}: Found the scroller in the APZ data`);
|
||||
utils.restoreNormalRefresh();
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {
|
||||
aWindow.requestAnimationFrame(() => {
|
||||
aWindow.requestAnimationFrame(() => {
|
||||
flushApzRepaints(() => {
|
||||
aWindow.requestAnimationFrame(() => {
|
||||
aWindow.requestAnimationFrame(resolve);
|
||||
});
|
||||
}, aWindow);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
|
@ -51,10 +51,6 @@ function clickDownButton() {
|
|||
{ type: "mouseup" });
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
}
|
||||
|
||||
function waitForScrollEvent(aWindow) {
|
||||
return new Promise(resolve => {
|
||||
aWindow.addEventListener("scroll", () => { SimpleTest.executeSoon(resolve); }, {once: true, capture: true});
|
||||
|
|
|
@ -62,11 +62,6 @@ async function doTests(aWindow) {
|
|||
});
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls() {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
}
|
||||
|
||||
|
||||
async function doPageDown() {
|
||||
let waitForScrolling = waitForScrollEvent();
|
||||
if (kUseKeyboardEvent) {
|
||||
|
@ -103,7 +98,7 @@ async function doTests(aWindow) {
|
|||
container = doc.documentElement;
|
||||
let editor = doc.getElementById("editor");
|
||||
editor.focus();
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
let description = "PageDown in non-scrollable editing host: ";
|
||||
let previousScrollTop = container.scrollTop;
|
||||
|
@ -142,7 +137,7 @@ async function doTests(aWindow) {
|
|||
editor = doc.getElementById("editor");
|
||||
container = editor;
|
||||
editor.focus();
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
description = "PageDown in scrollable editing host: ";
|
||||
previousScrollTop = container.scrollTop;
|
||||
|
@ -173,7 +168,7 @@ async function doTests(aWindow) {
|
|||
editor = doc.getElementById("editor");
|
||||
container = doc.documentElement;
|
||||
editor.focus();
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
description = "PageDown in too large editing host: ";
|
||||
previousScrollTop = container.scrollTop;
|
||||
|
@ -185,7 +180,7 @@ async function doTests(aWindow) {
|
|||
|
||||
selection.selectAllChildren(editor);
|
||||
selection.collapseToEnd();
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
description = "PageUp in too large editing host: ";
|
||||
container.scrollTop = container.scrollHeight;
|
||||
|
@ -199,7 +194,7 @@ async function doTests(aWindow) {
|
|||
editor = doc.getElementById("editor");
|
||||
container = editor;
|
||||
editor.focus();
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
description = "PageDown in scrollable editing host";
|
||||
previousScrollTop = container.scrollTop;
|
||||
|
@ -226,7 +221,7 @@ async function doTests(aWindow) {
|
|||
container = doc.documentElement;
|
||||
editor.focus();
|
||||
selection.collapse(editor.firstChild);
|
||||
await waitToClearOutAnyPotentialScrolls();
|
||||
await waitToClearOutAnyPotentialScrolls(aWindow);
|
||||
|
||||
description = "PageDown in too high non-scrollable editing host";
|
||||
previousScrollTop = container.scrollTop;
|
||||
|
|
|
@ -33,10 +33,6 @@ function doPageDown(targetExpectedToScroll) {
|
|||
return promise;
|
||||
}
|
||||
|
||||
function waitToClearOutAnyPotentialScrolls(aWindow) {
|
||||
return new Promise(resolve => {aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(() => { flushApzRepaints(() => { aWindow.requestAnimationFrame(() => { aWindow.requestAnimationFrame(resolve); } ); }, aWindow); }); }); });
|
||||
}
|
||||
|
||||
promise_test(async function() {
|
||||
await SpecialPowers.pushPrefEnv({"set": [["general.smoothScroll", false]]});
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ 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(() => { window.requestAnimationFrame(() => { window.requestAnimationFrame(resolve); } ); }, window); }); }); });
|
||||
await waitToClearOutAnyPotentialScrolls(window);
|
||||
|
||||
step2();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче