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

--HG--
extra : rebase_source : 72b9ee9992ebdf805b298d26bf1584294606f159
This commit is contained in:
Daisuke Akatsuka 2018-04-29 10:52:14 +09:00
parent bd4daf957a
commit 4529af68fb
2 changed files with 59 additions and 0 deletions

View File

@ -116,6 +116,7 @@ skip-if = e10s # Bug 1069044 - destroyInspector may hang during shutdown
[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]

View File

@ -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();
}
}