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:
parent
5c5c107ec5
commit
bb743389aa
@ -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`);
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
@ -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`);
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user