diff --git a/test/integration/accessibility_spec.mjs b/test/integration/accessibility_spec.mjs index 94472ddc8..52815f181 100644 --- a/test/integration/accessibility_spec.mjs +++ b/test/integration/accessibility_spec.mjs @@ -336,10 +336,20 @@ describe("accessibility", () => { expect(mathML) .withContext(`In ${browserName}`) .toEqual( - " x2 = |x| " + ` x2 = |x| ` ); + + // Check that the math corresponding element is hidden in the text + // layer. + const ariaHidden = await page.$eval("span#p58R_mc13", el => + el.getAttribute("aria-hidden") + ); + expect(ariaHidden).withContext(`In ${browserName}`).toEqual("true"); } else { - pending(`Sanitizer API (in ${browserName}) is not supported`); + // eslint-disable-next-line no-console + console.log( + `Pending in Chrome: Sanitizer API (in ${browserName}) is not supported` + ); } }) ); @@ -379,7 +389,10 @@ describe("accessibility", () => { ' 𝑛 𝑝 = 𝑛 mod 𝑝 ' ); } else { - pending(`Sanitizer API (in ${browserName}) is not supported`); + // eslint-disable-next-line no-console + console.log( + `Pending in Chrome: Sanitizer API (in ${browserName}) is not supported` + ); } }) ); diff --git a/web/struct_tree_layer_builder.js b/web/struct_tree_layer_builder.js index 393191420..94d7617c3 100644 --- a/web/struct_tree_layer_builder.js +++ b/web/struct_tree_layer_builder.js @@ -341,6 +341,18 @@ class StructTreeLayerBuilder { element.setHTML(node.mathML, { sanitizer: MathMLSanitizer.sanitizer, }); + // Hide all the corresponding content elements in the text layer in + // order to avoid screen readers reading both the MathML and the + // text content. + for (const { id } of node.children || []) { + if (!id) { + continue; + } + const elem = document.getElementById(id); + if (elem) { + elem.ariaHidden = true; + } + } } if ( !node.mathML &&