browser_accessibility_tree_navigation.js (4331B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const TEST_URI = `<html> 7 <head> 8 <meta charset="utf-8"/> 9 <title>Accessibility Panel Test</title> 10 </head> 11 <body> 12 <h1>Top level header</h1> 13 <p>This is a paragraph.</p> 14 </body> 15 </html>`; 16 17 /** 18 * Test data has the format of: 19 * { 20 * desc {String} description for better logging 21 * setup {Function} An optional setup that needs to be performed before 22 * the state of the tree and the sidebar can be checked. 23 * expected {JSON} An expected states for the tree and the sidebar. 24 * } 25 */ 26 const tests = [ 27 { 28 desc: "Test the initial accessibility tree and sidebar states.", 29 expected: { 30 tree: [ 31 { 32 role: "document", 33 name: `"Accessibility Panel Test"`, 34 }, 35 ], 36 sidebar: { 37 name: "Accessibility Panel Test", 38 role: "document", 39 actions: [], 40 value: "", 41 description: "", 42 keyboardShortcut: "", 43 childCount: 2, 44 indexInParent: 0, 45 states: [ 46 // The focused state is an outdated state, since the toolbox should now 47 // have the focus and not the content page. See Bug 1702709. 48 "focused", 49 "readonly", 50 "focusable", 51 "selectable text", 52 "opaque", 53 "enabled", 54 "sensitive", 55 ], 56 }, 57 }, 58 }, 59 { 60 desc: "Expand first tree node.", 61 setup: async ({ doc }) => toggleRow(doc, 0), 62 expected: { 63 tree: [ 64 { 65 role: "document", 66 name: `"Accessibility Panel Test"`, 67 }, 68 { 69 role: "heading", 70 name: `"Top level header"`, 71 }, 72 { 73 role: "paragraph", 74 name: `""`, 75 }, 76 ], 77 }, 78 }, 79 { 80 desc: "Expand second tree node.", 81 setup: async ({ doc }) => toggleRow(doc, 1), 82 expected: { 83 tree: [ 84 { 85 role: "document", 86 name: `"Accessibility Panel Test"`, 87 }, 88 { 89 role: "heading", 90 name: `"Top level header"`, 91 }, 92 { 93 role: "text leaf", 94 name: `"Top level header"`, 95 }, 96 { 97 role: "paragraph", 98 name: `""`, 99 }, 100 ], 101 sidebar: { 102 name: "Top level header", 103 role: "heading", 104 actions: [], 105 value: "", 106 description: "", 107 keyboardShortcut: "", 108 childCount: 1, 109 indexInParent: 0, 110 states: ["selectable text", "opaque", "enabled", "sensitive"], 111 }, 112 }, 113 }, 114 { 115 desc: "Select third tree node.", 116 setup: ({ doc }) => selectRow(doc, 2), 117 expected: { 118 sidebar: { 119 name: "Top level header", 120 role: "text leaf", 121 actions: [], 122 value: "", 123 description: "", 124 keyboardShortcut: "", 125 childCount: 0, 126 indexInParent: 0, 127 states: ["opaque", "enabled", "sensitive"], 128 }, 129 }, 130 }, 131 { 132 desc: "Collapse first tree node.", 133 setup: async ({ doc }) => toggleRow(doc, 0), 134 expected: { 135 tree: [ 136 { 137 role: "document", 138 name: `"Accessibility Panel Test"`, 139 }, 140 ], 141 sidebar: { 142 name: "Accessibility Panel Test", 143 role: "document", 144 actions: [], 145 value: "", 146 description: "", 147 keyboardShortcut: "", 148 childCount: 2, 149 indexInParent: 0, 150 states: [ 151 "readonly", 152 "focusable", 153 "selectable text", 154 "opaque", 155 "enabled", 156 "sensitive", 157 ], 158 }, 159 }, 160 }, 161 { 162 desc: "Expand first tree node again.", 163 setup: async ({ doc }) => toggleRow(doc, 0), 164 expected: { 165 tree: [ 166 { 167 role: "document", 168 name: `"Accessibility Panel Test"`, 169 }, 170 { 171 role: "heading", 172 name: `"Top level header"`, 173 }, 174 { 175 role: "text leaf", 176 name: `"Top level header"`, 177 }, 178 { 179 role: "paragraph", 180 name: `""`, 181 }, 182 ], 183 }, 184 }, 185 ]; 186 187 /** 188 * Check navigation within the tree. 189 */ 190 addA11yPanelTestsTask( 191 tests, 192 TEST_URI, 193 "Test Accessibility panel tree navigation." 194 );