Bug 1457067 - Part 2: Add test whether options panel toggled by key event and Settings on the meatball menu. r=jdescottes, a=RyanVM
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Fri, 11 May 2018 07:35:26 +0900
changeset 473328 d7cc3e2fa65b9a59ed4280aa178fa7cf08f004e7
parent 473327 b3f260301d0e1e4441bb1e6ae9bbb93bc6f487db
child 473329 9c5f236d1dd40bb2b5478ed69104c9785b7caa1c
push id1728
push userjlund@mozilla.com
push dateMon, 18 Jun 2018 21:12:27 +0000
treeherdermozilla-release@c296fde26f5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, RyanVM
bugs1457067
milestone61.0
Bug 1457067 - Part 2: Add test whether options panel toggled by key event and Settings on the meatball menu. r=jdescottes, a=RyanVM 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
@@ -84,16 +84,17 @@ skip-if = os == 'win' || debug # Bug 128
 skip-if = os == "mac" # Full keyboard navigation on OSX only works if Full Keyboard Access setting is set to All Control in System Keyboard Preferences
 [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_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");
+}