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]) => {
|
pages.map(async ([browserName, page]) => {
|
||||||
for (const i of [23, 22, 14]) {
|
for (const i of [23, 22, 14]) {
|
||||||
await page.click(`[data-annotation-id='${i}R']`);
|
await page.click(`[data-annotation-id='${i}R']`);
|
||||||
await page.waitForFunction(
|
await page.waitForSelector(`#pdfjs_internal_id_${i}R:focus`);
|
||||||
id =>
|
|
||||||
document.activeElement ===
|
|
||||||
document.querySelector(`#pdfjs_internal_id_${id}R`),
|
|
||||||
{},
|
|
||||||
i
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1591,18 +1591,12 @@ describe("Highlight Editor", () => {
|
|||||||
await page.focus(getEditorSelector(1));
|
await page.focus(getEditorSelector(1));
|
||||||
|
|
||||||
await kbFocusPrevious(page);
|
await kbFocusPrevious(page);
|
||||||
await page.waitForFunction(
|
await page.waitForSelector(
|
||||||
sel => document.querySelector(sel) === document.activeElement,
|
`.page[data-page-number="1"] > .textLayer:focus`
|
||||||
{},
|
|
||||||
`.page[data-page-number="1"] > .textLayer`
|
|
||||||
);
|
);
|
||||||
|
|
||||||
await kbFocusNext(page);
|
await kbFocusNext(page);
|
||||||
await page.waitForFunction(
|
await page.waitForSelector(`${getEditorSelector(1)}:focus`);
|
||||||
sel => document.querySelector(sel) === document.activeElement,
|
|
||||||
{},
|
|
||||||
getEditorSelector(1)
|
|
||||||
);
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user