browser_general.js (3527B)
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 adding `overflow:hidden;` styling to a div causes it to 11 * get an accessible. 12 */ 13 addAccessibleTask(`<p>hello world</p>`, async function (browser, docAcc) { 14 const originalTree = { DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] }; 15 16 testAccessibleTree(docAcc, originalTree); 17 info("Adding div element"); 18 await contentSpawnMutation( 19 browser, 20 { unexpected: [[EVENT_REORDER, docAcc]] }, 21 function () { 22 const d = content.document.createElement("div"); 23 content.document.body.appendChild(d); 24 } 25 ); 26 27 testAccessibleTree(docAcc, originalTree); 28 info("Adding overflow:hidden styling to div"); 29 await contentSpawnMutation( 30 browser, 31 { expected: [[EVENT_REORDER, docAcc]] }, 32 function () { 33 content.document.body.lastElementChild.setAttribute( 34 "style", 35 "overflow:hidden;" 36 ); 37 } 38 ); 39 40 testAccessibleTree(docAcc, { 41 DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }, { TEXT_CONTAINER: [] }], 42 }); 43 }); 44 45 /** 46 * Verify adding `overflow:scroll;` styling to a div causes 47 * it to get an accessible. 48 */ 49 addAccessibleTask(`<p>hello world</p>`, async function (browser, docAcc) { 50 const originalTree = { DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] }; 51 52 testAccessibleTree(docAcc, originalTree); 53 info("Adding div element"); 54 await contentSpawnMutation( 55 browser, 56 { unexpected: [[EVENT_REORDER, docAcc]] }, 57 function () { 58 const d = content.document.createElement("div"); 59 content.document.body.appendChild(d); 60 } 61 ); 62 63 testAccessibleTree(docAcc, originalTree); 64 info("Adding overflow:scroll styling to div"); 65 await contentSpawnMutation( 66 browser, 67 { expected: [[EVENT_REORDER, docAcc]] }, 68 function () { 69 content.document.body.lastElementChild.setAttribute( 70 "style", 71 "overflow:scroll;" 72 ); 73 } 74 ); 75 76 testAccessibleTree(docAcc, { 77 DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }, { TEXT_CONTAINER: [] }], 78 }); 79 }); 80 81 /** 82 * Verify adding `overflow:auto;` styling to a div causes 83 * it to get an accessible, but `overflow:visible` does not. 84 */ 85 addAccessibleTask(`<p>hello world</p>`, async function (browser, docAcc) { 86 const originalTree = { DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }] }; 87 88 testAccessibleTree(docAcc, originalTree); 89 info("Adding div element"); 90 await contentSpawnMutation( 91 browser, 92 { unexpected: [[EVENT_REORDER, docAcc]] }, 93 function () { 94 const d = content.document.createElement("div"); 95 content.document.body.appendChild(d); 96 } 97 ); 98 99 testAccessibleTree(docAcc, originalTree); 100 info("Adding overflow:visible styling to div"); 101 await contentSpawnMutation( 102 browser, 103 { unexpected: [[EVENT_REORDER, docAcc]] }, 104 function () { 105 content.document.body.lastElementChild.setAttribute( 106 "style", 107 "overflow:visible;" 108 ); 109 } 110 ); 111 112 testAccessibleTree(docAcc, originalTree); 113 info("Adding overflow:auto styling to div"); 114 await contentSpawnMutation( 115 browser, 116 { expected: [[EVENT_REORDER, docAcc]] }, 117 function () { 118 content.document.body.lastElementChild.setAttribute( 119 "style", 120 "overflow:auto;" 121 ); 122 } 123 ); 124 125 testAccessibleTree(docAcc, { 126 DOCUMENT: [{ PARAGRAPH: [{ TEXT_LEAF: [] }] }, { TEXT_CONTAINER: [] }], 127 }); 128 });