summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/test/browser_toolbox_minimize.js
diff options
context:
space:
mode:
authorMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
committerMatt A. Tobin <mattatobin@localhost.localdomain>2018-02-02 04:16:08 -0500
commit5f8de423f190bbb79a62f804151bc24824fa32d8 (patch)
tree10027f336435511475e392454359edea8e25895d /devtools/client/framework/test/browser_toolbox_minimize.js
parent49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff)
downloadUXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz
UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip
Add m-esr52 at 52.6.0
Diffstat (limited to 'devtools/client/framework/test/browser_toolbox_minimize.js')
-rw-r--r--devtools/client/framework/test/browser_toolbox_minimize.js106
1 files changed, 106 insertions, 0 deletions
diff --git a/devtools/client/framework/test/browser_toolbox_minimize.js b/devtools/client/framework/test/browser_toolbox_minimize.js
new file mode 100644
index 000000000..9b5126320
--- /dev/null
+++ b/devtools/client/framework/test/browser_toolbox_minimize.js
@@ -0,0 +1,106 @@
+/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
+/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+// Test that when the toolbox is displayed in a bottom host, that host can be
+// minimized to just the tabbar height, and maximized again.
+// Also test that while minimized, switching to a tool, clicking on the
+// settings, or clicking on the selected tool's tab maximizes the toolbox again.
+// Finally test that the minimize button doesn't exist in other host types.
+
+const URL = "data:text/html;charset=utf8,test page";
+const {Toolbox} = require("devtools/client/framework/toolbox");
+
+add_task(function* () {
+ info("Create a test tab and open the toolbox");
+ let tab = yield addTab(URL);
+ let target = TargetFactory.forTab(tab);
+ let toolbox = yield gDevTools.showToolbox(target, "webconsole");
+
+ let button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
+ ok(button, "The minimize button exists in the default bottom host");
+
+ info("Try to minimize the toolbox");
+ yield minimize(toolbox);
+ ok(parseInt(toolbox._host.frame.style.marginBottom, 10) < 0,
+ "The toolbox host has been hidden away with a negative-margin");
+
+ info("Try to maximize again the toolbox");
+ yield maximize(toolbox);
+ ok(parseInt(toolbox._host.frame.style.marginBottom, 10) == 0,
+ "The toolbox host is shown again");
+
+ info("Try to minimize again using the keyboard shortcut");
+ yield minimizeWithShortcut(toolbox);
+ ok(parseInt(toolbox._host.frame.style.marginBottom, 10) < 0,
+ "The toolbox host has been hidden away with a negative-margin");
+
+ info("Try to maximize again using the keyboard shortcut");
+ yield maximizeWithShortcut(toolbox);
+ ok(parseInt(toolbox._host.frame.style.marginBottom, 10) == 0,
+ "The toolbox host is shown again");
+
+ info("Minimize again and switch to another tool");
+ yield minimize(toolbox);
+ let onMaximized = toolbox._host.once("maximized");
+ yield toolbox.selectTool("inspector");
+ yield onMaximized;
+
+ info("Minimize again and click on the tab of the current tool");
+ yield minimize(toolbox);
+ onMaximized = toolbox._host.once("maximized");
+ let tabButton = toolbox.doc.querySelector("#toolbox-tab-inspector");
+ EventUtils.synthesizeMouseAtCenter(tabButton, {}, toolbox.win);
+ yield onMaximized;
+
+ info("Minimize again and click on the settings tab");
+ yield minimize(toolbox);
+ onMaximized = toolbox._host.once("maximized");
+ let settingsButton = toolbox.doc.querySelector("#toolbox-tab-options");
+ EventUtils.synthesizeMouseAtCenter(settingsButton, {}, toolbox.win);
+ yield onMaximized;
+
+ info("Switch to a different host");
+ yield toolbox.switchHost(Toolbox.HostType.SIDE);
+ button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
+ ok(!button, "The minimize button doesn't exist in the side host");
+
+ Services.prefs.clearUserPref("devtools.toolbox.host");
+ yield toolbox.destroy();
+ gBrowser.removeCurrentTab();
+});
+
+function* minimize(toolbox) {
+ let button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
+ let onMinimized = toolbox._host.once("minimized");
+ EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.win);
+ yield onMinimized;
+}
+
+function* minimizeWithShortcut(toolbox) {
+ let key = toolbox.doc.getElementById("toolbox-minimize-key")
+ .getAttribute("key");
+ let onMinimized = toolbox._host.once("minimized");
+ EventUtils.synthesizeKey(key, {accelKey: true, shiftKey: true},
+ toolbox.win);
+ yield onMinimized;
+}
+
+function* maximize(toolbox) {
+ let button = toolbox.doc.querySelector("#toolbox-dock-bottom-minimize");
+ let onMaximized = toolbox._host.once("maximized");
+ EventUtils.synthesizeMouseAtCenter(button, {}, toolbox.win);
+ yield onMaximized;
+}
+
+function* maximizeWithShortcut(toolbox) {
+ let key = toolbox.doc.getElementById("toolbox-minimize-key")
+ .getAttribute("key");
+ let onMaximized = toolbox._host.once("maximized");
+ EventUtils.synthesizeKey(key, {accelKey: true, shiftKey: true},
+ toolbox.win);
+ yield onMaximized;
+}