mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-03 12:57:20 +02:00
Aria-hide artifacts in the text layer (bug 2004951)
This commit is contained in:
parent
a939f12391
commit
0ef085e23b
@ -294,6 +294,9 @@ class TextLayer {
|
|||||||
if (item.id) {
|
if (item.id) {
|
||||||
this.#container.setAttribute("id", `${item.id}`);
|
this.#container.setAttribute("id", `${item.id}`);
|
||||||
}
|
}
|
||||||
|
if (item.tag === "Artifact") {
|
||||||
|
this.#container.ariaHidden = true;
|
||||||
|
}
|
||||||
parent.append(this.#container);
|
parent.append(this.#container);
|
||||||
} else if (item.type === "endMarkedContent") {
|
} else if (item.type === "endMarkedContent") {
|
||||||
this.#container = this.#container.parentNode;
|
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