browser_keybindings_02.js (1747B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Test that the toolbox keybindings still work after the host is changed. 7 8 const URL = "data:text/html;charset=utf8,test page"; 9 10 var { Toolbox } = require("resource://devtools/client/framework/toolbox.js"); 11 12 const L10N = new LocalizationHelper( 13 "devtools/client/locales/toolbox.properties" 14 ); 15 16 function getZoomValue() { 17 return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue")); 18 } 19 20 add_task(async function () { 21 info("Create a test tab and open the toolbox"); 22 const tab = await addTab(URL); 23 const toolbox = await gDevTools.showToolboxForTab(tab, "webconsole"); 24 25 const { RIGHT, BOTTOM } = Toolbox.HostType; 26 for (const type of [RIGHT, BOTTOM, RIGHT]) { 27 info("Switch to host type " + type); 28 await toolbox.switchHost(type); 29 30 info("Try to use the toolbox shortcuts"); 31 await checkKeyBindings(toolbox); 32 } 33 34 await toolbox.destroy(); 35 gBrowser.removeCurrentTab(); 36 }); 37 38 function zoomWithKey(toolbox, key) { 39 const shortcut = L10N.getStr(key); 40 if (!shortcut) { 41 info("Key was empty, skipping zoomWithKey"); 42 return; 43 } 44 info("Zooming with key: " + key); 45 const currentZoom = getZoomValue(); 46 synthesizeKeyShortcut(shortcut, toolbox.win); 47 isnot( 48 getZoomValue(), 49 currentZoom, 50 "The zoom level was changed in the toolbox" 51 ); 52 } 53 54 function checkKeyBindings(toolbox) { 55 zoomWithKey(toolbox, "toolbox.zoomIn.key"); 56 zoomWithKey(toolbox, "toolbox.zoomIn2.key"); 57 58 zoomWithKey(toolbox, "toolbox.zoomReset.key"); 59 60 zoomWithKey(toolbox, "toolbox.zoomOut.key"); 61 zoomWithKey(toolbox, "toolbox.zoomOut2.key"); 62 63 zoomWithKey(toolbox, "toolbox.zoomReset2.key"); 64 }