Bug 1457067 - Part 2: Add test whether options panel toggled by key event and Settings on the meatball menu. r?jdescottes draft
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 11 May 2018 07:35:26 +0900
changeset 793905 b7637082d40d9cc3dfa447a6664d5a489638ab1e
parent 793904 7f23c06e7424f1212068c32e551314ba5117b4d8
push id109526
push userbmo:dakatsuka@mozilla.com
push dateThu, 10 May 2018 22:36:57 +0000
reviewersjdescottes
bugs1457067
milestone62.0a1
Bug 1457067 - Part 2: Add test whether options panel toggled by key event and Settings on the meatball menu. r?jdescottes MozReview-Commit-ID: 4bSeh8kkTx6
devtools/client/framework/test/browser.ini
devtools/client/framework/test/browser_toolbox_options_panel_toggle.js
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -86,16 +86,17 @@ skip-if = os == "mac" # Full keyboard na
 [browser_toolbox_options.js]
 [browser_toolbox_options_multiple_tabs.js]
 [browser_toolbox_options_disable_buttons.js]
 [browser_toolbox_options_disable_cache-01.js]
 [browser_toolbox_options_disable_cache-02.js]
 [browser_toolbox_options_disable_js.js]
 [browser_toolbox_options_enable_serviceworkers_testing.js]
 [browser_toolbox_options_frames_button.js]
+[browser_toolbox_options_panel_toggle.js]
 [browser_toolbox_raise.js]
 disabled=Bug 962258
 [browser_toolbox_races.js]
 [browser_toolbox_ready.js]
 [browser_toolbox_remoteness_change.js]
 run-if = e10s
 [browser_toolbox_select_event.js]
 skip-if = e10s # Bug 1069044 - destroyInspector may hang during shutdown
new file mode 100644
--- /dev/null
+++ b/devtools/client/framework/test/browser_toolbox_options_panel_toggle.js
@@ -0,0 +1,57 @@
+/* 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("devtools/client/framework/toolbox");
+
+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("popuphidden", 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");
+  EventUtils.synthesizeMouseAtCenter(button, {}, button.ownerGlobal);
+
+  await toolbox.once("select");
+}