Merge pull request #20550 from calixteman/bug2004951_part1

Aria-hide artifacts in the text layer (bug 2004951)
This commit is contained in:
Tim van der Meij 2026-01-06 20:29:25 +01:00 committed by GitHub
commit 91fa05d2e8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View File

@ -294,6 +294,9 @@ class TextLayer {
if (item.id) {
this.#container.setAttribute("id", `${item.id}`);
}
if (item.tag === "Artifact") {
this.#container.ariaHidden = true;
}
parent.append(this.#container);
} else if (item.type === "endMarkedContent") {
this.#container = this.#container.parentNode;

View File

@ -430,4 +430,34 @@ describe("accessibility", () => {
);
});
});
describe("Artifacts must be aria-hidden", () => {
let pages;
beforeEach(async () => {
pages = await loadAndWait("bug1937438_mml_from_latex.pdf", ".textLayer");
});
afterEach(async () => {
await closePages(pages);
});
it("must check that some artifacts are aria-hidden", async () => {
await Promise.all(
pages.map(async ([browserName, page]) => {
const parentSquareRootHidden = await page.evaluate(() => {
for (const span of document.querySelectorAll(".textLayer span")) {
if (span.textContent === "√") {
return span.parentElement.getAttribute("aria-hidden");
}
}
return false;
});
expect(parentSquareRootHidden)
.withContext(`In ${browserName}`)
.toEqual("true");
})
);
});
});
});