browser_test_aria_hidden_iframe.js (3448B)
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 an iframe document with aria-hidden specified on the root element 11 * correctly hides the root element and its content. This test is meaninfully 12 * different from testIframeDocument which tests aria-hidden specified on the 13 * body element. 14 */ 15 addAccessibleTask( 16 `hello world`, 17 async function testIframeRootDocument(browser) { 18 info("Loading iframe document"); 19 const HIDDEN_IFRAME_URI = 20 "data:text/html,<html id='new_html' aria-hidden='true'><body id='iframeBody'><u>hello world</u></body></html>"; 21 const loaded = waitForEvent(EVENT_DOCUMENT_LOAD_COMPLETE, "iframeBody"); 22 await SpecialPowers.spawn( 23 browser, 24 [DEFAULT_IFRAME_ID, HIDDEN_IFRAME_URI], 25 (_id, _uri) => { 26 content.document.getElementById(_id).src = _uri; 27 } 28 ); 29 await loaded; 30 31 const tree = { 32 INTERNAL_FRAME: [ 33 { 34 DOCUMENT: [], 35 }, 36 ], 37 }; 38 const root = getRootAccessible(document); 39 const iframeDoc = findAccessibleChildByID(root, DEFAULT_IFRAME_ID); 40 testAccessibleTree(iframeDoc, tree); 41 }, 42 { 43 chrome: false, 44 topLevel: false, 45 iframe: true, 46 remoteIframe: true, 47 } 48 ); 49 50 /** 51 * Verify loading an iframe doc with aria-hidden doesn't render the document. 52 * This test ONLY tests iframe documents, it should not run in tab docs. 53 * There is a separate test for tab docs in browser_test_aria_hidden.js. 54 */ 55 addAccessibleTask( 56 ` 57 <p id="content">I am some content in a document</p> 58 `, 59 async function testIframeDocument(browser, docAcc, topLevel) { 60 const originalTree = { DOCUMENT: [{ INTERNAL_FRAME: [{ DOCUMENT: [] }] }] }; 61 testAccessibleTree(topLevel, originalTree); 62 }, 63 { 64 chrome: false, 65 topLevel: false, 66 iframe: true, 67 remoteIframe: true, 68 iframeDocBodyAttrs: { "aria-hidden": "true" }, 69 } 70 ); 71 72 /** 73 * Verify adding aria-hidden to iframe doc elements removes 74 * their subtree. This test ONLY tests iframe documents, it 75 * should not run in tab documents. There is a separate test for 76 * tab documents in browser_test_aria_hidden.js. 77 */ 78 addAccessibleTask( 79 ` 80 <p id="content">I am some content in a document</p> 81 `, 82 async function testIframeDocumentMutation(browser, docAcc, topLevel) { 83 const originalTree = { 84 DOCUMENT: [ 85 { 86 INTERNAL_FRAME: [ 87 { 88 DOCUMENT: [ 89 { 90 PARAGRAPH: [ 91 { 92 TEXT_LEAF: [], 93 }, 94 ], 95 }, 96 ], 97 }, 98 ], 99 }, 100 ], 101 }; 102 103 testAccessibleTree(topLevel, originalTree); 104 info("Adding aria-hidden=true to content doc"); 105 await contentSpawnMutation( 106 browser, 107 { expected: [[EVENT_REORDER, docAcc]] }, 108 function () { 109 const b = content.document.body; 110 b.setAttribute("aria-hidden", "true"); 111 } 112 ); 113 const newTree = { 114 DOCUMENT: [ 115 { 116 INTERNAL_FRAME: [ 117 { 118 DOCUMENT: [], 119 }, 120 ], 121 }, 122 ], 123 }; 124 testAccessibleTree(topLevel, newTree); 125 }, 126 { chrome: false, topLevel: false, iframe: true, remoteIframe: true } 127 );