Backed out changeset f56181344f2a (bug 1921536) for causing bc failures @ browser_bookmark_context_menu_contents.js & browser_reviewchecker_sidebar.js CLOSED TREE
This commit is contained in:
@@ -27,14 +27,7 @@ var showSidebar = async function (win = window) {
|
||||
|
||||
var hideSidebar = async function (win = window) {
|
||||
let button = win.document.getElementById("sidebar-button");
|
||||
let box = win.document.getElementById("sidebar-box");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(button, {}, win);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
box,
|
||||
{ attributes: true, attributeFilter: ["hidden"] },
|
||||
() => box.hidden
|
||||
);
|
||||
ok(!win.SidebarController.isOpen, "Sidebar is closed");
|
||||
ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
|
||||
};
|
||||
@@ -81,16 +74,7 @@ add_task(async function () {
|
||||
}
|
||||
}
|
||||
let otherWin = await BrowserTestUtils.openNewBrowserWindow();
|
||||
info("Waiting for the sidebar to initialize in the new browser window");
|
||||
await BrowserTestUtils.waitForCondition(
|
||||
() => otherWin.SidebarController.uiStateInitialized,
|
||||
"The uiStateInitialized is true in the new window"
|
||||
);
|
||||
if (!sidebarRevampEnabled) {
|
||||
ok(
|
||||
!otherWin.SidebarController.isOpen,
|
||||
"The sidebar panel isn't open in the new window"
|
||||
);
|
||||
await showSidebar(otherWin);
|
||||
is(
|
||||
otherWin.SidebarController.currentID,
|
||||
|
||||
@@ -43,14 +43,12 @@ class TestSessionRestore(SessionStoreTestCase):
|
||||
1,
|
||||
msg="Should have 1 window open.",
|
||||
)
|
||||
self.marionette.execute_async_script(
|
||||
self.marionette.execute_script(
|
||||
"""
|
||||
const resolve = arguments[0];
|
||||
let window = BrowserWindowTracker.getTopWindow()
|
||||
window.SidebarController.show("viewHistorySidebar").then(() => {
|
||||
let sidebarBox = window.document.getElementById("sidebar-box")
|
||||
sidebarBox.style.width = "100px";
|
||||
}).then(resolve);
|
||||
window.SidebarController.show("viewHistorySidebar");
|
||||
let sidebarBox = window.document.getElementById("sidebar-box")
|
||||
sidebarBox.style.width = "100px";
|
||||
"""
|
||||
)
|
||||
|
||||
@@ -112,15 +110,13 @@ class TestSessionRestore(SessionStoreTestCase):
|
||||
)
|
||||
|
||||
def test_restore_sidebar_closed(self):
|
||||
self.marionette.execute_async_script(
|
||||
self.marionette.execute_script(
|
||||
"""
|
||||
const resolve = arguments[0];
|
||||
let window = BrowserWindowTracker.getTopWindow()
|
||||
window.SidebarController.show("viewHistorySidebar").then(() => {
|
||||
let sidebarBox = window.document.getElementById("sidebar-box")
|
||||
sidebarBox.style.width = "100px";
|
||||
window.SidebarController.toggle();
|
||||
}).then(resolve);
|
||||
window.SidebarController.show("viewHistorySidebar");
|
||||
let sidebarBox = window.document.getElementById("sidebar-box")
|
||||
sidebarBox.style.width = "100px";
|
||||
window.SidebarController.toggle();
|
||||
"""
|
||||
)
|
||||
|
||||
|
||||
@@ -58,9 +58,8 @@ export class SidebarState {
|
||||
launcherDragActive: false,
|
||||
launcherHoverActive: false,
|
||||
collapsedLauncherWidth: undefined,
|
||||
command: undefined,
|
||||
};
|
||||
#previousLauncherExpanded = undefined;
|
||||
#previousLauncherVisible = undefined;
|
||||
|
||||
/**
|
||||
* Construct a new SidebarState.
|
||||
@@ -154,7 +153,7 @@ export class SidebarState {
|
||||
}
|
||||
switch (key) {
|
||||
case "command":
|
||||
this.command = value;
|
||||
this.#controller.showInitially(value);
|
||||
break;
|
||||
case "panelWidth":
|
||||
this.#panelEl.style.width = `${value}px`;
|
||||
@@ -168,33 +167,10 @@ export class SidebarState {
|
||||
case "hidden":
|
||||
this.launcherVisible = !value;
|
||||
break;
|
||||
case "panelOpen":
|
||||
// we need to know if we have a command value before finalizing panelOpen
|
||||
break;
|
||||
default:
|
||||
this[key] = value;
|
||||
}
|
||||
}
|
||||
if (this.revampEnabled) {
|
||||
if (this.command && !this.launcherVisible) {
|
||||
// We're restoring a session or state saved with an open sidebar panel when sidebar.revamp was false
|
||||
props.panelOpen = true;
|
||||
}
|
||||
}
|
||||
if (this.command && !props.hasOwnProperty("panelOpen")) {
|
||||
// legacy state saved before panelOpen was a thing
|
||||
props.panelOpen = true;
|
||||
}
|
||||
if (!this.command) {
|
||||
props.panelOpen = false;
|
||||
}
|
||||
this.panelOpen = !!props.panelOpen;
|
||||
if (this.command && this.panelOpen) {
|
||||
this.launcherVisible = true;
|
||||
// show() is async, so make sure we return its promise here
|
||||
return this.#controller.showInitially(this.command);
|
||||
}
|
||||
return this.#controller.hide();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -216,8 +192,7 @@ export class SidebarState {
|
||||
*/
|
||||
getProperties() {
|
||||
return {
|
||||
command: this.command,
|
||||
panelOpen: this.panelOpen,
|
||||
command: this.#controller.currentID,
|
||||
panelWidth: this.panelWidth,
|
||||
launcherWidth: convertToInt(this.launcherWidth),
|
||||
expandedLauncherWidth: convertToInt(this.expandedLauncherWidth),
|
||||
@@ -235,24 +210,20 @@ export class SidebarState {
|
||||
}
|
||||
|
||||
set panelOpen(open) {
|
||||
if (this.#props.panelOpen == open) {
|
||||
return;
|
||||
}
|
||||
this.#props.panelOpen = !!open;
|
||||
this.#props.panelOpen = open;
|
||||
if (open) {
|
||||
// Launcher must be visible to open a panel.
|
||||
this.#previousLauncherVisible = this.launcherVisible;
|
||||
this.launcherVisible = true;
|
||||
// We need to know how to revert the launcher when the panel closes
|
||||
this.#previousLauncherExpanded = this.launcherExpanded;
|
||||
|
||||
Services.prefs.setBoolPref(
|
||||
this.revampEnabled ? REVAMP_USED_PREF : LEGACY_USED_PREF,
|
||||
true
|
||||
);
|
||||
} else if (this.revampVisibility === "hide-sidebar") {
|
||||
this.launcherExpanded = lazy.verticalTabsEnabled
|
||||
? this.#previousLauncherExpanded
|
||||
? this.#previousLauncherVisible
|
||||
: false;
|
||||
this.launcherVisible = this.#previousLauncherVisible;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +265,7 @@ export class SidebarState {
|
||||
case "hide-sidebar":
|
||||
if (onToolbarButtonRemoval) {
|
||||
// If we are hiding the sidebar because we removed the toolbar button, close everything
|
||||
this.#previousLauncherExpanded = false;
|
||||
this.#previousLauncherVisible = false;
|
||||
this.launcherVisible = false;
|
||||
this.launcherExpanded = false;
|
||||
|
||||
@@ -312,7 +283,7 @@ export class SidebarState {
|
||||
} else {
|
||||
// Hide the launcher when the pref is set to hide-sidebar
|
||||
this.launcherVisible = false;
|
||||
this.#previousLauncherExpanded = false;
|
||||
this.#previousLauncherVisible = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -321,11 +292,8 @@ export class SidebarState {
|
||||
case "always-show":
|
||||
case "expand-on-hover":
|
||||
this.launcherVisible = true;
|
||||
if (forceExpandValue !== null) {
|
||||
this.launcherExpanded = forceExpandValue;
|
||||
} else if (onUserToggle) {
|
||||
this.launcherExpanded = !this.launcherExpanded;
|
||||
}
|
||||
this.launcherExpanded =
|
||||
forceExpandValue !== null ? forceExpandValue : !this.launcherExpanded;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -452,24 +420,6 @@ export class SidebarState {
|
||||
.getElementById("tabbrowser-tabbox")
|
||||
.toggleAttribute("sidebar-shown", isSidebarShown);
|
||||
}
|
||||
|
||||
get command() {
|
||||
return this.#props.command || "";
|
||||
}
|
||||
|
||||
set command(id) {
|
||||
if (id && !this.#controller.sidebars.has(id)) {
|
||||
throw new Error("Setting command to an invalid value");
|
||||
}
|
||||
if (id && id !== this.#props.command) {
|
||||
this.#props.command = id;
|
||||
// We need the attribute to mirror the command property as its used as a CSS hook
|
||||
this.#controller._box.setAttribute("sidebarcommand", id);
|
||||
} else if (!id) {
|
||||
delete this.#props.command;
|
||||
this.#controller._box.setAttribute("sidebarcommand", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -526,15 +526,7 @@ var SidebarController = {
|
||||
},
|
||||
|
||||
getUIState() {
|
||||
if (this.inPopup) {
|
||||
return null;
|
||||
}
|
||||
let snapshot = this._state.getProperties();
|
||||
// we don't persist the sidebar command when the panel is closed
|
||||
if (!this._state.panelOpen) {
|
||||
delete snapshot.command;
|
||||
}
|
||||
return snapshot;
|
||||
return this.inPopup ? null : this._state.getProperties();
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -547,23 +539,19 @@ var SidebarController = {
|
||||
if (!state) {
|
||||
return;
|
||||
}
|
||||
const isValidSidebar = !state.command || this.sidebars.has(state.command);
|
||||
if (!isValidSidebar) {
|
||||
state.command = "";
|
||||
}
|
||||
|
||||
const hasOpenPanel =
|
||||
state.panelOpen &&
|
||||
state.command &&
|
||||
this.sidebars.has(state.command) &&
|
||||
this.currentID !== state.command;
|
||||
if (hasOpenPanel) {
|
||||
// There's a panel to show, so ignore the contradictory hidden property.
|
||||
delete state.hidden;
|
||||
} else {
|
||||
delete state.command;
|
||||
}
|
||||
await this.promiseInitialized;
|
||||
await this.waitUntilStable(); // Finish currently scheduled tasks.
|
||||
await this._state.loadInitialState(state);
|
||||
this._state.loadInitialState(state);
|
||||
await this.waitUntilStable(); // Finish newly scheduled tasks.
|
||||
this.updateToolbarButton();
|
||||
this.uiStateInitialized = true;
|
||||
@@ -864,12 +852,16 @@ var SidebarController = {
|
||||
document.getElementById("sidebar-main").hidden = true;
|
||||
return false;
|
||||
}
|
||||
// Adopt the other window's UI state (it too could be a popup)
|
||||
// We get the properties directly forom the SidebarState instance as in this case
|
||||
// we need the command property even if no panel is currently open.
|
||||
const sourceState = sourceController.inPopup
|
||||
? null
|
||||
: sourceController._state?.getProperties();
|
||||
|
||||
// Set sidebar command even if hidden, so that we keep the same sidebar
|
||||
// even if it's currently closed.
|
||||
let commandID = sourceController._box.getAttribute("sidebarcommand");
|
||||
if (commandID) {
|
||||
this._box.setAttribute("sidebarcommand", commandID);
|
||||
}
|
||||
|
||||
// Adopt the other window's UI state.
|
||||
const sourceState = sourceController.getUIState();
|
||||
await this.initializeUIState(sourceState);
|
||||
|
||||
return true;
|
||||
@@ -917,15 +909,17 @@ var SidebarController = {
|
||||
return;
|
||||
}
|
||||
|
||||
let commandID = this._state.command;
|
||||
let commandID = this._box.getAttribute("sidebarcommand");
|
||||
if (commandID && this.sidebars.has(commandID)) {
|
||||
this.showInitially(commandID);
|
||||
} else {
|
||||
this._box.removeAttribute("checked");
|
||||
// Update the state, because the element it
|
||||
// Remove the |sidebarcommand| attribute, because the element it
|
||||
// refers to no longer exists, so we should assume this sidebar
|
||||
// panel has been uninstalled. (249883)
|
||||
this._state.command = "";
|
||||
// We use setAttribute rather than removeAttribute so it persists
|
||||
// correctly.
|
||||
this._box.setAttribute("sidebarcommand", "");
|
||||
// On a startup in which the startup cache was invalidated (e.g. app update)
|
||||
// extensions will not be started prior to delayedLoad, thus the
|
||||
// sidebarcommand element will not exist yet. Store the commandID so
|
||||
@@ -976,7 +970,7 @@ var SidebarController = {
|
||||
* The ID of the current sidebar.
|
||||
*/
|
||||
get currentID() {
|
||||
return this.isOpen ? this._state.command : "";
|
||||
return this.isOpen ? this._box.getAttribute("sidebarcommand") : "";
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -1020,7 +1014,7 @@ var SidebarController = {
|
||||
// have a persisted command either, or the command doesn't exist anymore, then
|
||||
// fallback to a default sidebar.
|
||||
if (!commandID) {
|
||||
commandID = this._state.command;
|
||||
commandID = this._box.getAttribute("sidebarcommand");
|
||||
}
|
||||
if (!commandID || !this.sidebars.has(commandID)) {
|
||||
if (this.sidebarRevampEnabled && this.sidebars.size) {
|
||||
@@ -1202,9 +1196,6 @@ var SidebarController = {
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* For sidebar.revamp=true only, handle the keyboard or sidebar-button command to toggle the sidebar state
|
||||
*/
|
||||
async handleToolbarButtonClick() {
|
||||
let initialExpandedValue = this._state.launcherExpanded;
|
||||
if (this.inPopup || this.uninitializing) {
|
||||
@@ -1213,12 +1204,8 @@ var SidebarController = {
|
||||
if (this._animationEnabled && !window.gReduceMotion) {
|
||||
this._animateSidebarMain();
|
||||
}
|
||||
const showLauncher = !this._state.launcherVisible;
|
||||
|
||||
this._state.updateVisibility(showLauncher, true);
|
||||
if (showLauncher && this._state.command) {
|
||||
this._show(this._state.command);
|
||||
}
|
||||
this._state.updateVisibility(!this._state.launcherVisible, true);
|
||||
if (this.sidebarRevampVisibility === "expand-on-hover") {
|
||||
this.toggleExpandOnHover(initialExpandedValue);
|
||||
}
|
||||
@@ -1676,7 +1663,7 @@ var SidebarController = {
|
||||
this._box.hidden = this._splitter.hidden = false;
|
||||
|
||||
this._box.setAttribute("checked", "true");
|
||||
this._state.command = commandID;
|
||||
this._box.setAttribute("sidebarcommand", commandID);
|
||||
|
||||
let { icon, url, title, sourceL10nEl, contextMenuId } =
|
||||
this.sidebars.get(commandID);
|
||||
@@ -1787,17 +1774,6 @@ var SidebarController = {
|
||||
if (triggerNode) {
|
||||
updateToggleControlLabel(triggerNode);
|
||||
}
|
||||
let showLauncher = false;
|
||||
if (
|
||||
this.sidebarRevampEnabled &&
|
||||
this.sidebarRevampVisibility !== "hide-sidebar"
|
||||
) {
|
||||
showLauncher = true;
|
||||
}
|
||||
this._state.updateVisibility(
|
||||
showLauncher,
|
||||
false // onUserToggle param means "did the user click the sidebar-button", which is false here
|
||||
);
|
||||
this.updateToolbarButton();
|
||||
},
|
||||
|
||||
@@ -1809,9 +1785,6 @@ var SidebarController = {
|
||||
*/
|
||||
_recordPanelToggle(commandID, opened) {
|
||||
const sidebar = this.sidebars.get(commandID);
|
||||
if (!sidebar) {
|
||||
return;
|
||||
}
|
||||
const isExtension = sidebar && Object.hasOwn(sidebar, "extensionId");
|
||||
const version = this.sidebarRevampEnabled ? "new" : "old";
|
||||
if (isExtension) {
|
||||
@@ -2125,13 +2098,9 @@ XPCOMUtils.defineLazyPreferenceGetter(
|
||||
const forceExpand = isVerticalTabs && newValue === "always-show";
|
||||
|
||||
// horizontal tabs and hide-sidebar = visible initially.
|
||||
// vertical tab and hide-sidebar = not visible initially
|
||||
let showLauncher = true;
|
||||
if (newValue == "hide-sidebar" && isVerticalTabs) {
|
||||
showLauncher = false;
|
||||
}
|
||||
// vertical tab and hide-sidebar = not visible initally.
|
||||
SidebarController._state.updateVisibility(
|
||||
showLauncher,
|
||||
(newValue != "hide-sidebar" && isVerticalTabs) || !isVerticalTabs,
|
||||
false,
|
||||
false,
|
||||
forceExpand
|
||||
|
||||
@@ -84,7 +84,7 @@ add_task(async function test_keyboard_navigation() {
|
||||
info("Press Tab key.");
|
||||
EventUtils.synthesizeKey("KEY_Tab", {}, win);
|
||||
ok(isActiveElement(customizeButton), "Customize button is focused.");
|
||||
}).skip(); // Bug 1950504
|
||||
});
|
||||
|
||||
add_task(async function test_menu_items_labeled() {
|
||||
const { document, SidebarController } = win;
|
||||
|
||||
@@ -8,9 +8,6 @@ requestLongerTimeout(10);
|
||||
const lazy = {};
|
||||
|
||||
const TAB_DIRECTION_PREF = "sidebar.verticalTabs";
|
||||
const initialTabDirection = Services.prefs.getBoolPref(TAB_DIRECTION_PREF)
|
||||
? "vertical"
|
||||
: "horizontal";
|
||||
|
||||
ChromeUtils.defineESModuleGetters(lazy, {
|
||||
TabsSetupFlowManager:
|
||||
@@ -19,10 +16,9 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
});
|
||||
|
||||
add_setup(async () => {
|
||||
await SidebarController.promiseInitialized;
|
||||
await SidebarController.sidebarMain?.updateComplete;
|
||||
SidebarController.init();
|
||||
await TestUtils.waitForTick();
|
||||
});
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
while (gBrowser.tabs.length > 1) {
|
||||
BrowserTestUtils.removeTab(gBrowser.tabs[0]);
|
||||
@@ -50,33 +46,31 @@ add_task(async function test_sidebar_expand() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[TAB_DIRECTION_PREF, true]],
|
||||
});
|
||||
await waitForTabstripOrientation("vertical");
|
||||
|
||||
// Vertical tabs are expanded by default
|
||||
Assert.ok(SidebarController.sidebarMain.expanded, "Sidebar is expanded.");
|
||||
await TestUtils.waitForCondition(
|
||||
() => SidebarController.sidebarMain.expanded,
|
||||
"Sidebar is expanded."
|
||||
);
|
||||
|
||||
info("Collapse the sidebar.");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(SidebarController.toolbarButton, {});
|
||||
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
SidebarController.sidebarMain,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => !SidebarController.sidebarMain.expanded
|
||||
await TestUtils.waitForCondition(
|
||||
() => !SidebarController.sidebarMain.expanded,
|
||||
"Sidebar is collapsed."
|
||||
);
|
||||
|
||||
info("Re-expand the sidebar.");
|
||||
EventUtils.synthesizeMouseAtCenter(SidebarController.toolbarButton, {});
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
SidebarController.sidebarMain,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => SidebarController.sidebarMain.expanded
|
||||
await TestUtils.waitForCondition(
|
||||
() => SidebarController.sidebarMain.expanded,
|
||||
"Sidebar is expanded."
|
||||
);
|
||||
|
||||
const events = Glean.sidebar.expand.testGetValue();
|
||||
Assert.equal(events?.length, 2, "Two events were reported.");
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
});
|
||||
|
||||
async function testSidebarToggle(commandID, gleanEvent, otherCommandID) {
|
||||
@@ -106,11 +100,9 @@ async function testSidebarToggle(commandID, gleanEvent, otherCommandID) {
|
||||
"false",
|
||||
"Event indicates that the panel was closed."
|
||||
);
|
||||
await SidebarController.initializeUIState({
|
||||
panelOpen: false,
|
||||
command: "",
|
||||
launcherVisible: true,
|
||||
});
|
||||
if (otherCommandID) {
|
||||
SidebarController.hide();
|
||||
}
|
||||
}
|
||||
|
||||
add_task(async function test_history_sidebar_toggle() {
|
||||
@@ -174,7 +166,6 @@ async function test_synced_tabs_sidebar_toggle(revampEnabled) {
|
||||
|
||||
sandbox.restore();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
@@ -244,11 +235,9 @@ add_task(async function test_contextual_manager_toggle() {
|
||||
["sidebar.revamp", false],
|
||||
],
|
||||
});
|
||||
await SidebarController.waitUntilStable();
|
||||
const gleanEvent = Glean.contextualManager.sidebarToggle;
|
||||
await testSidebarToggle("viewCPMSidebar", gleanEvent);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
add_task(async function test_customize_panel_toggle() {
|
||||
@@ -261,14 +250,8 @@ add_task(async function test_customize_panel_toggle() {
|
||||
add_task(async function test_customize_icon_click() {
|
||||
info("Click on the gear icon.");
|
||||
const { customizeButton } = SidebarController.sidebarMain;
|
||||
Assert.ok(
|
||||
BrowserTestUtils.isVisible(customizeButton),
|
||||
"The customize button is visible to click on"
|
||||
);
|
||||
const sideShown = BrowserTestUtils.waitForEvent(document, "SidebarShown");
|
||||
EventUtils.synthesizeMouseAtCenter(customizeButton, {});
|
||||
|
||||
await sideShown;
|
||||
const events = Glean.sidebarCustomize.iconClick.testGetValue();
|
||||
Assert.equal(events?.length, 1, "One event was reported.");
|
||||
|
||||
@@ -330,8 +313,6 @@ add_task(async function test_customize_chatbot_enabled() {
|
||||
"viewGenaiChatSidebar",
|
||||
Glean.sidebarCustomize.chatbotEnabled
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
add_task(async function test_customize_synced_tabs_enabled() {
|
||||
@@ -365,8 +346,6 @@ add_task(async function test_customize_review_checker_enabled() {
|
||||
Glean.sidebarCustomize.shoppingReviewCheckerEnabled,
|
||||
false
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
add_task(async function test_customize_extensions_clicked() {
|
||||
@@ -442,7 +421,6 @@ add_task(async function test_customize_sidebar_display() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[TAB_DIRECTION_PREF, true]],
|
||||
});
|
||||
await waitForTabstripOrientation("vertical");
|
||||
await testCustomizeSetting(
|
||||
"visibilityInput",
|
||||
Glean.sidebarCustomize.sidebarDisplay,
|
||||
@@ -450,7 +428,6 @@ add_task(async function test_customize_sidebar_display() {
|
||||
{ preference: "always" }
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
});
|
||||
|
||||
add_task(async function test_customize_sidebar_position() {
|
||||
@@ -489,7 +466,6 @@ add_task(async function test_sidebar_resize() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[TAB_DIRECTION_PREF, true]],
|
||||
});
|
||||
await waitForTabstripOrientation("vertical");
|
||||
await SidebarController.show("viewHistorySidebar");
|
||||
const originalWidth = SidebarController._box.style.width;
|
||||
SidebarController._box.style.width = "500px";
|
||||
@@ -513,14 +489,12 @@ add_task(async function test_sidebar_resize() {
|
||||
SidebarController._box.style.width = originalWidth;
|
||||
SidebarController.hide();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
});
|
||||
|
||||
add_task(async function test_sidebar_display_settings() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[TAB_DIRECTION_PREF, true]],
|
||||
});
|
||||
await waitForTabstripOrientation("vertical");
|
||||
await testCustomizeSetting(
|
||||
"visibilityInput",
|
||||
Glean.sidebar.displaySettings,
|
||||
@@ -528,7 +502,6 @@ add_task(async function test_sidebar_display_settings() {
|
||||
"always"
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
});
|
||||
|
||||
add_task(async function test_sidebar_position_settings() {
|
||||
@@ -572,7 +545,6 @@ add_task(async function test_sidebar_position_rtl_ui() {
|
||||
|
||||
sandbox.restore();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
async function testIconClick(expanded) {
|
||||
@@ -583,7 +555,6 @@ async function testIconClick(expanded) {
|
||||
[TAB_DIRECTION_PREF, true],
|
||||
],
|
||||
});
|
||||
await waitForTabstripOrientation("vertical");
|
||||
|
||||
const { sidebarMain } = SidebarController;
|
||||
const gleanEvents = [
|
||||
@@ -593,16 +564,7 @@ async function testIconClick(expanded) {
|
||||
Glean.sidebar.bookmarksIconClick,
|
||||
];
|
||||
for (const [i, button] of Array.from(sidebarMain.toolButtons).entries()) {
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: expanded,
|
||||
command: "",
|
||||
});
|
||||
Assert.equal(
|
||||
SidebarController.sidebarMain.expanded,
|
||||
expanded,
|
||||
`The launcher is ${expanded ? "expanded" : "collapsed"}`
|
||||
);
|
||||
Assert.ok(!SidebarController._state.panelOpen, "No panel is open");
|
||||
await SidebarController.initializeUIState({ launcherExpanded: expanded });
|
||||
|
||||
info(`Click the icon for: ${button.getAttribute("view")}`);
|
||||
EventUtils.synthesizeMouseAtCenter(button, {});
|
||||
@@ -619,22 +581,11 @@ async function testIconClick(expanded) {
|
||||
}
|
||||
|
||||
info("Load an extension.");
|
||||
// The extensions's sidebar will open when it loads
|
||||
const extension = ExtensionTestUtils.loadExtension({ ...extData });
|
||||
await extension.startup();
|
||||
await extension.awaitMessage("sidebar");
|
||||
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: expanded,
|
||||
panelOpen: false,
|
||||
command: "",
|
||||
});
|
||||
Assert.equal(
|
||||
SidebarController.sidebarMain.expanded,
|
||||
expanded,
|
||||
`The launcher is ${expanded ? "expanded" : "collapsed"}`
|
||||
);
|
||||
Assert.ok(!SidebarController._state.panelOpen, "No panel is open");
|
||||
await SidebarController.initializeUIState({ launcherExpanded: expanded });
|
||||
|
||||
info("Click the icon for the extension.");
|
||||
const extensionButton = await TestUtils.waitForCondition(
|
||||
@@ -656,7 +607,6 @@ async function testIconClick(expanded) {
|
||||
await extension.unload();
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
@@ -672,17 +622,7 @@ async function testIconClickReviewChecker(expanded) {
|
||||
|
||||
const { sidebarMain } = SidebarController;
|
||||
|
||||
await SidebarController.initializeUIState({
|
||||
launcherVisible: true,
|
||||
launcherExpanded: expanded,
|
||||
command: "",
|
||||
});
|
||||
Assert.equal(
|
||||
SidebarController.sidebarMain.expanded,
|
||||
expanded,
|
||||
`The launcher is ${expanded ? "expanded" : "collapsed"}`
|
||||
);
|
||||
Assert.ok(!SidebarController._state.panelOpen, "No panel is open");
|
||||
await SidebarController.initializeUIState({ launcherExpanded: expanded });
|
||||
|
||||
let reviewCheckerButton = sidebarMain.shadowRoot.querySelector(
|
||||
"moz-button[view='viewReviewCheckerSidebar']"
|
||||
@@ -698,11 +638,6 @@ async function testIconClickReviewChecker(expanded) {
|
||||
);
|
||||
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: false,
|
||||
launcherVisible: true,
|
||||
command: "",
|
||||
});
|
||||
Services.fog.testResetFOG();
|
||||
}
|
||||
|
||||
@@ -715,19 +650,9 @@ add_task(async function test_icon_click_expanded_sidebar() {
|
||||
});
|
||||
|
||||
add_task(async function test_review_checker_icon_click_collapsed_sidebar() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.shopping.experience2023.integratedSidebar", true]],
|
||||
});
|
||||
await testIconClickReviewChecker(false);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
add_task(async function test_review_checker_icon_click_expanded_sidebar() {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [["browser.shopping.experience2023.integratedSidebar", true]],
|
||||
});
|
||||
await testIconClickReviewChecker(true);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
@@ -10,17 +10,13 @@ add_setup(async () => {
|
||||
});
|
||||
});
|
||||
|
||||
const initialTabDirection = Services.prefs.getBoolPref("sidebar.verticalTabs")
|
||||
? "vertical"
|
||||
: "horizontal";
|
||||
|
||||
add_task(async function test_extension_context_menu() {
|
||||
const win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await waitForBrowserWindowActive(win);
|
||||
const { document } = win;
|
||||
const sidebar = document.querySelector("sidebar-main");
|
||||
await sidebar.updateComplete;
|
||||
ok(BrowserTestUtils.isVisible(sidebar), "Sidebar is shown.");
|
||||
ok(sidebar, "Sidebar is shown.");
|
||||
|
||||
const manageStub = sinon.stub(sidebar, "manageExtension");
|
||||
const reportStub = sinon.stub(sidebar, "reportExtension");
|
||||
@@ -182,20 +178,14 @@ add_task(async function test_extension_context_menu() {
|
||||
|
||||
sinon.restore();
|
||||
await extension.unload();
|
||||
ok(
|
||||
BrowserTestUtils.isHidden(sidebar),
|
||||
"Unloading the extension causes the sidebar launcher to hide"
|
||||
);
|
||||
await BrowserTestUtils.closeWindow(win);
|
||||
});
|
||||
|
||||
add_task(async function test_sidebar_context_menu() {
|
||||
const { document, SidebarController } = window;
|
||||
const { sidebarMain, sidebarContainer } = SidebarController;
|
||||
await SidebarController.initializeUIState({
|
||||
launcherVisible: true,
|
||||
});
|
||||
ok(BrowserTestUtils.isVisible(sidebarMain), "Sidebar is shown.");
|
||||
await sidebarMain.updateComplete;
|
||||
ok(sidebarMain, "Sidebar is shown.");
|
||||
|
||||
const contextMenu = document.getElementById("sidebar-context-menu");
|
||||
is(contextMenu.state, "closed", "Checking if context menu is closed");
|
||||
@@ -251,10 +241,9 @@ add_task(async function test_sidebar_context_menu() {
|
||||
});
|
||||
ok(
|
||||
Services.prefs.getBoolPref("sidebar.verticalTabs", false),
|
||||
"Vertical tabs disabled"
|
||||
"Vertical tabs enabled"
|
||||
);
|
||||
Services.prefs.clearUserPref("sidebar.verticalTabs");
|
||||
await waitForTabstripOrientation(initialTabDirection);
|
||||
|
||||
is(contextMenu.state, "closed", "Context menu closed for vertical tabs");
|
||||
});
|
||||
@@ -331,5 +320,4 @@ add_task(async function test_toggle_vertical_tabs_from_sidebar_button() {
|
||||
|
||||
window.SidebarController.hide();
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await window.SidebarController.waitUntilStable();
|
||||
});
|
||||
|
||||
@@ -9,19 +9,10 @@ add_setup(async () => {
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[SIDEBAR_VISIBILITY_PREF, "hide-sidebar"]],
|
||||
});
|
||||
await SidebarController.waitUntilStable();
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: false,
|
||||
launcherVisible: false,
|
||||
});
|
||||
|
||||
info("Waiting for a mutation condition where sidebarContainer is hidden");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
SidebarController.sidebarContainer,
|
||||
{ attributes: true, attributeFilter: ["hidden"] },
|
||||
() => SidebarController.sidebarContainer.hasAttribute("hidden")
|
||||
);
|
||||
|
||||
// make sure the sidebar is reset after we're done
|
||||
registerCleanupFunction(async () => {
|
||||
await SidebarController.sidebarMain.updateComplete;
|
||||
@@ -64,16 +55,10 @@ add_task(async function test_sidebar_view_commands() {
|
||||
ok(!sidebar.expanded, "Sidebar is not expanded when the view is closed");
|
||||
ok(BrowserTestUtils.isHidden(sidebarBox), "Sidebar box is hidden");
|
||||
|
||||
// Confirm that toggling the sidebar using the toolbarbutton re-opens it with the previous panel
|
||||
document.getElementById("sidebar-button").doCommand();
|
||||
await sidebar.updateComplete;
|
||||
ok(BrowserTestUtils.isVisible(sidebar), "Sidebar is visible again.");
|
||||
ok(BrowserTestUtils.isVisible(sidebarBox), "Sidebar panel is visible.");
|
||||
is(
|
||||
SidebarController.currentID,
|
||||
"viewBookmarksSidebar",
|
||||
"Sidebar controller re-opened the previous panel"
|
||||
);
|
||||
ok(BrowserTestUtils.isHidden(sidebarBox), "Sidebar box is hidden.");
|
||||
|
||||
// restore the animation pref
|
||||
SpecialPowers.popPrefEnv();
|
||||
|
||||
@@ -94,21 +94,15 @@ add_task(async function test_expanded_state_for_always_show() {
|
||||
component = sidebarMain,
|
||||
button = toolbarButton
|
||||
) => {
|
||||
info(
|
||||
`Waiting for component to become ${expanded ? "expanded" : "collapsed"}`
|
||||
await TestUtils.waitForCondition(
|
||||
() => Boolean(component.expanded) == expanded,
|
||||
expanded ? "Sidebar is expanded." : "Sidebar is collapsed."
|
||||
);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
component,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => Boolean(component.expanded) == expanded
|
||||
);
|
||||
info(
|
||||
`Waiting for button to become ${expanded ? "highlighted" : "not highlighted"}`
|
||||
);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
button,
|
||||
{ attributes: true, attributeFilter: ["checked"] },
|
||||
() => Boolean(button.checked) == expanded
|
||||
await TestUtils.waitForCondition(
|
||||
() => Boolean(button.checked) == expanded,
|
||||
expanded
|
||||
? "Toolbar button is highlighted."
|
||||
: "Toolbar button is not highlighted."
|
||||
);
|
||||
Assert.deepEqual(
|
||||
document.l10n.getAttributes(button),
|
||||
@@ -123,9 +117,8 @@ add_task(async function test_expanded_state_for_always_show() {
|
||||
},
|
||||
"Toolbar button has the correct tooltip."
|
||||
);
|
||||
Assert.equal(
|
||||
button.hasAttribute("expanded"),
|
||||
expanded,
|
||||
await TestUtils.waitForCondition(
|
||||
() => button.hasAttribute("expanded") == expanded,
|
||||
expanded
|
||||
? "Toolbar button expanded attribute is present."
|
||||
: "Toolbar button expanded attribute is absent."
|
||||
@@ -140,50 +133,26 @@ add_task(async function test_expanded_state_for_always_show() {
|
||||
await checkExpandedState(false);
|
||||
|
||||
info("Don't collapse the sidebar by loading a tool.");
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: true,
|
||||
command: "",
|
||||
});
|
||||
info("Waiting to re-initialize UI state to make the launcher expanded");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
sidebarMain,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => Boolean(sidebarMain.expanded)
|
||||
);
|
||||
await SidebarController.initializeUIState({ launcherExpanded: true });
|
||||
await SidebarController.waitUntilStable();
|
||||
|
||||
const toolButton = sidebarMain.toolButtons[0];
|
||||
EventUtils.synthesizeMouseAtCenter(toolButton, {}, window);
|
||||
await SidebarController.waitUntilStable();
|
||||
await checkExpandedState(true);
|
||||
SidebarController.hide();
|
||||
|
||||
info("Load and unload a tool with the sidebar collapsed to begin with.");
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: false,
|
||||
command: "",
|
||||
});
|
||||
info("Waiting to re-initialize UI state to make the launcher collapsed");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
sidebarMain,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => !sidebarMain.expanded
|
||||
);
|
||||
await SidebarController.initializeUIState({ launcherExpanded: false });
|
||||
await SidebarController.waitUntilStable();
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(toolButton, {}, window);
|
||||
await SidebarController.waitUntilStable();
|
||||
await checkExpandedState(false);
|
||||
SidebarController.hide();
|
||||
|
||||
await SidebarController.initializeUIState({
|
||||
launcherExpanded: true,
|
||||
command: "",
|
||||
});
|
||||
info("Waiting to re-initialize UI state to make the launcher expanded");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
sidebarMain,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => Boolean(sidebarMain.expanded)
|
||||
);
|
||||
|
||||
info("Check expanded state on a new window.");
|
||||
await SidebarController.initializeUIState({ launcherExpanded: true });
|
||||
await SidebarController.waitUntilStable();
|
||||
|
||||
const newWin = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await waitForTabstripOrientation("vertical", newWin);
|
||||
await checkExpandedState(
|
||||
@@ -228,23 +197,17 @@ add_task(async function test_states_for_hide_sidebar() {
|
||||
component = sidebarMain,
|
||||
button = toolbarButton
|
||||
) => {
|
||||
info(`Waiting for container to become ${hidden ? "hidden" : "not hidden"}`);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
container,
|
||||
{ attributes: true, attributeFilter: ["hidden"] },
|
||||
() => Boolean(container.hidden) == hidden
|
||||
await TestUtils.waitForCondition(
|
||||
() => container.hidden == hidden,
|
||||
"Hidden state is correct."
|
||||
);
|
||||
info("Waiting for component to be not expanded");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
component,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => !component.expanded
|
||||
await TestUtils.waitForCondition(
|
||||
() => !component.expanded,
|
||||
"Expanded state is correct."
|
||||
);
|
||||
info("Waiting for button to be highlighted");
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
button,
|
||||
{ attributes: true, attributeFilter: ["checked"] },
|
||||
() => Boolean(button.checked) == !hidden
|
||||
await TestUtils.waitForCondition(
|
||||
() => button.checked == !hidden,
|
||||
"Toolbar button state is correct."
|
||||
);
|
||||
Assert.deepEqual(
|
||||
document.l10n.getAttributes(button),
|
||||
@@ -322,27 +285,17 @@ add_task(async function test_states_for_hide_sidebar_vertical() {
|
||||
component = sidebarMain,
|
||||
button = toolbarButton
|
||||
) => {
|
||||
info(`Waiting for container to become ${hidden ? "hidden" : "not hidden"}`);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
container,
|
||||
{ attributes: true, attributeFilter: ["hidden"] },
|
||||
() => Boolean(container.hidden) == hidden
|
||||
await TestUtils.waitForCondition(
|
||||
() => container.hidden == hidden,
|
||||
"Hidden state is correct."
|
||||
);
|
||||
info(
|
||||
`Waiting for component to be ${expanded ? "expanded" : "not expanded"}`
|
||||
await TestUtils.waitForCondition(
|
||||
() => component.expanded == expanded,
|
||||
"Expanded state is correct."
|
||||
);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
component,
|
||||
{ attributes: true, attributeFilter: ["expanded"] },
|
||||
() => Boolean(component.expanded) == expanded
|
||||
);
|
||||
info(
|
||||
`Waiting for button to be ${hidden ? "not highlighted" : "highlighted"}`
|
||||
);
|
||||
await BrowserTestUtils.waitForMutationCondition(
|
||||
button,
|
||||
{ attributes: true, attributeFilter: ["checked"] },
|
||||
() => Boolean(button.checked) == !hidden
|
||||
await TestUtils.waitForCondition(
|
||||
() => button.checked == !hidden,
|
||||
"Toolbar button state is correct."
|
||||
);
|
||||
Assert.deepEqual(
|
||||
document.l10n.getAttributes(button),
|
||||
@@ -377,19 +330,20 @@ add_task(async function test_states_for_hide_sidebar_vertical() {
|
||||
const toolButton = sidebarMain.toolButtons[0];
|
||||
EventUtils.synthesizeMouseAtCenter(toolButton, {}, win);
|
||||
|
||||
await TestUtils.waitForCondition(
|
||||
() => SidebarController.isOpen,
|
||||
"Panel is open"
|
||||
);
|
||||
await checkStates({ hidden: false, expanded: true });
|
||||
ok(SidebarController.isOpen, "Panel is open.");
|
||||
|
||||
info("Close a panel using the toolbar button.");
|
||||
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
||||
|
||||
await checkStates({ hidden: true, expanded: false });
|
||||
ok(!SidebarController.isOpen, "Panel is closed.");
|
||||
|
||||
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
||||
await checkStates({ hidden: false, expanded: true });
|
||||
await checkStates({ hidden: true, expanded: true });
|
||||
|
||||
info("Check states on a new window.");
|
||||
EventUtils.synthesizeMouseAtCenter(toolbarButton, {}, win);
|
||||
await checkStates({ hidden: false, expanded: true });
|
||||
const newWin = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await checkStates(
|
||||
{ hidden: false, expanded: true },
|
||||
@@ -443,29 +397,23 @@ add_task(async function test_sidebar_button_runtime_pref_enabled() {
|
||||
"Sidebar button should not be checked when old sidebar is not showing."
|
||||
);
|
||||
await SpecialPowers.popPrefEnv();
|
||||
await SidebarController.waitUntilStable();
|
||||
|
||||
// When the button was removed, "hide-sidebar" was set automatically. Revert for the next test.
|
||||
// Expanded is the default when "hide-sidebar" is set - revert to collapsed for the next test.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[SIDEBAR_VISIBILITY_PREF, "always-show"]],
|
||||
});
|
||||
await SidebarController.initializeUIState({ expanded: false });
|
||||
});
|
||||
|
||||
/**
|
||||
* Check that keyboard shortcut toggles sidebar
|
||||
*/
|
||||
add_task(async function test_keyboard_shortcut() {
|
||||
// When the button was removed, "hide-sidebar" was set automatically. Revert for this test.
|
||||
// Expanded is the default when "hide-sidebar" is set - revert to collapsed.
|
||||
await SpecialPowers.pushPrefEnv({
|
||||
set: [[SIDEBAR_VISIBILITY_PREF, "always-show"]],
|
||||
});
|
||||
await SidebarController.initializeUIState({ launcherExpanded: false });
|
||||
|
||||
const sidebar = document.querySelector("sidebar-main");
|
||||
const key = document.getElementById("toggleSidebarKb");
|
||||
|
||||
Assert.equal(
|
||||
Services.prefs.getStringPref("sidebar.visibility"),
|
||||
"always-show",
|
||||
"Got expected visibility value"
|
||||
);
|
||||
Assert.ok(!sidebar.expanded, "Sidebar initially not expanded");
|
||||
Assert.ok(!sidebar.expanded, "Sidebar collapsed by default");
|
||||
|
||||
key.doCommand();
|
||||
|
||||
|
||||
@@ -94,18 +94,6 @@ const extData = {
|
||||
},
|
||||
};
|
||||
|
||||
// Ensure each test leaves the sidebar in its initial state when it completes
|
||||
const initialSidebarState = { ...SidebarController.getUIState(), command: "" };
|
||||
async function resetSidebarToInitialState() {
|
||||
info(
|
||||
`Restoring sidebar state from: ${JSON.stringify(SidebarController.getUIState())}, back to: ${JSON.stringify(initialSidebarState)}`
|
||||
);
|
||||
await SidebarController.initializeUIState(initialSidebarState);
|
||||
}
|
||||
registerCleanupFunction(async () => {
|
||||
await resetSidebarToInitialState();
|
||||
});
|
||||
|
||||
function waitForBrowserWindowActive(win) {
|
||||
// eslint-disable-next-line consistent-return
|
||||
return new Promise(resolve => {
|
||||
|
||||
@@ -24,7 +24,6 @@ const mockGlobal = {
|
||||
};
|
||||
const mockController = {
|
||||
_box: mockElement,
|
||||
hide: sinon.stub(),
|
||||
showInitially: sinon.stub(),
|
||||
sidebarContainer: { ownerGlobal: mockGlobal },
|
||||
sidebarMain: mockElement,
|
||||
@@ -53,35 +52,3 @@ add_task(async function test_load_legacy_session_restore_data() {
|
||||
"Bookmarks panel was shown."
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_load_prerevamp_session_restore_data() {
|
||||
const sidebarState = new SidebarState(mockController);
|
||||
|
||||
sidebarState.loadInitialState({
|
||||
command: "viewBookmarksSidebar",
|
||||
});
|
||||
|
||||
const props = sidebarState.getProperties();
|
||||
Assert.ok(props.panelOpen, "The panel is marked as open.");
|
||||
Assert.equal(props.launcherVisible, true, "The launcher is visible.");
|
||||
Assert.equal(props.command, "viewBookmarksSidebar", "The command matches.");
|
||||
Assert.ok(
|
||||
mockController.showInitially.calledWith("viewBookmarksSidebar"),
|
||||
"Bookmarks panel was shown."
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function test_load_hidden_panel_state() {
|
||||
const sidebarState = new SidebarState(mockController);
|
||||
|
||||
sidebarState.loadInitialState({
|
||||
command: "viewBookmarksSidebar",
|
||||
panelOpen: false,
|
||||
launcherVisible: true,
|
||||
});
|
||||
|
||||
const props = sidebarState.getProperties();
|
||||
Assert.ok(!props.panelOpen, "The panel is marked as closed.");
|
||||
Assert.equal(props.launcherVisible, true, "The launcher is visible.");
|
||||
Assert.equal(props.command, "viewBookmarksSidebar", "The command matches.");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user