Bug 1944931 - Ensure sidebar.visibility gets set when vertical tabs are enabled. r=sidebar-reviewers,sclements,nsharpley
Differential Revision: https://phabricator.services.mozilla.com/D236447
This commit is contained in:
@@ -148,6 +148,11 @@ add_setup(async function () {
|
|||||||
// The page actions button is not normally visible, so we must
|
// The page actions button is not normally visible, so we must
|
||||||
// unhide it.
|
// unhide it.
|
||||||
BrowserPageActions.mainButtonNode.style.visibility = "visible";
|
BrowserPageActions.mainButtonNode.style.visibility = "visible";
|
||||||
|
|
||||||
|
// Make sure the sidebar launcher is visible (when sidebar.revamp is true);
|
||||||
|
// previous tests might have hidden it.
|
||||||
|
await SidebarController.initializeUIState({ launcherVisible: true });
|
||||||
|
|
||||||
registerCleanupFunction(() => {
|
registerCleanupFunction(() => {
|
||||||
BrowserPageActions.mainButtonNode.style.removeProperty("visibility");
|
BrowserPageActions.mainButtonNode.style.removeProperty("visibility");
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,12 +21,14 @@ add_setup(async function setup() {
|
|||||||
registerCleanupFunction(async () => {
|
registerCleanupFunction(async () => {
|
||||||
SidebarController.hide();
|
SidebarController.hide();
|
||||||
});
|
});
|
||||||
|
await SidebarController.initializeUIState({ launcherVisible: true });
|
||||||
});
|
});
|
||||||
|
|
||||||
add_task(async function test_integrated_sidebar() {
|
add_task(async function test_integrated_sidebar() {
|
||||||
await BrowserTestUtils.withNewTab(CONTENT_PAGE, async function (browser) {
|
await BrowserTestUtils.withNewTab(CONTENT_PAGE, async function (browser) {
|
||||||
const { document } = browser.ownerGlobal;
|
const { document } = browser.ownerGlobal;
|
||||||
let sidebar = document.querySelector("sidebar-main");
|
let sidebar = document.querySelector("sidebar-main");
|
||||||
|
await sidebar.updateComplete;
|
||||||
let reviewCheckerButton = await TestUtils.waitForCondition(
|
let reviewCheckerButton = await TestUtils.waitForCondition(
|
||||||
() =>
|
() =>
|
||||||
sidebar.shadowRoot.querySelector(
|
sidebar.shadowRoot.querySelector(
|
||||||
|
|||||||
@@ -20,11 +20,15 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||||||
"sidebarBackupState",
|
"sidebarBackupState",
|
||||||
BACKUP_STATE_PREF
|
BACKUP_STATE_PREF
|
||||||
);
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
lazy,
|
lazy,
|
||||||
"verticalTabsEnabled",
|
"verticalTabsEnabled",
|
||||||
"sidebar.verticalTabs",
|
"sidebar.verticalTabs",
|
||||||
false
|
false,
|
||||||
|
(pref, oldVal, newVal) => {
|
||||||
|
SidebarManager.handleVerticalTabsPrefChange(newVal);
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
export const SidebarManager = {
|
export const SidebarManager = {
|
||||||
@@ -74,7 +78,16 @@ export const SidebarManager = {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!lazy.verticalTabsEnabled) {
|
this.handleVerticalTabsPrefChange(lazy.verticalTabsEnabled);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust for a change to the verticalTabs pref.
|
||||||
|
*/
|
||||||
|
handleVerticalTabsPrefChange(isEnabled) {
|
||||||
|
if (isEnabled) {
|
||||||
|
Services.prefs.setStringPref(VISIBILITY_SETTING_PREF, "always-show");
|
||||||
|
} else {
|
||||||
Services.prefs.setStringPref(VISIBILITY_SETTING_PREF, "hide-sidebar");
|
Services.prefs.setStringPref(VISIBILITY_SETTING_PREF, "hide-sidebar");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1980,6 +1980,7 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
SidebarController,
|
SidebarController,
|
||||||
"sidebarRevampVisibility",
|
"sidebarRevampVisibility",
|
||||||
@@ -1989,19 +1990,21 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||||||
if (!SidebarController.inPopup && !SidebarController.uninitializing) {
|
if (!SidebarController.inPopup && !SidebarController.uninitializing) {
|
||||||
SidebarController.toggleExpandOnHover(newValue === "expand-on-hover");
|
SidebarController.toggleExpandOnHover(newValue === "expand-on-hover");
|
||||||
SidebarController.recordVisibilitySetting(newValue);
|
SidebarController.recordVisibilitySetting(newValue);
|
||||||
SidebarController._state.revampVisibility = newValue;
|
if (SidebarController._state) {
|
||||||
SidebarController._state.updateVisibility(
|
const isVerticalTabs = SidebarController.sidebarVerticalTabsEnabled;
|
||||||
(newValue != "hide-sidebar" &&
|
SidebarController._state.revampVisibility = newValue;
|
||||||
SidebarController.sidebarVerticalTabsEnabled) ||
|
SidebarController._state.updateVisibility(
|
||||||
!SidebarController.sidebarVerticalTabsEnabled,
|
(newValue != "hide-sidebar" && isVerticalTabs) || !isVerticalTabs,
|
||||||
false,
|
false,
|
||||||
false,
|
false,
|
||||||
newValue !== "expand-on-hover"
|
newValue !== "expand-on-hover"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
SidebarController.updateToolbarButton();
|
SidebarController.updateToolbarButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
XPCOMUtils.defineLazyPreferenceGetter(
|
XPCOMUtils.defineLazyPreferenceGetter(
|
||||||
SidebarController,
|
SidebarController,
|
||||||
"sidebarVerticalTabsEnabled",
|
"sidebarVerticalTabsEnabled",
|
||||||
@@ -2010,10 +2013,6 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
|||||||
(_aPreference, _previousValue, newValue) => {
|
(_aPreference, _previousValue, newValue) => {
|
||||||
if (!SidebarController.uninitializing && !SidebarController.inPopup) {
|
if (!SidebarController.uninitializing && !SidebarController.inPopup) {
|
||||||
SidebarController.recordTabsLayoutSetting(newValue);
|
SidebarController.recordTabsLayoutSetting(newValue);
|
||||||
Services.prefs.setStringPref(
|
|
||||||
SidebarController.VISIBILITY_PREF,
|
|
||||||
newValue ? "always-show" : "hide-sidebar"
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -5,11 +5,13 @@
|
|||||||
|
|
||||||
add_setup(async () => {
|
add_setup(async () => {
|
||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [
|
set: [["sidebar.verticalTabs", true]],
|
||||||
["sidebar.verticalTabs", true],
|
|
||||||
["sidebar.visibility", "always-show"],
|
|
||||||
],
|
|
||||||
});
|
});
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"always-show",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are enabled"
|
||||||
|
);
|
||||||
});
|
});
|
||||||
registerCleanupFunction(async () => {
|
registerCleanupFunction(async () => {
|
||||||
await SpecialPowers.popPrefEnv();
|
await SpecialPowers.popPrefEnv();
|
||||||
|
|||||||
@@ -154,6 +154,11 @@ add_task(async function test_toggle_vertical_tabs_from_a_tab() {
|
|||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [["sidebar.verticalTabs", false]],
|
set: [["sidebar.verticalTabs", false]],
|
||||||
});
|
});
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"hide-sidebar",
|
||||||
|
"Sanity check the visibilty pref is updated when verticalTabs are disabled"
|
||||||
|
);
|
||||||
|
|
||||||
info("Enable vertical tabs from a tab.");
|
info("Enable vertical tabs from a tab.");
|
||||||
const tabContextMenu = document.getElementById("tabContextMenu");
|
const tabContextMenu = document.getElementById("tabContextMenu");
|
||||||
@@ -170,6 +175,11 @@ add_task(async function test_toggle_vertical_tabs_from_a_tab() {
|
|||||||
() => gBrowser.tabContainer.verticalMode,
|
() => gBrowser.tabContainer.verticalMode,
|
||||||
"Vertical tabs are enabled."
|
"Vertical tabs are enabled."
|
||||||
);
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"always-show",
|
||||||
|
"Sanity check the visibilty pref is updated when verticalTabs are enabled"
|
||||||
|
);
|
||||||
|
|
||||||
info("Disable vertical tabs from a tab.");
|
info("Disable vertical tabs from a tab.");
|
||||||
await openAndWaitForContextMenu(tabContextMenu, gBrowser.selectedTab, () => {
|
await openAndWaitForContextMenu(tabContextMenu, gBrowser.selectedTab, () => {
|
||||||
@@ -184,6 +194,11 @@ add_task(async function test_toggle_vertical_tabs_from_a_tab() {
|
|||||||
() => !gBrowser.tabContainer.verticalMode,
|
() => !gBrowser.tabContainer.verticalMode,
|
||||||
"Vertical tabs are disabled."
|
"Vertical tabs are disabled."
|
||||||
);
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"hide-sidebar",
|
||||||
|
"Sanity check the visibilty pref is updated when verticalTabs are disabled"
|
||||||
|
);
|
||||||
|
|
||||||
await SpecialPowers.popPrefEnv();
|
await SpecialPowers.popPrefEnv();
|
||||||
});
|
});
|
||||||
@@ -192,6 +207,11 @@ add_task(async function test_toggle_vertical_tabs_from_tab_strip() {
|
|||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [["sidebar.verticalTabs", false]],
|
set: [["sidebar.verticalTabs", false]],
|
||||||
});
|
});
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"hide-sidebar",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are disabled"
|
||||||
|
);
|
||||||
|
|
||||||
info("Enable vertical tabs from the toolbar.");
|
info("Enable vertical tabs from the toolbar.");
|
||||||
const toolbarContextMenu = document.getElementById("toolbar-context-menu");
|
const toolbarContextMenu = document.getElementById("toolbar-context-menu");
|
||||||
@@ -217,6 +237,11 @@ add_task(async function test_toggle_vertical_tabs_from_tab_strip() {
|
|||||||
() => gBrowser.tabContainer.verticalMode,
|
() => gBrowser.tabContainer.verticalMode,
|
||||||
"Vertical tabs are enabled."
|
"Vertical tabs are enabled."
|
||||||
);
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"always-show",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are enabled"
|
||||||
|
);
|
||||||
|
|
||||||
// Open customize sidebar panel from context menu
|
// Open customize sidebar panel from context menu
|
||||||
await openAndWaitForContextMenu(
|
await openAndWaitForContextMenu(
|
||||||
@@ -250,6 +275,11 @@ add_task(async function test_toggle_vertical_tabs_from_tab_strip() {
|
|||||||
() => !gBrowser.tabContainer.verticalMode,
|
() => !gBrowser.tabContainer.verticalMode,
|
||||||
"Vertical tabs are disabled."
|
"Vertical tabs are disabled."
|
||||||
);
|
);
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"hide-sidebar",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are disabled"
|
||||||
|
);
|
||||||
|
|
||||||
window.SidebarController.hide();
|
window.SidebarController.hide();
|
||||||
await SpecialPowers.popPrefEnv();
|
await SpecialPowers.popPrefEnv();
|
||||||
|
|||||||
@@ -169,6 +169,11 @@ add_task(async function test_flip_revamp_pref() {
|
|||||||
ok(BrowserTestUtils.isVisible(verticalTabs), "Vertical tabs slot is visible");
|
ok(BrowserTestUtils.isVisible(verticalTabs), "Vertical tabs slot is visible");
|
||||||
|
|
||||||
ok(sidebar, "Revamped sidebar is shown initially.");
|
ok(sidebar, "Revamped sidebar is shown initially.");
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref("sidebar.visibility"),
|
||||||
|
"always-show",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are enabled"
|
||||||
|
);
|
||||||
|
|
||||||
await SpecialPowers.pushPrefEnv({ set: [["sidebar.revamp", false]] });
|
await SpecialPowers.pushPrefEnv({ set: [["sidebar.revamp", false]] });
|
||||||
|
|
||||||
|
|||||||
@@ -19,9 +19,14 @@ add_setup(async () => {
|
|||||||
set: [
|
set: [
|
||||||
[SIDEBAR_TAB_DIRECTION_PREF, true],
|
[SIDEBAR_TAB_DIRECTION_PREF, true],
|
||||||
[SIDEBAR_BUTTON_INTRODUCED_PREF, false],
|
[SIDEBAR_BUTTON_INTRODUCED_PREF, false],
|
||||||
[SIDEBAR_VISIBILITY_PREF, "always-show"],
|
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref(SIDEBAR_VISIBILITY_PREF),
|
||||||
|
"always-show",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are enabled"
|
||||||
|
);
|
||||||
|
|
||||||
let navbarDefaults = gAreas.get("nav-bar").get("defaultPlacements");
|
let navbarDefaults = gAreas.get("nav-bar").get("defaultPlacements");
|
||||||
let hadSavedState = !!CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
let hadSavedState = !!CustomizableUI.getTestOnlyInternalProp("gSavedState");
|
||||||
if (!hadSavedState) {
|
if (!hadSavedState) {
|
||||||
@@ -179,6 +184,13 @@ add_task(async function test_states_for_hide_sidebar() {
|
|||||||
await SpecialPowers.pushPrefEnv({
|
await SpecialPowers.pushPrefEnv({
|
||||||
set: [[SIDEBAR_TAB_DIRECTION_PREF, false]],
|
set: [[SIDEBAR_TAB_DIRECTION_PREF, false]],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Assert.equal(
|
||||||
|
Services.prefs.getStringPref(SIDEBAR_VISIBILITY_PREF),
|
||||||
|
"hide-sidebar",
|
||||||
|
"Sanity check the visibilty pref when verticalTabs are disabled"
|
||||||
|
);
|
||||||
|
|
||||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||||
const { SidebarController } = win;
|
const { SidebarController } = win;
|
||||||
const { sidebarContainer, sidebarMain, toolbarButton } = SidebarController;
|
const { sidebarContainer, sidebarMain, toolbarButton } = SidebarController;
|
||||||
@@ -221,12 +233,8 @@ add_task(async function test_states_for_hide_sidebar() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Hide the sidebar
|
// Hide the sidebar
|
||||||
info("Check default hidden state.");
|
info("Check the launcher is initially hidden");
|
||||||
await checkStates({ hidden: false });
|
|
||||||
info("Hide sidebar using the toolbar button.");
|
|
||||||
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
|
||||||
await checkStates({ hidden: true });
|
await checkStates({ hidden: true });
|
||||||
|
|
||||||
info("Show sidebar using the toolbar button.");
|
info("Show sidebar using the toolbar button.");
|
||||||
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
||||||
await checkStates({ hidden: false });
|
await checkStates({ hidden: false });
|
||||||
@@ -297,7 +305,7 @@ add_task(async function test_states_for_hide_sidebar_vertical() {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Hide the sidebar
|
// Check initial sidebar state - it should be hidden
|
||||||
info("Check default hidden state.");
|
info("Check default hidden state.");
|
||||||
await checkStates({ hidden: true, expanded: false });
|
await checkStates({ hidden: true, expanded: false });
|
||||||
info("Show expanded sidebar using the toolbar button.");
|
info("Show expanded sidebar using the toolbar button.");
|
||||||
|
|||||||
Reference in New Issue
Block a user