Merge pull request #17205 from calixteman/issue17200

Fix the intermittent failures with PageOpen/PageClose test
This commit is contained in:
calixteman 2023-10-29 23:23:09 +01:00 committed by GitHub
commit 1ab0f8a0ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 17 deletions

View File

@ -816,7 +816,7 @@ describe("Interaction", () => {
"window.PDFViewerApplication.scriptingReady === true"
);
await scrollIntoView(page, getSelector("171R"));
await scrollIntoView(page, getSelector("138R"));
let sum = 0;
for (const [id, val] of [

View File

@ -255,23 +255,12 @@ async function scrollIntoView(page, selector) {
await page.evaluate(sel => {
const element = document.querySelector(sel);
element.scrollIntoView({ behavior: "instant", block: "start" });
return new Promise(resolve => {
document
.getElementById("viewerContainer")
.addEventListener("scrollend", resolve, { once: true });
});
}, selector);
await page.waitForFunction(
sel => {
const toolbarHeight = document
.querySelector("#toolbarContainer")
.getBoundingClientRect().height;
const element = document.querySelector(sel);
const { top, bottom } = element.getBoundingClientRect();
return (
Math.abs(top) < toolbarHeight + 100 ||
Math.abs(bottom - window.innerHeight) < 100 ||
(top > toolbarHeight && bottom < window.innerHeight)
);
},
{},
selector
);
}
async function hover(page, selector) {