summaryrefslogtreecommitdiffstats
path: root/devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js')
-rw-r--r--devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js78
1 files changed, 78 insertions, 0 deletions
diff --git a/devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js b/devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js
new file mode 100644
index 0000000000..f7390feb6b
--- /dev/null
+++ b/devtools/client/debugger/test/mochitest/browser_dbg-layout-changes.js
@@ -0,0 +1,78 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */
+
+/**
+ * This if the debugger's layout is correctly modified when the toolbox's
+ * host changes.
+ */
+requestLongerTimeout(2);
+
+let gDefaultHostType = Services.prefs.getCharPref("devtools.toolbox.host");
+
+add_task(async function() {
+ // test is too slow on some platforms due to the number of test cases
+ const dbg = await initDebugger("doc-iframes.html");
+
+ const layouts = [
+ ["vertical", "window:small"],
+ ["horizontal", "bottom"],
+ ["vertical", "right"],
+ ["horizontal", "window:big"]
+ ];
+
+ for (const layout of layouts) {
+ const [orientation, host] = layout;
+ await testLayout(dbg, orientation, host);
+ }
+
+ ok(true, "Orientations are correct");
+});
+
+async function testLayout(dbg, orientation, host) {
+ info(`Switching to ${host} ${orientation}.`);
+
+ await switchHost(dbg, host);
+ await resizeToolboxWindow(dbg, host);
+ return waitForState(
+ dbg,
+ state => dbg.selectors.getOrientation() == orientation
+ );
+}
+
+function getHost(host) {
+ if (host.indexOf("window") == 0) {
+ return "window";
+ }
+ return host;
+}
+
+async function switchHost(dbg, hostType) {
+ const { toolbox } = dbg;
+ await toolbox.switchHost(getHost(hostType));
+}
+
+function resizeToolboxWindow(dbg, host) {
+ const { panel, toolbox } = dbg;
+ const sizeOption = host.split(":")[1];
+ const win = toolbox.win.parent;
+
+ const breakpoint = 800;
+ if (sizeOption == "big" && win.outerWidth <= breakpoint) {
+ return resizeWindow(dbg, breakpoint + 300);
+ } else if (sizeOption == "small" && win.outerWidth >= breakpoint) {
+ return resizeWindow(dbg, breakpoint - 300);
+ }
+}
+
+function resizeWindow(dbg, width) {
+ const { panel, toolbox } = dbg;
+ const win = toolbox.win.parent;
+ const currentWidth = win.screen.width;
+ win.resizeTo(width, window.screen.availHeight);
+}
+
+registerCleanupFunction(function() {
+ Services.prefs.setCharPref("devtools.toolbox.host", gDefaultHostType);
+ gDefaultHostType = null;
+});