1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Use waitForSelector instead of waitForFunction for focus checks

This commit replaces `waitForFunction` calls that use
`document.activeElement` to wait for an element to get focus by simpler
`waitForSelector` expressions that use the `:focus` selector. Note that
we already use this in other tests, so this improves consistency too.
This commit is contained in:
Tim van der Meij 2024-05-02 19:23:55 +02:00
parent 5c5c107ec5
commit bb743389aa
No known key found for this signature in database
GPG key ID: 8C3FD2925A5F2762
2 changed files with 4 additions and 16 deletions

View file

@ -74,13 +74,7 @@ describe("Annotation highlight", () => {
pages.map(async ([browserName, page]) => {
for (const i of [23, 22, 14]) {
await page.click(`[data-annotation-id='${i}R']`);
await page.waitForFunction(
id =>
document.activeElement ===
document.querySelector(`#pdfjs_internal_id_${id}R`),
{},
i
);
await page.waitForSelector(`#pdfjs_internal_id_${i}R:focus`);
}
})
);

View file

@ -1591,18 +1591,12 @@ describe("Highlight Editor", () => {
await page.focus(getEditorSelector(1));
await kbFocusPrevious(page);
await page.waitForFunction(
sel => document.querySelector(sel) === document.activeElement,
{},
`.page[data-page-number="1"] > .textLayer`
await page.waitForSelector(
`.page[data-page-number="1"] > .textLayer:focus`
);
await kbFocusNext(page);
await page.waitForFunction(
sel => document.querySelector(sel) === document.activeElement,
{},
getEditorSelector(1)
);
await page.waitForSelector(`${getEditorSelector(1)}:focus`);
})
);
});