1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

[Editor] Use the alt text to descibe the canvas used to display the image

This commit is contained in:
Calixte Denizet 2023-10-02 20:30:27 +02:00
parent 59d94b549f
commit e3fbe2908a
3 changed files with 59 additions and 3 deletions

View file

@ -249,9 +249,34 @@ describe("Stamp Editor", () => {
]);
}, data);
await page.keyboard.down("Control");
await page.keyboard.press("v");
await page.keyboard.up("Control");
let hasPasteEvent = false;
while (!hasPasteEvent) {
// We retry to paste if nothing has been pasted before 500ms.
const promise = Promise.race([
page.evaluate(
() =>
new Promise(resolve => {
document.addEventListener(
"paste",
e => resolve(e.clipboardData.items.length !== 0),
{
once: true,
}
);
})
),
page.evaluate(
() =>
new Promise(resolve => {
setTimeout(() => resolve(false), 500);
})
),
]);
await page.keyboard.down("Control");
await page.keyboard.press("v");
await page.keyboard.up("Control");
hasPasteEvent = await promise;
}
await waitForImage(page, getEditorSelector(0));
@ -277,6 +302,11 @@ describe("Stamp Editor", () => {
const saveButtonSelector = "#altTextDialog #altTextSave";
await page.click(saveButtonSelector);
// Check that the canvas has an aria-describedby attribute.
await page.waitForSelector(
`${getEditorSelector(0)} canvas[aria-describedby]`
);
// Wait for the alt-text button to have the correct icon.
await page.waitForSelector(`${buttonSelector}:not([hidden]).done`);