mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Merge pull request #20550 from calixteman/bug2004951_part1
Aria-hide artifacts in the text layer (bug 2004951)
This commit is contained in:
commit
91fa05d2e8
@ -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;
|
||||
|
||||
@ -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");
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user