summaryrefslogtreecommitdiffstats
path: root/devtools/client/framework/test/xpcshell
diff options
context:
space:
mode:
Diffstat (limited to 'devtools/client/framework/test/xpcshell')
-rw-r--r--devtools/client/framework/test/xpcshell/.eslintrc.js6
-rw-r--r--devtools/client/framework/test/xpcshell/test_tabs_absolute_order.js79
-rw-r--r--devtools/client/framework/test/xpcshell/xpcshell.ini6
3 files changed, 91 insertions, 0 deletions
diff --git a/devtools/client/framework/test/xpcshell/.eslintrc.js b/devtools/client/framework/test/xpcshell/.eslintrc.js
new file mode 100644
index 0000000000..7f6b62a9e5
--- /dev/null
+++ b/devtools/client/framework/test/xpcshell/.eslintrc.js
@@ -0,0 +1,6 @@
+"use strict";
+
+module.exports = {
+ // Extend from the shared list of defined globals for mochitests.
+ extends: "../../../../.eslintrc.xpcshell.js",
+};
diff --git a/devtools/client/framework/test/xpcshell/test_tabs_absolute_order.js b/devtools/client/framework/test/xpcshell/test_tabs_absolute_order.js
new file mode 100644
index 0000000000..9f2220ed81
--- /dev/null
+++ b/devtools/client/framework/test/xpcshell/test_tabs_absolute_order.js
@@ -0,0 +1,79 @@
+/* Any copyright is dedicated to the Public Domain.
+ http://creativecommons.org/publicdomain/zero/1.0/ */
+
+"use strict";
+
+const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm");
+
+const TEST_DATA = [
+ {
+ description: "Test for no order in preference",
+ preferenceOrder: [],
+ currentTabsOrder: ["T1", "T2", "T3", "T4", "T5"],
+ dragTarget: "T1",
+ expectedOrder: ["T1", "T2", "T3", "T4", "T5"],
+ },
+ {
+ description: "Test for drag a tab to left with hidden tab",
+ preferenceOrder: ["T1", "T2", "T3", "E1", "T4", "T5"],
+ currentTabsOrder: ["T1", "T2", "T4", "T3", "T5"],
+ dragTarget: "T4",
+ expectedOrder: ["T1", "T2", "T4", "T3", "E1", "T5"],
+ },
+ {
+ description: "Test for drag a tab to right with hidden tab",
+ preferenceOrder: ["T1", "T2", "T3", "E1", "T4", "T5"],
+ currentTabsOrder: ["T1", "T3", "T4", "T2", "T5"],
+ dragTarget: "T2",
+ expectedOrder: ["T1", "T3", "E1", "T4", "T2", "T5"],
+ },
+ {
+ description:
+ "Test for drag a tab to left end in case hidden tab was left end",
+ preferenceOrder: ["E1", "T1", "T2", "T3", "T4", "T5"],
+ currentTabsOrder: ["T4", "T1", "T2", "T3", "T5"],
+ dragTarget: "T4",
+ expectedOrder: ["E1", "T4", "T1", "T2", "T3", "T5"],
+ },
+ {
+ description:
+ "Test for drag a tab to right end in case hidden tab was right end",
+ preferenceOrder: ["T1", "T2", "T3", "T4", "T5", "E1"],
+ currentTabsOrder: ["T2", "T3", "T4", "T5", "T1"],
+ dragTarget: "T1",
+ expectedOrder: ["T2", "T3", "T4", "T5", "E1", "T1"],
+ },
+ {
+ description: "Test for multiple hidden tabs",
+ preferenceOrder: ["T1", "T2", "E1", "E2", "E3", "E4"],
+ currentTabsOrder: ["T2", "T1"],
+ dragTarget: "T1",
+ expectedOrder: ["T2", "E1", "E2", "E3", "E4", "T1"],
+ },
+];
+
+function run_test() {
+ const {
+ toAbsoluteOrder,
+ } = require("devtools/client/framework/toolbox-tabs-order-manager");
+
+ for (const {
+ description,
+ preferenceOrder,
+ currentTabsOrder,
+ dragTarget,
+ expectedOrder,
+ } of TEST_DATA) {
+ info(description);
+ const resultOrder = toAbsoluteOrder(
+ preferenceOrder,
+ currentTabsOrder,
+ dragTarget
+ );
+ equal(
+ resultOrder.join(","),
+ expectedOrder.join(","),
+ "Result should be correct"
+ );
+ }
+}
diff --git a/devtools/client/framework/test/xpcshell/xpcshell.ini b/devtools/client/framework/test/xpcshell/xpcshell.ini
new file mode 100644
index 0000000000..6f68037a48
--- /dev/null
+++ b/devtools/client/framework/test/xpcshell/xpcshell.ini
@@ -0,0 +1,6 @@
+[DEFAULT]
+tags = devtools
+firefox-appdir = browser
+skip-if = toolkit == 'android'
+
+[test_tabs_absolute_order.js]