browser_accessibility_panel_toolbar_checks.js (3122B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /* global toggleMenuItem, TREE_FILTERS_MENU_ID */ 7 8 const TEST_URI = `<html> 9 <head> 10 <meta charset="utf-8"/> 11 <title>Accessibility Panel Test</title> 12 </head> 13 <body></body> 14 </html>`; 15 16 /** 17 * Test data has the format of: 18 * { 19 * desc {String} description for better logging 20 * setup {Function} An optional setup that needs to be performed before 21 * the state of the tree and the sidebar can be checked. 22 * expected {JSON} An expected states for the tree and the sidebar. 23 * } 24 */ 25 const tests = [ 26 { 27 desc: "Check initial state.", 28 expected: { 29 activeToolbarFilters: [true, false, false, false, false], 30 }, 31 }, 32 { 33 desc: "Toggle first filter (all) to activate.", 34 setup: async ({ doc, toolbox }) => { 35 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 1); 36 }, 37 expected: { 38 activeToolbarFilters: [false, true, true, true, true], 39 }, 40 }, 41 { 42 desc: "Click on the filter again.", 43 setup: async ({ doc, toolbox }) => { 44 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 1); 45 }, 46 expected: { 47 activeToolbarFilters: [true, false, false, false, false], 48 }, 49 }, 50 { 51 desc: "Toggle first custom filter to activate.", 52 setup: async ({ doc, toolbox }) => { 53 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 2); 54 }, 55 expected: { 56 activeToolbarFilters: [false, false, true, false, false], 57 }, 58 }, 59 { 60 desc: "Click on the filter again.", 61 setup: async ({ doc, toolbox }) => { 62 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 2); 63 }, 64 expected: { 65 activeToolbarFilters: [true, false, false, false, false], 66 }, 67 }, 68 { 69 desc: "Toggle first custom filter to activate.", 70 setup: async ({ doc, toolbox }) => { 71 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 2); 72 }, 73 expected: { 74 activeToolbarFilters: [false, false, true, false, false], 75 }, 76 }, 77 { 78 desc: "Toggle second custom filter to activate.", 79 setup: async ({ doc, toolbox }) => { 80 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 3); 81 }, 82 expected: { 83 activeToolbarFilters: [false, false, true, true, false], 84 }, 85 }, 86 { 87 desc: "Toggle third custom filter to activate.", 88 setup: async ({ doc, toolbox }) => { 89 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 4); 90 }, 91 expected: { 92 activeToolbarFilters: [false, true, true, true, true], 93 }, 94 }, 95 { 96 desc: "Click on the none filter to de-activate all.", 97 setup: async ({ doc, toolbox }) => { 98 await toggleMenuItem(doc, toolbox.doc, TREE_FILTERS_MENU_ID, 0); 99 }, 100 expected: { 101 activeToolbarFilters: [true, false, false, false, false], 102 }, 103 }, 104 ]; 105 106 /** 107 * Simple test that checks toggle states for filters in the Accessibility panel 108 * toolbar. 109 */ 110 addA11yPanelTestsTask( 111 tests, 112 TEST_URI, 113 "Test Accessibility panel filter toggle states." 114 );