Bug 1456849 - Part 2: Add test whether the tool tabs are re-arranged when the visibility of toolbox button were changed. r=jdescottes
authorDaisuke Akatsuka <dakatsuka@mozilla.com>
Sun, 29 Apr 2018 10:52:14 +0900
changeset 472321 37463107d7585e9854360a193e84f6ed519fb186
parent 472320 95f8c87c1d97ae309e795c09d5aff376c695156c
child 472323 9ce8f33791e2a157621442758019d9f6fa1d5372
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
bugs1456849
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1456849 - Part 2: Add test whether the tool tabs are re-arranged when the visibility of toolbox button were changed. r=jdescottes MozReview-Commit-ID: 7e3txrVhB9D
devtools/client/framework/test/browser.ini
devtools/client/framework/test/browser_toolbox_toolbar_overflow_button_visibility.js
--- a/devtools/client/framework/test/browser.ini
+++ b/devtools/client/framework/test/browser.ini
@@ -111,16 +111,17 @@ skip-if = e10s # Bug 1069044 - destroyIn
 [browser_toolbox_telemetry_exit.js]
 [browser_toolbox_textbox_context_menu.js]
 [browser_toolbox_theme.js]
 [browser_toolbox_theme_registration.js]
 [browser_toolbox_toggle.js]
 [browser_toolbox_tool_ready.js]
 [browser_toolbox_tool_remote_reopen.js]
 [browser_toolbox_toolbar_overflow.js]
+[browser_toolbox_toolbar_overflow_button_visibility.js]
 [browser_toolbox_toolbar_reorder_by_dnd.js]
 [browser_toolbox_toolbar_reorder_by_width.js]
 [browser_toolbox_toolbar_reorder_with_extension.js]
 [browser_toolbox_tools_per_toolbox_registration.js]
 [browser_toolbox_view_source_01.js]
 [browser_toolbox_view_source_02.js]
 [browser_toolbox_view_source_03.js]
 [browser_toolbox_view_source_04.js]
new file mode 100644
--- /dev/null
+++ b/devtools/client/framework/test/browser_toolbox_toolbar_overflow_button_visibility.js
@@ -0,0 +1,58 @@
+/* -*- 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 for the toolbox tabs rearrangement when the visibility of toolbox buttons were changed.
+
+const { Toolbox } = require("devtools/client/framework/toolbox");
+
+add_task(async function() {
+  const tab = await addTab("about:blank");
+  const toolbox = await openToolboxForTab(tab, "options", Toolbox.HostType.BOTTOM);
+  const toolboxButtonPreferences =
+    toolbox.toolbarButtons.map(button => button.visibilityswitch);
+
+  const win = getWindow(toolbox);
+  const { outerWidth: originalWindowWidth, outerHeight: originalWindowHeight } = win;
+  registerCleanupFunction(() => {
+    for (const preference of toolboxButtonPreferences) {
+      Services.prefs.clearUserPref(preference);
+    }
+
+    win.resizeTo(originalWindowWidth, originalWindowHeight);
+  });
+
+  const optionsTool = toolbox.getCurrentPanel();
+  const checkButtons =
+    optionsTool.panelWin.document
+               .querySelectorAll("#enabled-toolbox-buttons-box input[type=checkbox]");
+
+  info("Test the count of shown devtools tab after making all buttons to be visible");
+  await resizeWindow(toolbox, 800);
+  // Once, make all toolbox button to be invisible.
+  setToolboxButtonsVisibility(checkButtons, false);
+  // Get count of shown devtools tab elements.
+  const initialTabCount = toolbox.doc.querySelectorAll(".devtools-tab").length;
+  // Make all toolbox button to be visible.
+  setToolboxButtonsVisibility(checkButtons, true);
+  ok(toolbox.doc.querySelectorAll(".devtools-tab").length < initialTabCount,
+     "Count of shown devtools tab should decreased");
+
+  info("Test the count of shown devtools tab after making all buttons to be invisible");
+  setToolboxButtonsVisibility(checkButtons, false);
+  is(toolbox.doc.querySelectorAll(".devtools-tab").length, initialTabCount,
+     "Count of shown devtools tab should be same to 1st count");
+});
+
+function setToolboxButtonsVisibility(checkButtons, doVisible) {
+  for (const checkButton of checkButtons) {
+    if (checkButton.checked === doVisible) {
+      continue;
+    }
+
+    checkButton.click();
+  }
+}