diff --git a/test/integration/accessibility_spec.mjs b/test/integration/accessibility_spec.mjs index fed6eac5ddbb7..41f84adb100da 100644 --- a/test/integration/accessibility_spec.mjs +++ b/test/integration/accessibility_spec.mjs @@ -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 "); + } + }) + ); + }); + }); }); diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 6080768c93f9e..8278a7a025751 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -768,3 +768,4 @@ !issue20513.pdf !issue20516.pdf !issue20489.pdf +!bug2004951.pdf diff --git a/test/pdfs/bug2004951.pdf b/test/pdfs/bug2004951.pdf new file mode 100755 index 0000000000000..83a9e4fffee7f Binary files /dev/null and b/test/pdfs/bug2004951.pdf differ diff --git a/web/struct_tree_layer_builder.js b/web/struct_tree_layer_builder.js index f52b6acc0934a..a2d1524a79f8c 100644 --- a/web/struct_tree_layer_builder.js +++ b/web/struct_tree_layer_builder.js @@ -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; } } }