browser_accessibility_panel_toolbar_pref_scroll.js (1998B)
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, PREFS_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 const { 17 PREFS: { SCROLL_INTO_VIEW }, 18 } = require("resource://devtools/client/accessibility/constants.js"); 19 20 /** 21 * Test data has the format of: 22 * { 23 * desc {String} description for better logging 24 * setup {Function} An optional setup that needs to be performed before 25 * the state of the tree and the sidebar can be checked. 26 * expected {JSON} An expected states for the tree and the sidebar. 27 * } 28 */ 29 const tests = [ 30 { 31 desc: "Check initial state. All filters are disabled (except none). Scroll into view pref disabled.", 32 expected: { 33 activeToolbarFilters: [true, false, false, false], 34 toolbarPrefValues: { 35 [SCROLL_INTO_VIEW]: false, 36 }, 37 }, 38 }, 39 { 40 desc: "Toggle scroll into view checkbox to set the pref. Scroll into view pref should be enabled.", 41 setup: async ({ doc, toolbox }) => { 42 await toggleMenuItem(doc, toolbox.doc, PREFS_MENU_ID, 0); 43 }, 44 expected: { 45 activeToolbarFilters: [true, false, false, false], 46 toolbarPrefValues: { 47 [SCROLL_INTO_VIEW]: true, 48 }, 49 }, 50 }, 51 { 52 desc: "Toggle off scroll into view checkbox to unset the pref. Scroll into view pref disabled.", 53 setup: async ({ doc, toolbox }) => { 54 await toggleMenuItem(doc, toolbox.doc, PREFS_MENU_ID, 0); 55 }, 56 expected: { 57 activeToolbarFilters: [true, false, false, false], 58 toolbarPrefValues: { 59 [SCROLL_INTO_VIEW]: false, 60 }, 61 }, 62 }, 63 ]; 64 65 /** 66 * Simple test that checks toggle state and pref set for automatic scroll into 67 * view setting. 68 */ 69 addA11yPanelTestsTask( 70 tests, 71 TEST_URI, 72 "Test Accessibility panel scroll into view pref." 73 );