browser_test_aria_hidden.js (2590B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* import-globals-from ../../mochitest/role.js */ 7 loadScripts({ name: "role.js", dir: MOCHITESTS_DIR }); 8 9 /** 10 * Verify loading a tab document with aria-hidden specified on the root element 11 * correctly renders the root element and its content. This test is meaninfully 12 * different from testTabDocument which tests aria-hidden specified on the 13 * body element. 14 */ 15 addAccessibleTask( 16 `<html aria-hidden="true"><u>hello world`, 17 async function testTabRootDocument(_, accDoc) { 18 const tree = { 19 DOCUMENT: [ 20 { 21 TEXT_LEAF: [], 22 }, 23 ], 24 }; 25 testAccessibleTree(accDoc, tree); 26 }, 27 { 28 chrome: true, 29 topLevel: true, 30 iframe: false, 31 remoteIframe: false, 32 } 33 ); 34 35 /** 36 * Verify loading a tab doc with aria-hidden on the body renders the document. 37 * Body elements inside of embedded iframes, should continue 38 * to respect aria-hidden when present. This test ONLY tests 39 * tab documents, it should not run in iframes. There is a separate 40 * test for iframes in browser_test_aria_hidden_iframe.js. 41 */ 42 addAccessibleTask( 43 ` 44 <p id="content">I am some content in a document</p> 45 `, 46 async function testTabDocument(browser, docAcc) { 47 const originalTree = { DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] }; 48 testAccessibleTree(docAcc, originalTree); 49 }, 50 { 51 chrome: true, 52 topLevel: true, 53 iframe: false, 54 remoteIframe: false, 55 contentDocBodyAttrs: { "aria-hidden": "true" }, 56 } 57 ); 58 59 /** 60 * Verify adding aria-hidden to root doc elements has no effect. 61 * Non-root doc elements, like embedded iframes, should continue 62 * to respect aria-hidden when applied. This test ONLY tests 63 * tab documents, it should not run in iframes. There is a separate 64 * test for iframes in browser_test_aria_hidden_iframe.js. 65 */ 66 addAccessibleTask( 67 ` 68 <p id="content">I am some content in a document</p> 69 `, 70 async function testTabDocumentMutation(browser, docAcc) { 71 const originalTree = { DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] }; 72 73 testAccessibleTree(docAcc, originalTree); 74 info("Adding aria-hidden=true to content doc"); 75 const unexpectedEvents = { unexpected: [[EVENT_REORDER, docAcc]] }; 76 await contentSpawnMutation(browser, unexpectedEvents, function () { 77 const b = content.document.body; 78 b.setAttribute("aria-hidden", "true"); 79 }); 80 81 testAccessibleTree(docAcc, originalTree); 82 }, 83 { chrome: true, topLevel: true, iframe: false, remoteIframe: false } 84 );