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

Ignore null-chars when using structTree-data in the viewer

Testing the `tagged_stamp.pdf` document locally in the viewer, I noticed that e.g. the /Alt entry for the StampAnnotation contains "Secondary text for stamp\u0000".
Elsewhere in the viewer we're skipping null-chars and it's easy enough to do that in the `StructTreeLayerBuilder` class as well. (Note that we generally let the API itself return the data as-is.)
This commit is contained in:
Jonas Jenwald 2023-08-31 15:22:51 +02:00
parent 14b2a31e78
commit 284f32f50b
2 changed files with 23 additions and 2 deletions

View file

@ -169,6 +169,22 @@ describe("accessibility", () => {
);
});
it("must check the aria-label linked to the stamp annotation", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
await page.waitForSelector(".structTree");
const ariaLabel = await page.$eval(
".structTree [role='figure']",
el => el.getAttribute("aria-label")
);
expect(ariaLabel)
.withContext(`In ${browserName}`)
.toEqual("Secondary text for stamp");
})
);
});
it("must check that the stamp annotation is linked to the struct tree", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {