browser_keybindings_03.js (1627B)
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 'switch to previous host' feature works. 7 // Pressing ctrl/cmd+shift+d should switch to the last used host. 8 9 const URL = "data:text/html;charset=utf8,test page for toolbox switching"; 10 11 var { Toolbox } = require("resource://devtools/client/framework/toolbox.js"); 12 13 const L10N = new LocalizationHelper( 14 "devtools/client/locales/toolbox.properties" 15 ); 16 17 add_task(async function () { 18 info("Create a test tab and open the toolbox"); 19 const tab = await addTab(URL); 20 const toolbox = await gDevTools.showToolboxForTab(tab, "webconsole"); 21 22 const shortcut = L10N.getStr("toolbox.toggleHost.key"); 23 24 const { RIGHT, BOTTOM, WINDOW } = Toolbox.HostType; 25 checkHostType(toolbox, BOTTOM, RIGHT); 26 27 info("Switching from bottom to right"); 28 let onHostChanged = toolbox.once("host-changed"); 29 synthesizeKeyShortcut(shortcut, toolbox.win); 30 await onHostChanged; 31 checkHostType(toolbox, RIGHT, BOTTOM); 32 33 info("Switching from right to bottom"); 34 onHostChanged = toolbox.once("host-changed"); 35 synthesizeKeyShortcut(shortcut, toolbox.win); 36 await onHostChanged; 37 checkHostType(toolbox, BOTTOM, RIGHT); 38 39 info("Switching to window"); 40 await toolbox.switchHost(WINDOW); 41 checkHostType(toolbox, WINDOW, BOTTOM); 42 43 info("Switching from window to bottom"); 44 onHostChanged = toolbox.once("host-changed"); 45 synthesizeKeyShortcut(shortcut, toolbox.win); 46 await onHostChanged; 47 checkHostType(toolbox, BOTTOM, WINDOW); 48 49 await toolbox.destroy(); 50 gBrowser.removeCurrentTab(); 51 });