mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Don't add an aria-label on MathML elements in the struct tree (bug 2004951)
This commit is contained in:
parent
91fa05d2e8
commit
da463f2da9
@ -460,4 +460,42 @@ describe("accessibility", () => {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("No alt-text with MathML", () => {
|
||||
let pages;
|
||||
|
||||
beforeEach(async () => {
|
||||
pages = await loadAndWait("bug2004951.pdf", ".textLayer");
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
await closePages(pages);
|
||||
});
|
||||
|
||||
it("must check that there's no alt-text on the MathML node", async () => {
|
||||
await Promise.all(
|
||||
pages.map(async ([browserName, page]) => {
|
||||
const isSanitizerSupported = await page.evaluate(() => {
|
||||
try {
|
||||
// eslint-disable-next-line no-undef
|
||||
return typeof Sanitizer !== "undefined";
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
const ariaLabel = await page.$eval(
|
||||
"span[aria-owns='p3R_mc2']",
|
||||
el => el.getAttribute("aria-label") || ""
|
||||
);
|
||||
if (isSanitizerSupported) {
|
||||
expect(ariaLabel).withContext(`In ${browserName}`).toEqual("");
|
||||
} else {
|
||||
expect(ariaLabel)
|
||||
.withContext(`In ${browserName}`)
|
||||
.toEqual("cube root of , x plus y end cube root ");
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -768,3 +768,4 @@
|
||||
!issue20513.pdf
|
||||
!issue20516.pdf
|
||||
!issue20489.pdf
|
||||
!bug2004951.pdf
|
||||
|
||||
BIN
test/pdfs/bug2004951.pdf
Executable file
BIN
test/pdfs/bug2004951.pdf
Executable file
Binary file not shown.
@ -370,6 +370,10 @@ class StructTreeLayerBuilder {
|
||||
elem.ariaHidden = true;
|
||||
}
|
||||
}
|
||||
// For now, we don't want to keep the alt text if there's valid
|
||||
// MathML (see https://github.com/w3c/mathml-aam/issues/37).
|
||||
// TODO: Revisit this decision in the future.
|
||||
delete node.alt;
|
||||
}
|
||||
if (
|
||||
!node.mathML &&
|
||||
@ -377,6 +381,7 @@ class StructTreeLayerBuilder {
|
||||
node.children[0].role !== "math"
|
||||
) {
|
||||
element = document.createElementNS(MathMLNamespace, "math");
|
||||
delete node.alt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user