browser_accessibility_reload.js (2489B)
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_1 = `<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 const TEST_URI_2 = `<html> 18 <head> 19 <meta charset="utf-8"/> 20 <title>Navigation Accessibility Panel</title> 21 </head> 22 <body></body> 23 </html>`; 24 25 /** 26 * Test data has the format of: 27 * { 28 * desc {String} description for better logging 29 * setup {Function} An optional setup that needs to be performed before 30 * the state of the tree and the sidebar can be checked. 31 * expected {JSON} An expected states for the tree and the sidebar. 32 * } 33 */ 34 const tests = [ 35 { 36 desc: "Test the initial accessibility tree state after first row is expanded.", 37 setup: async ({ doc }) => toggleRow(doc, 0), 38 expected: { 39 tree: [ 40 { 41 role: "document", 42 name: `"Accessibility Panel Test"`, 43 }, 44 { 45 role: "heading", 46 name: `"Top level header"`, 47 }, 48 { 49 role: "paragraph", 50 name: `""`, 51 }, 52 ], 53 sidebar: { 54 name: "Accessibility Panel Test", 55 role: "document", 56 }, 57 }, 58 }, 59 { 60 desc: "Reload the page.", 61 setup: async ({ panel }) => { 62 const onReloaded = panel.once("reloaded"); 63 panel.accessibilityProxy.commands.targetCommand.reloadTopLevelTarget(); 64 await onReloaded; 65 }, 66 expected: { 67 tree: [ 68 { 69 role: "document", 70 name: `"Accessibility Panel Test"`, 71 }, 72 ], 73 sidebar: { 74 name: "Accessibility Panel Test", 75 role: "document", 76 }, 77 }, 78 }, 79 { 80 desc: "Navigate to a new page.", 81 setup: async () => { 82 // `navigate` waits for the "reloaded" event so we don't need to do it explicitly here 83 await navigateTo(buildURL(TEST_URI_2)); 84 }, 85 expected: { 86 tree: [ 87 { 88 role: "document", 89 name: `"Navigation Accessibility Panel"`, 90 }, 91 ], 92 sidebar: { 93 name: "Navigation Accessibility Panel", 94 role: "document", 95 }, 96 }, 97 }, 98 ]; 99 100 /** 101 * Simple test that checks content of the Accessibility panel tree on reload. 102 */ 103 addA11yPanelTestsTask( 104 tests, 105 TEST_URI_1, 106 "Test Accessibility panel tree on reload." 107 );