diff options
Diffstat (limited to '')
-rw-r--r-- | devtools/client/framework/test/browser_toolbox_options_panel_toggle.js | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_toolbox_options_panel_toggle.js b/devtools/client/framework/test/browser_toolbox_options_panel_toggle.js new file mode 100644 index 0000000000..d94f7c14fb --- /dev/null +++ b/devtools/client/framework/test/browser_toolbox_options_panel_toggle.js @@ -0,0 +1,82 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +// Test whether options panel toggled by key event and "Settings" on the meatball menu. + +const { Toolbox } = require("resource://devtools/client/framework/toolbox.js"); + +add_task(async function () { + const tab = await addTab("about:blank"); + const toolbox = await openToolboxForTab( + tab, + "webconsole", + Toolbox.HostType.BOTTOM + ); + + info("Check the option panel was selected after sending F1 key event"); + await sendOptionsKeyEvent(toolbox); + is(toolbox.currentToolId, "options", "The options panel should be selected"); + + info("Check the last selected panel was selected after sending F1 key event"); + await sendOptionsKeyEvent(toolbox); + is( + toolbox.currentToolId, + "webconsole", + "The webconsole panel should be selected" + ); + + info("Check the option panel was selected after clicking 'Settings' menu"); + await clickSettingsMenu(toolbox); + is(toolbox.currentToolId, "options", "The options panel should be selected"); + + info( + "Check the last selected panel was selected after clicking 'Settings' menu" + ); + await sendOptionsKeyEvent(toolbox); + is( + toolbox.currentToolId, + "webconsole", + "The webconsole panel should be selected" + ); + + info("Check the combination of key event and 'Settings' menu"); + await sendOptionsKeyEvent(toolbox); + await clickSettingsMenu(toolbox); + is( + toolbox.currentToolId, + "webconsole", + "The webconsole panel should be selected" + ); + await clickSettingsMenu(toolbox); + await sendOptionsKeyEvent(toolbox); + is( + toolbox.currentToolId, + "webconsole", + "The webconsole panel should be selected" + ); +}); + +async function sendOptionsKeyEvent(toolbox) { + const onReady = toolbox.once("select"); + EventUtils.synthesizeKey("VK_F1", {}, toolbox.win); + await onReady; +} + +async function clickSettingsMenu(toolbox) { + const onPopupShown = () => { + toolbox.doc.removeEventListener("popupshown", onPopupShown); + const menuItem = toolbox.doc.getElementById( + "toolbox-meatball-menu-settings" + ); + EventUtils.synthesizeMouseAtCenter(menuItem, {}, menuItem.ownerGlobal); + }; + toolbox.doc.addEventListener("popupshown", onPopupShown); + + const button = toolbox.doc.getElementById("toolbox-meatball-menu-button"); + await waitUntil(() => button.style.pointerEvents !== "none"); + EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerGlobal); + + await toolbox.once("select"); +} |