Bug 1948259 - Add menu item to hide/show Extensions Button in Customize mode r=willdurand,fluent-reviewers,bolsson
Bug 1948258 added a way to hide the Extensions Button, but not a way to show it. This patch makes the following changes: - always show the Extensions button in Customization mode, even if the user wants to hide the button unconditionally. - add menu item to toggle the visibility of the Extensions Button. - the new menu item is not shown anywhere except on the Extensions Button in Customization mode. Differential Revision: https://phabricator.services.mozilla.com/D248158
This commit is contained in:
@@ -13,32 +13,6 @@ const { ExtensionPermissions } = ChromeUtils.importESModule(
|
||||
|
||||
loadTestSubscript("head_unified_extensions.js");
|
||||
|
||||
const openCustomizationUI = async () => {
|
||||
const customizationReady = BrowserTestUtils.waitForEvent(
|
||||
gNavToolbox,
|
||||
"customizationready"
|
||||
);
|
||||
gCustomizeMode.enter();
|
||||
await customizationReady;
|
||||
ok(
|
||||
CustomizationHandler.isCustomizing(),
|
||||
"expected customizing mode to be enabled"
|
||||
);
|
||||
};
|
||||
|
||||
const closeCustomizationUI = async () => {
|
||||
const afterCustomization = BrowserTestUtils.waitForEvent(
|
||||
gNavToolbox,
|
||||
"aftercustomization"
|
||||
);
|
||||
gCustomizeMode.exit();
|
||||
await afterCustomization;
|
||||
ok(
|
||||
!CustomizationHandler.isCustomizing(),
|
||||
"expected customizing mode to be disabled"
|
||||
);
|
||||
};
|
||||
|
||||
add_setup(async function () {
|
||||
// Make sure extension buttons added to the navbar will not overflow in the
|
||||
// panel, which could happen when a previous test file resizes the current
|
||||
|
||||
@@ -98,3 +98,114 @@ add_task(async function test_hide_button_via_contextmenu() {
|
||||
resetButtonVisibilityToDefault();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Until the the "Hide Extensions Button" feature finished its implementation,
|
||||
// the UI to trigger hiding should be disabled by default.
|
||||
add_task(async function test_customization_disabled_by_default() {
|
||||
await openCustomizationUI();
|
||||
const contextMenu = await openChromeContextMenu(
|
||||
"toolbar-context-menu",
|
||||
"#wrapper-unified-extensions-button"
|
||||
);
|
||||
const item = document.getElementById(
|
||||
"toolbar-context-always-show-extensions-button"
|
||||
);
|
||||
is(item.hidden, true, "Not expecting menu item to hide button");
|
||||
await closeChromeContextMenu(contextMenu.id);
|
||||
await closeCustomizationUI();
|
||||
});
|
||||
|
||||
add_task(async function test_customization_option_hidden_if_not_customizing() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.unifiedExtensions.button.customizable", true]],
|
||||
});
|
||||
const contextMenu = await openChromeContextMenu(
|
||||
"toolbar-context-menu",
|
||||
"#unified-extensions-button"
|
||||
);
|
||||
const item = document.getElementById(
|
||||
"toolbar-context-always-show-extensions-button"
|
||||
);
|
||||
is(item.hidden, true, "Not expecting menu item to hide button");
|
||||
await closeChromeContextMenu(contextMenu.id);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
// Tests that the "Always Show in Toolbar" checkbox is visible in the menu and
|
||||
// reflects the expected state when entering/exiting customization mode.
|
||||
// And that the Extensions Button is always shown while in customization mode.
|
||||
add_task(async function test_customization_button_and_menu_item_visibility() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["extensions.unifiedExtensions.button.customizable", true]],
|
||||
});
|
||||
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
|
||||
await openCustomizationUI(win);
|
||||
{
|
||||
info("Toggle checkbox via context menu, from on to off");
|
||||
const contextMenu = await openChromeContextMenu(
|
||||
"toolbar-context-menu",
|
||||
"#wrapper-unified-extensions-button",
|
||||
win
|
||||
);
|
||||
const item = win.document.getElementById(
|
||||
"toolbar-context-always-show-extensions-button"
|
||||
);
|
||||
is(item.hidden, false, "Menu item should be visible");
|
||||
is(item.getAttribute("checked"), "true", "Should be checked by default");
|
||||
await closeChromeContextMenu(contextMenu.id, item, win);
|
||||
|
||||
info("The button should still be visible while customizing");
|
||||
assertExtensionsButtonVisible(win);
|
||||
info("The button should be hidden in windows that are not customizing");
|
||||
assertExtensionsButtonHidden();
|
||||
}
|
||||
|
||||
{
|
||||
info("Open context menu to verify checked state, then cancel menu");
|
||||
const contextMenu = await openChromeContextMenu(
|
||||
"toolbar-context-menu",
|
||||
"#wrapper-unified-extensions-button",
|
||||
win
|
||||
);
|
||||
const item = win.document.getElementById(
|
||||
"toolbar-context-always-show-extensions-button"
|
||||
);
|
||||
is(item.hidden, false, "Menu item should be visible");
|
||||
ok(!item.getAttribute("checked"), "Should be unchecked by earlier action");
|
||||
await closeChromeContextMenu(contextMenu.id, null, win);
|
||||
}
|
||||
|
||||
await closeCustomizationUI(win);
|
||||
info("The button should be hidden after exiting customization");
|
||||
assertExtensionsButtonHidden(win);
|
||||
|
||||
await openCustomizationUI(win);
|
||||
info("The button should be visible upon entering customization");
|
||||
assertExtensionsButtonVisible(win);
|
||||
{
|
||||
info("Toggle checkbox via context menu, from off to on");
|
||||
const contextMenu = await openChromeContextMenu(
|
||||
"toolbar-context-menu",
|
||||
"#wrapper-unified-extensions-button",
|
||||
win
|
||||
);
|
||||
const item = win.document.getElementById(
|
||||
"toolbar-context-always-show-extensions-button"
|
||||
);
|
||||
is(item.hidden, false, "Menu item should be visible");
|
||||
ok(!item.hasAttribute("checked"), "Should be unchecked");
|
||||
await closeChromeContextMenu(contextMenu.id, item, win);
|
||||
|
||||
info("After checking the option, buttons should be shown in all windows");
|
||||
assertExtensionsButtonVisible(win);
|
||||
assertExtensionsButtonVisible();
|
||||
}
|
||||
|
||||
await closeCustomizationUI(win);
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
|
||||
resetButtonVisibilityToDefault();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
});
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
/* exported assertExtensionsButtonHidden,
|
||||
assertExtensionsButtonVisible,
|
||||
clickUnifiedExtensionsItem,
|
||||
closeCustomizationUI,
|
||||
closeExtensionsPanel,
|
||||
createExtensions,
|
||||
ensureMaximizedWindow,
|
||||
@@ -14,6 +15,7 @@
|
||||
getMessageBars,
|
||||
getUnifiedExtensionsItem,
|
||||
loadBlocklistRawData,
|
||||
openCustomizationUI,
|
||||
openExtensionsPanel,
|
||||
openUnifiedExtensionsContextMenu,
|
||||
promiseSetToolbarVisibility
|
||||
@@ -149,6 +151,32 @@ const createExtensions = (
|
||||
);
|
||||
};
|
||||
|
||||
const openCustomizationUI = async (win = window) => {
|
||||
const customizationReady = BrowserTestUtils.waitForEvent(
|
||||
win.gNavToolbox,
|
||||
"customizationready"
|
||||
);
|
||||
win.gCustomizeMode.enter();
|
||||
await customizationReady;
|
||||
ok(
|
||||
win.CustomizationHandler.isCustomizing(),
|
||||
"expected customizing mode to be enabled"
|
||||
);
|
||||
};
|
||||
|
||||
const closeCustomizationUI = async (win = window) => {
|
||||
const afterCustomization = BrowserTestUtils.waitForEvent(
|
||||
win.gNavToolbox,
|
||||
"aftercustomization"
|
||||
);
|
||||
win.gCustomizeMode.exit();
|
||||
await afterCustomization;
|
||||
ok(
|
||||
!win.CustomizationHandler.isCustomizing(),
|
||||
"expected customizing mode to be disabled"
|
||||
);
|
||||
};
|
||||
|
||||
const ensureStableDimensions = async win => {
|
||||
let lastOuterWidth = win.outerWidth;
|
||||
let lastOuterHeight = win.outerHeight;
|
||||
|
||||
Reference in New Issue
Block a user