Skip to content

Commit 91fa05d

Browse files
Merge pull request #20550 from calixteman/bug2004951_part1
Aria-hide artifacts in the text layer (bug 2004951)
2 parents a939f12 + 0ef085e commit 91fa05d

2 files changed

Lines changed: 33 additions & 0 deletions

File tree

src/display/text_layer.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,9 @@ class TextLayer {
294294
if (item.id) {
295295
this.#container.setAttribute("id", `${item.id}`);
296296
}
297+
if (item.tag === "Artifact") {
298+
this.#container.ariaHidden = true;
299+
}
297300
parent.append(this.#container);
298301
} else if (item.type === "endMarkedContent") {
299302
this.#container = this.#container.parentNode;

test/integration/accessibility_spec.mjs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,4 +430,34 @@ describe("accessibility", () => {
430430
);
431431
});
432432
});
433+
434+
describe("Artifacts must be aria-hidden", () => {
435+
let pages;
436+
437+
beforeEach(async () => {
438+
pages = await loadAndWait("bug1937438_mml_from_latex.pdf", ".textLayer");
439+
});
440+
441+
afterEach(async () => {
442+
await closePages(pages);
443+
});
444+
445+
it("must check that some artifacts are aria-hidden", async () => {
446+
await Promise.all(
447+
pages.map(async ([browserName, page]) => {
448+
const parentSquareRootHidden = await page.evaluate(() => {
449+
for (const span of document.querySelectorAll(".textLayer span")) {
450+
if (span.textContent === "√") {
451+
return span.parentElement.getAttribute("aria-hidden");
452+
}
453+
}
454+
return false;
455+
});
456+
expect(parentSquareRootHidden)
457+
.withContext(`In ${browserName}`)
458+
.toEqual("true");
459+
})
460+
);
461+
});
462+
});
433463
});

0 commit comments

Comments
 (0)