Bug 1892965 - Rename SidebarUI and SidebarLauncher r=sidebar-reviewers,places-reviewers,nsharpley

Differential Revision: https://phabricator.services.mozilla.com/D208901
This commit is contained in:
Sarah Clements 2024-05-03 15:20:15 +00:00
Родитель 0bf8a2c00f
Коммит 6c0504ee55
61 изменённых файлов: 304 добавлений и 253 удалений

Просмотреть файл

@ -3,7 +3,7 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
<hbox flex="1" id="browser">
<html:sidebar-launcher id="sidebar-launcher" flex="1" hidden="true"></html:sidebar-launcher>
<html:sidebar-main id="sidebar-main" flex="1" hidden="true"></html:sidebar-main>
<vbox id="sidebar-box" hidden="true" class="chromeclass-extrachrome">
<box id="sidebar-header" align="center">
<toolbarbutton id="sidebar-switcher-target" class="tabbable" aria-expanded="false">
@ -13,7 +13,7 @@
</toolbarbutton>
<image id="sidebar-throbber"/>
<spacer id="sidebar-spacer"/>
<toolbarbutton id="sidebar-close" class="close-icon tabbable" data-l10n-id="sidebar-close-button" oncommand="SidebarUI.hide();"/>
<toolbarbutton id="sidebar-close" class="close-icon tabbable" data-l10n-id="sidebar-close-button" oncommand="SidebarController.hide();"/>
</box>
<browser id="sidebar" autoscroll="false" disablehistory="true" disablefullscreen="true" tooltip="aHTMLTooltip"/>
</vbox>

Просмотреть файл

@ -213,7 +213,7 @@ var gBrowserInit = {
gBrowser.addProgressListener(window.XULBrowserWindow);
gBrowser.addTabsProgressListener(window.TabsProgressListener);
SidebarUI.init();
SidebarController.init();
// We do this in onload because we want to ensure the button's state
// doesn't flicker as the window is being shown.
@ -484,7 +484,7 @@ var gBrowserInit = {
// Enable the Restore Last Session command if needed
RestoreLastSessionObserver.init();
SidebarUI.startDelayedLoad();
SidebarController.startDelayedLoad();
PanicButtonNotifier.init();
});
@ -1021,7 +1021,7 @@ var gBrowserInit = {
CaptivePortalWatcher.uninit();
SidebarUI.uninit();
SidebarController.uninit();
DownloadsButton.uninit();

Просмотреть файл

@ -140,7 +140,7 @@
</menupopup>
</menu>
<menu id="viewSidebarMenuMenu" data-l10n-id="menu-view-sidebar">
<menupopup id="viewSidebarMenu" onpopupshowing="SidebarUI.setMegalistMenubarVisibility(event);">
<menupopup id="viewSidebarMenu" onpopupshowing="SidebarController.setMegalistMenubarVisibility(event);">
</menupopup>
</menu>
<menuseparator/>

Просмотреть файл

@ -1377,7 +1377,7 @@ var BookmarkingUI = {
this.updateLabel(
"BMB_viewBookmarksSidebar",
SidebarUI.currentID == "viewBookmarksSidebar"
SidebarController.currentID == "viewBookmarksSidebar"
);
this.updateLabel("BMB_viewBookmarksToolbar", !this.toolbar.collapsed);
},

Просмотреть файл

@ -276,7 +276,7 @@
<key id="viewBookmarksSidebarKb"
data-l10n-id="bookmark-show-sidebar-shortcut"
modifiers="accel"
oncommand="SidebarUI.toggle('viewBookmarksSidebar');"/>
oncommand="SidebarController.toggle('viewBookmarksSidebar');"/>
<key id="viewBookmarksToolbarKb"
data-l10n-id="bookmark-show-toolbar-shortcut"
oncommand="BookmarkingUI.toggleBookmarksToolbar('shortcut');"
@ -295,7 +295,7 @@
#else
modifiers="accel"
#endif
oncommand="SidebarUI.toggle('viewHistorySidebar');"/>
oncommand="SidebarController.toggle('viewHistorySidebar');"/>
<key id="key_fullZoomReduce" data-l10n-id="full-zoom-reduce-shortcut" command="cmd_fullZoomReduce" modifiers="accel"/>
<key data-l10n-id="full-zoom-reduce-shortcut-alt-a" command="cmd_fullZoomReduce" modifiers="accel"/>

Просмотреть файл

@ -1521,7 +1521,7 @@ function HandleAppCommandEvent(evt) {
BrowserSearch.webSearch();
break;
case "Bookmarks":
SidebarUI.toggle("viewBookmarksSidebar");
SidebarController.toggle("viewBookmarksSidebar");
break;
case "Home":
BrowserCommands.home();
@ -5164,9 +5164,10 @@ var gUIDensity = {
}
let docs = [document.documentElement];
let shouldUpdateSidebar = SidebarUI.initialized && SidebarUI.isOpen;
let shouldUpdateSidebar =
SidebarController.initialized && SidebarController.isOpen;
if (shouldUpdateSidebar) {
docs.push(SidebarUI.browser.contentDocument.documentElement);
docs.push(SidebarController.browser.contentDocument.documentElement);
}
for (let doc of docs) {
switch (mode) {
@ -5182,7 +5183,7 @@ var gUIDensity = {
}
}
if (shouldUpdateSidebar) {
let tree = SidebarUI.browser.contentDocument.querySelector(
let tree = SidebarController.browser.contentDocument.querySelector(
".sidebar-placesTree"
);
if (tree) {

Просмотреть файл

@ -256,26 +256,26 @@
<menuitem id="sidebar-switcher-bookmarks"
data-l10n-id="sidebar-menu-bookmarks"
key="viewBookmarksSidebarKb"
oncommand="SidebarUI.show('viewBookmarksSidebar');"/>
oncommand="SidebarController.show('viewBookmarksSidebar');"/>
<menuitem id="sidebar-switcher-history"
data-l10n-id="sidebar-menu-history"
key="key_gotoHistory"
oncommand="SidebarUI.show('viewHistorySidebar');"/>
oncommand="SidebarController.show('viewHistorySidebar');"/>
<menuitem id="sidebar-switcher-tabs"
data-l10n-id="sidebar-menu-synced-tabs"
class="sync-ui-item"
oncommand="SidebarUI.show('viewTabsSidebar');"/>
oncommand="SidebarController.show('viewTabsSidebar');"/>
<menuitem id="sidebar-switcher-megalist"
data-l10n-id="sidebar-menu-megalist"
oncommand="SidebarUI.show('viewMegalistSidebar');"/>
oncommand="SidebarController.show('viewMegalistSidebar');"/>
<menuseparator/>
<!-- Extension toolbarbuttons go here. -->
<menuseparator id="sidebar-extensions-separator"/>
<menuitem id="sidebar-reverse-position"
oncommand="SidebarUI.reversePosition()"/>
oncommand="SidebarController.reversePosition()"/>
<menuseparator/>
<menuitem data-l10n-id="sidebar-menu-close"
oncommand="SidebarUI.hide()"/>
oncommand="SidebarController.hide()"/>
</menupopup>
<menupopup id="toolbar-context-menu"

Просмотреть файл

@ -621,7 +621,7 @@
<menuitem id="BMB_viewBookmarksSidebar"
data-l10n-id="bookmarks-tools-sidebar-visibility"
data-l10n-args='{ "isVisible": false }'
oncommand="SidebarUI.toggle('viewBookmarksSidebar');"
oncommand="SidebarController.toggle('viewBookmarksSidebar');"
key="viewBookmarksSidebarKb"/>
<menuitem id="BMB_searchBookmarks"
data-l10n-id="bookmarks-search"

Просмотреть файл

@ -229,7 +229,7 @@ add_task(async function () {
let sidebar = document.getElementById("sidebar");
let loadPromise = BrowserTestUtils.waitForEvent(sidebar, "load", true);
SidebarUI.toggle("viewBookmarksSidebar");
SidebarController.toggle("viewBookmarksSidebar");
await loadPromise;
gURLBar.focus();
@ -278,7 +278,7 @@ add_task(async function () {
"back focus with sidebar urlbar"
);
SidebarUI.toggle("viewBookmarksSidebar");
SidebarController.toggle("viewBookmarksSidebar");
});
// Navigate when the downloads panel is open

Просмотреть файл

@ -5,7 +5,7 @@
* during the initial browser startup - but it would be hard to do with a mochitest. */
registerCleanupFunction(() => {
SidebarUI.hide();
SidebarController.hide();
});
function failIfSidebarFocusedFires() {
@ -26,7 +26,7 @@ add_task(async function testAdoptedTwoWindows() {
info("Ensure that sidebar state is adopted only from the opener");
let win1 = await BrowserTestUtils.openNewBrowserWindow();
await win1.SidebarUI.show("viewBookmarksSidebar");
await win1.SidebarController.show("viewBookmarksSidebar");
await BrowserTestUtils.closeWindow(win1);
let win2 = await BrowserTestUtils.openNewBrowserWindow();
@ -34,7 +34,7 @@ add_task(async function testAdoptedTwoWindows() {
!win2.document.getElementById("sidebar-button").hasAttribute("checked"),
"Sidebar button isn't checked"
);
ok(!win2.SidebarUI.isOpen, "Sidebar is closed");
ok(!win2.SidebarController.isOpen, "Sidebar is closed");
await BrowserTestUtils.closeWindow(win2);
});
@ -46,7 +46,7 @@ add_task(async function testEventsReceivedInMainWindow() {
let initialShown = BrowserTestUtils.waitForEvent(window, "SidebarShown");
let initialFocus = BrowserTestUtils.waitForEvent(window, "SidebarFocused");
await SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
await initialShown;
await initialFocus;

Просмотреть файл

@ -8,7 +8,7 @@
add_task(function cleanup() {
registerCleanupFunction(() => {
SidebarUI.hide();
SidebarController.hide();
});
});
@ -17,7 +17,7 @@ add_task(function cleanup() {
*/
async function testLiveReloading(sidebarName) {
info("Showing the sidebar " + sidebarName);
await SidebarUI.show(sidebarName);
await SidebarController.show(sidebarName);
function getTreeChildren() {
const sidebarDoc =
@ -44,7 +44,7 @@ async function testLiveReloading(sidebarName) {
);
info("Hiding the sidebar");
SidebarUI.hide();
SidebarController.hide();
}
add_task(async function test_bookmarks_sidebar() {

Просмотреть файл

@ -11,11 +11,11 @@ async function testSidebarKeyToggle(key, options, expectedSidebarId) {
expectedSidebarId
);
EventUtils.synthesizeKey(key, options);
Assert.ok(!SidebarUI.isOpen);
Assert.ok(!SidebarController.isOpen);
}
add_task(async function test_sidebar_keys() {
registerCleanupFunction(() => SidebarUI.hide());
registerCleanupFunction(() => SidebarController.hide());
await testSidebarKeyToggle("b", { accelKey: true }, "viewBookmarksSidebar");
@ -30,7 +30,7 @@ add_task(async function test_sidebar_in_customize_mode() {
let { CustomizableUI } = ChromeUtils.importESModule(
"resource:///modules/CustomizableUI.sys.mjs"
);
registerCleanupFunction(() => SidebarUI.hide());
registerCleanupFunction(() => SidebarController.hide());
let placement = CustomizableUI.getPlacementOfWidget("sidebar-button");
if (!(placement?.area == CustomizableUI.AREA_NAVBAR)) {
@ -55,7 +55,7 @@ add_task(async function test_sidebar_in_customize_mode() {
).a;
let promiseShown = BrowserTestUtils.waitForEvent(window, "SidebarShown");
SidebarUI.show("viewBookmarksSidebar");
SidebarController.show("viewBookmarksSidebar");
await promiseShown;
Assert.greater(
@ -80,8 +80,8 @@ add_task(async function test_sidebar_in_customize_mode() {
);
// Attempt toggle - should fail in customize mode.
await SidebarUI.toggle();
ok(SidebarUI.isOpen, "Sidebar is still open");
await SidebarController.toggle();
ok(SidebarController.isOpen, "Sidebar is still open");
// Exit customize mode. This should re-enable the toggle and make the sidebar
// toggle widget appear checked again, since toggle() didn't hide the sidebar.
@ -98,8 +98,8 @@ add_task(async function test_sidebar_in_customize_mode() {
"Sidebar widget background should appear checked again"
);
await SidebarUI.toggle();
ok(!SidebarUI.isOpen, "Sidebar is closed");
await SidebarController.toggle();
ok(!SidebarController.isOpen, "Sidebar is closed");
Assert.equal(
getBGAlpha(),
0,

Просмотреть файл

@ -1,17 +1,17 @@
registerCleanupFunction(() => {
Services.prefs.clearUserPref("sidebar.position_start");
SidebarUI.hide();
SidebarController.hide();
});
const EXPECTED_START_ORDINALS = [
["sidebar-launcher", 1],
["sidebar-main", 1],
["sidebar-box", 2],
["sidebar-splitter", 3],
["appcontent", 4],
];
const EXPECTED_END_ORDINALS = [
["sidebar-launcher", 5],
["sidebar-main", 5],
["sidebar-box", 4],
["sidebar-splitter", 3],
["appcontent", 2],
@ -25,8 +25,8 @@ function getBrowserChildrenWithOrdinals() {
}
add_task(async function () {
await SidebarUI.show("viewBookmarksSidebar");
SidebarUI.showSwitcherPanel();
await SidebarController.show("viewBookmarksSidebar");
SidebarController.showSwitcherPanel();
let reversePositionButton = document.getElementById(
"sidebar-reverse-position"
@ -43,8 +43,8 @@ add_task(async function () {
ok(!box.hasAttribute("positionend"), "Positioned start");
// Moved to right
SidebarUI.reversePosition();
SidebarUI.showSwitcherPanel();
SidebarController.reversePosition();
SidebarController.showSwitcherPanel();
Assert.deepEqual(
getBrowserChildrenWithOrdinals(),
EXPECTED_END_ORDINALS,
@ -58,8 +58,8 @@ add_task(async function () {
ok(box.hasAttribute("positionend"), "Positioned end");
// Moved to back to left
SidebarUI.reversePosition();
SidebarUI.showSwitcherPanel();
SidebarController.reversePosition();
SidebarController.showSwitcherPanel();
Assert.deepEqual(
getBrowserChildrenWithOrdinals(),
EXPECTED_START_ORDINALS,

Просмотреть файл

@ -18,7 +18,7 @@ add_task(async function persist_sidebar_width() {
{
info("Showing new window and setting sidebar box");
const win = await BrowserTestUtils.openNewBrowserWindow();
await win.SidebarUI.show("viewBookmarksSidebar");
await win.SidebarController.show("viewBookmarksSidebar");
win.document.getElementById("sidebar-box").style.width = "100px";
await BrowserTestUtils.closeWindow(win);
}
@ -26,7 +26,7 @@ add_task(async function persist_sidebar_width() {
{
info("Showing new window and seeing persisted width");
const win = await BrowserTestUtils.openNewBrowserWindow();
await win.SidebarUI.show("viewBookmarksSidebar");
await win.SidebarController.show("viewBookmarksSidebar");
is(
win.document.getElementById("sidebar-box").style.width,
"100px",

Просмотреть файл

@ -1,5 +1,5 @@
registerCleanupFunction(() => {
SidebarUI.hide();
SidebarController.hide();
});
/**
@ -9,14 +9,14 @@ registerCleanupFunction(() => {
*/
function showSwitcherPanelPromise() {
return new Promise(resolve => {
SidebarUI._switcherPanel.addEventListener(
SidebarController._switcherPanel.addEventListener(
"popupshown",
() => {
resolve();
},
{ once: true }
);
SidebarUI.showSwitcherPanel();
SidebarController.showSwitcherPanel();
});
}
@ -25,7 +25,10 @@ function showSwitcherPanelPromise() {
* @returns Promise which resolves when the popup menu is opened
*/
async function waitForSwitcherPopupShown() {
return BrowserTestUtils.waitForEvent(SidebarUI._switcherPanel, "popupshown");
return BrowserTestUtils.waitForEvent(
SidebarController._switcherPanel,
"popupshown"
);
}
/**
@ -63,7 +66,7 @@ async function testSidebarMenuKeyToggle(key, sidebarTitle) {
info(`Testing "${key}" key handling of sidebar menu popup items
to access ${sidebarTitle} sidebar`);
Assert.ok(SidebarUI.isOpen, "Sidebar is open");
Assert.ok(SidebarController.isOpen, "Sidebar is open");
let sidebarSwitcher = document.querySelector("#sidebar-switcher-target");
let sidebar = document.getElementById("sidebar");
@ -89,7 +92,7 @@ async function testSidebarMenuKeyToggle(key, sidebarTitle) {
"The sidebar switcher target button is focused"
);
Assert.equal(
SidebarUI._switcherPanel.state,
SidebarController._switcherPanel.state,
"closed",
"Sidebar menu popup is closed"
);
@ -102,7 +105,7 @@ async function testSidebarMenuKeyToggle(key, sidebarTitle) {
await promisePopupShown;
Assert.equal(
SidebarUI._switcherPanel.state,
SidebarController._switcherPanel.state,
"open",
"Sidebar menu popup is open"
);
@ -111,7 +114,7 @@ async function testSidebarMenuKeyToggle(key, sidebarTitle) {
let arrowDown = async (menuitemId, msg) => {
let menuItemActive = BrowserTestUtils.waitForEvent(
SidebarUI._switcherPanel,
SidebarController._switcherPanel,
"DOMMenuItemActive"
);
EventUtils.synthesizeKey("KEY_ArrowDown", {});
@ -149,18 +152,18 @@ async function testSidebarMenuKeyToggle(key, sidebarTitle) {
info("Testing keyboard navigation when a sidebar menu popup is closed");
Assert.equal(
SidebarUI._switcherPanel.state,
SidebarController._switcherPanel.state,
"closed",
"Sidebar menu popup is closed"
);
// Test the sidebar panel is updated
Assert.equal(
SidebarUI._box.getAttribute("sidebarcommand"),
SidebarController._box.getAttribute("sidebarcommand"),
`view${sidebarTitle}Sidebar` /* e.g. "viewHistorySidebar" */,
`${sidebarTitle} sidebar loaded`
);
Assert.equal(
SidebarUI.currentID,
SidebarController.currentID,
`view${sidebarTitle}Sidebar` /* e.g. "viewHistorySidebar" */,
`${sidebarTitle}'s current ID is updated to a target view`
);
@ -173,7 +176,7 @@ add_task(async function markup() {
false,
"Unexpected sidebar found - a previous test failed to cleanup correctly"
);
SidebarUI.hide();
SidebarController.hide();
}
let sidebarPopup = document.querySelector("#sidebarMenu-popup");
@ -205,7 +208,7 @@ add_task(async function markup() {
info("Test dynamic changes in the markup of the sidebar switcher control");
await SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
await showSwitcherPanelPromise();
Assert.equal(
@ -229,25 +232,25 @@ add_task(async function markup() {
"Sidebar switcher button is collapsed when a sidebar menu is dismissed"
);
SidebarUI.hide();
SidebarController.hide();
});
add_task(async function keynav() {
// If a sidebar is already open, close it.
if (SidebarUI.isOpen) {
if (SidebarController.isOpen) {
Assert.ok(
false,
"Unexpected sidebar found - a previous test failed to cleanup correctly"
);
SidebarUI.hide();
SidebarController.hide();
}
await SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
await testSidebarMenuKeyToggle("KEY_Enter", "History");
await testSidebarMenuKeyToggle(" ", "Tabs");
SidebarUI.hide();
SidebarController.hide();
});
add_task(async function mouse() {
@ -257,11 +260,11 @@ add_task(async function mouse() {
false,
"Unexpected sidebar found - a previous test failed to cleanup correctly"
);
SidebarUI.hide();
SidebarController.hide();
}
let sidebar = document.querySelector("#sidebar-box");
await SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
await showSwitcherPanelPromise();
await pickSwitcherMenuitem("#sidebar-switcher-history");

Просмотреть файл

@ -280,7 +280,7 @@ export const CustomizableWidgets = [
tooltiptext: "sidebar-button.tooltiptext2",
onCommand(aEvent) {
let win = aEvent.target.ownerGlobal;
win.SidebarUI.toggle();
win.SidebarController.toggle();
},
onCreated(aNode) {
// Add an observer so the button is checked while the sidebar is open

Просмотреть файл

@ -9,7 +9,7 @@ registerCleanupFunction(async function () {
// Ensure sidebar is hidden after each test:
if (!document.getElementById("sidebar-box").hidden) {
SidebarUI.hide();
SidebarController.hide();
}
});
@ -21,14 +21,14 @@ var showSidebar = async function (win = window) {
);
EventUtils.synthesizeMouseAtCenter(button, {}, win);
await sidebarFocusedPromise;
ok(win.SidebarUI.isOpen, "Sidebar is opened");
ok(win.SidebarController.isOpen, "Sidebar is opened");
ok(button.hasAttribute("checked"), "Toolbar button is checked");
};
var hideSidebar = async function (win = window) {
let button = win.document.getElementById("sidebar-button");
EventUtils.synthesizeMouseAtCenter(button, {}, win);
ok(!win.SidebarUI.isOpen, "Sidebar is closed");
ok(!win.SidebarController.isOpen, "Sidebar is closed");
ok(!button.hasAttribute("checked"), "Toolbar button isn't checked");
};
@ -37,18 +37,26 @@ add_task(async function () {
CustomizableUI.addWidgetToArea("sidebar-button", "nav-bar");
await showSidebar();
is(SidebarUI.currentID, "viewBookmarksSidebar", "Default sidebar selected");
await SidebarUI.show("viewHistorySidebar");
is(
SidebarController.currentID,
"viewBookmarksSidebar",
"Default sidebar selected"
);
await SidebarController.show("viewHistorySidebar");
await hideSidebar();
await showSidebar();
is(SidebarUI.currentID, "viewHistorySidebar", "Selected sidebar remembered");
is(
SidebarController.currentID,
"viewHistorySidebar",
"Selected sidebar remembered"
);
await hideSidebar();
let otherWin = await BrowserTestUtils.openNewBrowserWindow();
await showSidebar(otherWin);
is(
otherWin.SidebarUI.currentID,
otherWin.SidebarController.currentID,
"viewHistorySidebar",
"Selected sidebar remembered across windows"
);

Просмотреть файл

@ -1100,11 +1100,11 @@ const menuTracker = {
);
sidebarHeader.addEventListener("SidebarShown", menuTracker.onSidebarShown);
await window.SidebarUI.promiseInitialized;
await window.SidebarController.promiseInitialized;
if (
!window.closed &&
window.SidebarUI.currentID === "viewBookmarksSidebar"
window.SidebarController.currentID === "viewBookmarksSidebar"
) {
menuTracker.onSidebarShown({ currentTarget: sidebarHeader });
}
@ -1121,8 +1121,8 @@ const menuTracker = {
);
sidebarHeader.removeEventListener("SidebarShown", this.onSidebarShown);
if (window.SidebarUI.currentID === "viewBookmarksSidebar") {
let sidebarBrowser = window.SidebarUI.browser;
if (window.SidebarController.currentID === "viewBookmarksSidebar") {
let sidebarBrowser = window.SidebarController.browser;
sidebarBrowser.removeEventListener("load", this.onSidebarShown);
const menu =
sidebarBrowser.contentDocument.getElementById("placesContext");
@ -1134,10 +1134,10 @@ const menuTracker = {
// The event target is an element in a browser window, so |window| will be
// the browser window that contains the sidebar.
const window = event.currentTarget.ownerGlobal;
if (window.SidebarUI.currentID === "viewBookmarksSidebar") {
let sidebarBrowser = window.SidebarUI.browser;
if (window.SidebarController.currentID === "viewBookmarksSidebar") {
let sidebarBrowser = window.SidebarController.browser;
if (sidebarBrowser.contentDocument.readyState !== "complete") {
// SidebarUI.currentID may be updated before the bookmark sidebar's
// SidebarController.currentID may be updated before the bookmark sidebar's
// document has finished loading. This sometimes happens when the
// sidebar is automatically shown when a new window is opened.
sidebarBrowser.addEventListener("load", menuTracker.onSidebarShown, {

Просмотреть файл

@ -82,8 +82,8 @@ this.sidebarAction = class extends ExtensionAPI {
}
for (let window of windowTracker.browserWindows()) {
let { SidebarUI } = window;
SidebarUI.removeExtension(this.id);
let { SidebarController } = window;
SidebarController.removeExtension(this.id);
}
windowTracker.removeOpenListener(this.windowOpenListener);
}
@ -91,9 +91,9 @@ this.sidebarAction = class extends ExtensionAPI {
static onUninstall(id) {
const sidebarId = `${makeWidgetId(id)}-sidebar-action`;
for (let window of windowTracker.browserWindows()) {
let { SidebarUI } = window;
if (SidebarUI.lastOpenedId === sidebarId) {
SidebarUI.lastOpenedId = null;
let { SidebarController } = window;
if (SidebarController.lastOpenedId === sidebarId) {
SidebarController.lastOpenedId = null;
}
}
}
@ -107,12 +107,12 @@ this.sidebarAction = class extends ExtensionAPI {
let install = this.extension.startupReason === "ADDON_INSTALL";
for (let window of windowTracker.browserWindows()) {
this.updateWindow(window);
let { SidebarUI } = window;
let { SidebarController } = window;
if (
(install && this.extension.manifest.sidebar_action.open_at_install) ||
SidebarUI.lastOpenedId == this.id
SidebarController.lastOpenedId == this.id
) {
SidebarUI.show(this.id);
SidebarController.show(this.id);
}
}
}
@ -122,14 +122,14 @@ this.sidebarAction = class extends ExtensionAPI {
return;
}
this.panel = details.panel;
let { SidebarUI } = window;
SidebarUI.registerExtension(this.id, {
let { SidebarController } = window;
SidebarController.registerExtension(this.id, {
icon: this.getMenuIcon(details),
menuId: this.menuId,
title: details.title,
extensionId: this.extension.id,
onload: () =>
SidebarUI.browser.contentWindow.loadPanel(
SidebarController.browser.contentWindow.loadPanel(
this.extension.id,
this.panel,
this.browserStyle
@ -155,7 +155,7 @@ this.sidebarAction = class extends ExtensionAPI {
* Tab specific sidebar configuration.
*/
updateButton(window, tabData) {
let { document, SidebarUI } = window;
let { document, SidebarController } = window;
let title = tabData.title || this.extension.name;
if (!document.getElementById(this.menuId)) {
// Menu items are added when new windows are opened, or from onReady (when
@ -167,7 +167,7 @@ this.sidebarAction = class extends ExtensionAPI {
if (urlChanged) {
this.panel = tabData.panel;
}
SidebarUI.setExtensionAttributes(
SidebarController.setExtensionAttributes(
this.id,
{
icon: this.getMenuIcon(tabData),
@ -315,9 +315,9 @@ this.sidebarAction = class extends ExtensionAPI {
* @param {ChromeWindow} window
*/
triggerAction(window) {
let { SidebarUI } = window;
if (SidebarUI && this.extension.canAccessWindow(window)) {
SidebarUI.toggle(this.id);
let { SidebarController } = window;
if (SidebarController && this.extension.canAccessWindow(window)) {
SidebarController.toggle(this.id);
}
}
@ -327,9 +327,9 @@ this.sidebarAction = class extends ExtensionAPI {
* @param {ChromeWindow} window
*/
open(window) {
let { SidebarUI } = window;
if (SidebarUI && this.extension.canAccessWindow(window)) {
SidebarUI.show(this.id);
let { SidebarController } = window;
if (SidebarController && this.extension.canAccessWindow(window)) {
SidebarController.show(this.id);
}
}
@ -340,7 +340,7 @@ this.sidebarAction = class extends ExtensionAPI {
*/
close(window) {
if (this.isOpen(window)) {
window.SidebarUI.hide();
window.SidebarController.hide();
}
}
@ -350,15 +350,15 @@ this.sidebarAction = class extends ExtensionAPI {
* @param {ChromeWindow} window
*/
toggle(window) {
let { SidebarUI } = window;
if (!SidebarUI || !this.extension.canAccessWindow(window)) {
let { SidebarController } = window;
if (!SidebarController || !this.extension.canAccessWindow(window)) {
return;
}
if (!this.isOpen(window)) {
SidebarUI.show(this.id);
SidebarController.show(this.id);
} else {
SidebarUI.hide();
SidebarController.hide();
}
}
@ -369,8 +369,8 @@ this.sidebarAction = class extends ExtensionAPI {
* @returns {boolean}
*/
isOpen(window) {
let { SidebarUI } = window;
return SidebarUI.isOpen && this.id == SidebarUI.currentID;
let { SidebarController } = window;
return SidebarController.isOpen && this.id == SidebarController.currentID;
}
getAPI(context) {

Просмотреть файл

@ -401,11 +401,11 @@ add_task(async function updateSidebarCommand() {
await extension.awaitMessage("sidebar");
// Show and hide the switcher panel to generate the initial shortcuts.
let switcherShown = promisePopupShown(SidebarUI._switcherPanel);
SidebarUI.showSwitcherPanel();
let switcherShown = promisePopupShown(SidebarController._switcherPanel);
SidebarController.showSwitcherPanel();
await switcherShown;
let switcherHidden = promisePopupHidden(SidebarUI._switcherPanel);
SidebarUI.hideSwitcherPanel();
let switcherHidden = promisePopupHidden(SidebarController._switcherPanel);
SidebarController.hideSwitcherPanel();
await switcherHidden;
let menuitemId = `sidebarswitcher_menu_${makeWidgetId(

Просмотреть файл

@ -724,7 +724,7 @@ add_task(async function test_bookmark_sidebar_contextmenu() {
await extension.startup();
let bookmarkGuid = await extension.awaitMessage("bookmark-created");
let sidebar = window.SidebarUI.browser;
let sidebar = window.SidebarController.browser;
let menu = sidebar.contentDocument.getElementById("placesContext");
tree.selectItems([bookmarkGuid]);
let shown = BrowserTestUtils.waitForEvent(menu, "popupshown");

Просмотреть файл

@ -54,7 +54,7 @@ add_task(async function test_bookmark_sidebar_contextmenu() {
expectedVirtualID,
] of expected_bookmarkID_2_virtualID) {
info(`Testing context menu for Bookmark ID "${expectedBookmarkID}"`);
let sidebar = window.SidebarUI.browser;
let sidebar = window.SidebarController.browser;
let menu = sidebar.contentDocument.getElementById("placesContext");
tree.selectItems([expectedBookmarkID]);

Просмотреть файл

@ -189,7 +189,9 @@ add_task(async function overrideContext_permissions() {
// permissions.request requires user input, export helper.
await SpecialPowers.spawn(
SidebarUI.browser.contentDocument.getElementById("webext-panels-browser"),
SidebarController.browser.contentDocument.getElementById(
"webext-panels-browser"
),
[],
() => {
const { ExtensionCommon } = ChromeUtils.importESModule(
@ -212,7 +214,9 @@ add_task(async function overrideContext_permissions() {
await BrowserTestUtils.synthesizeMouseAtCenter(
"a",
{ type: "contextmenu" },
SidebarUI.browser.contentDocument.getElementById("webext-panels-browser")
SidebarController.browser.contentDocument.getElementById(
"webext-panels-browser"
)
);
} while (await extension.awaitMessage("continue_test"));

Просмотреть файл

@ -120,7 +120,7 @@ async function test_mousewheel_zoom(test) {
const sidebar = document.getElementById("sidebar-box");
ok(!sidebar.hidden, "Sidebar box is visible");
browser = SidebarUI.browser.contentWindow.gBrowser.selectedBrowser;
browser = SidebarController.browser.contentWindow.gBrowser.selectedBrowser;
} else if (test == TESTS.BROWSER_ACTION) {
browser = await openBrowserActionPanel(extension, undefined, true);
} else if (test == TESTS.PAGE_ACTION) {

Просмотреть файл

@ -136,16 +136,16 @@ add_task(async function test_openPopup_requires_user_interaction() {
{},
gBrowser.selectedBrowser
);
await TestUtils.waitForCondition(() => !SidebarUI.isOpen);
await TestUtils.waitForCondition(() => !SidebarController.isOpen);
await click("#toggleSidebarAction");
await TestUtils.waitForCondition(() => SidebarUI.isOpen);
await TestUtils.waitForCondition(() => SidebarController.isOpen);
await BrowserTestUtils.synthesizeMouseAtCenter(
"#toggleSidebarAction",
{},
gBrowser.selectedBrowser
);
await TestUtils.waitForCondition(() => !SidebarUI.isOpen);
await TestUtils.waitForCondition(() => !SidebarController.isOpen);
BrowserTestUtils.removeTab(gBrowser.selectedTab);
await extension.unload();

Просмотреть файл

@ -154,7 +154,7 @@ add_task(async function sidebar_isOpen() {
info("Test extension1's sidebar is opened on install");
await extension1.awaitMessage("sidebar");
await sendMessage(extension1, "isOpen", { result: true });
let sidebar1ID = SidebarUI.currentID;
let sidebar1ID = SidebarController.currentID;
info("Load extension2");
let extension2 = ExtensionTestUtils.loadExtension(getExtData());
@ -166,7 +166,7 @@ add_task(async function sidebar_isOpen() {
await sendMessage(extension2, "isOpen", { result: true });
info("Switch back to extension1's sidebar");
SidebarUI.show(sidebar1ID);
SidebarController.show(sidebar1ID);
await extension1.awaitMessage("sidebar");
await sendMessage(extension1, "isOpen", { result: true });
await sendMessage(extension2, "isOpen", { result: false });
@ -201,7 +201,7 @@ add_task(async function sidebar_isOpen() {
newWin.close();
info("Close the sidebar in the original window");
SidebarUI.hide();
SidebarController.hide();
await sendMessage(extension1, "isOpen", { result: false });
await sendMessage(extension2, "isOpen", { result: false });
@ -229,11 +229,15 @@ add_task(async function testShortcuts() {
async function toggleSwitcherPanel(win = window) {
// Open and close the switcher panel to trigger shortcut content rendering.
let switcherPanelShown = promisePopupShown(win.SidebarUI._switcherPanel);
win.SidebarUI.showSwitcherPanel();
let switcherPanelShown = promisePopupShown(
win.SidebarController._switcherPanel
);
win.SidebarController.showSwitcherPanel();
await switcherPanelShown;
let switcherPanelHidden = promisePopupHidden(win.SidebarUI._switcherPanel);
win.SidebarUI.hideSwitcherPanel();
let switcherPanelHidden = promisePopupHidden(
win.SidebarController._switcherPanel
);
win.SidebarController.hideSwitcherPanel();
await switcherPanelHidden;
}
@ -316,20 +320,22 @@ add_task(async function sidebar_switcher_panel_icon_update() {
info("Test extension's sidebar is opened on install");
await extension.awaitMessage("sidebar");
await sendMessage(extension, "isOpen", { result: true });
const sidebarID = SidebarUI.currentID;
const sidebarID = SidebarController.currentID;
const item = SidebarUI._switcherPanel.querySelector(".webextension-menuitem");
const item = SidebarController._switcherPanel.querySelector(
".webextension-menuitem"
);
let iconUrl = `moz-extension://${extension.uuid}/default.png`;
is(
item.style.getPropertyValue("--webextension-menuitem-image"),
`image-set(url("${iconUrl}"), url("${iconUrl}") 2x)`,
"Extension has the correct icon."
);
SidebarUI.hide();
SidebarController.hide();
await sendMessage(extension, "isOpen", { result: false });
await sendMessage(extension, "set-icon", "1.png");
await SidebarUI.show(sidebarID);
await SidebarController.show(sidebarID);
await extension.awaitMessage("sidebar");
await sendMessage(extension, "isOpen", { result: true });
iconUrl = `moz-extension://${extension.uuid}/1.png`;

Просмотреть файл

@ -54,7 +54,7 @@ add_task(async function test_sidebar_click_isAppTab_behavior() {
await extension.awaitMessage("sidebar-ready");
// This test fails if docShell.isAppTab has not been set to true.
let content = SidebarUI.browser.contentWindow;
let content = SidebarController.browser.contentWindow;
// Wait for the layout to be flushed, otherwise this test may
// fail intermittently if synthesizeMouseAtCenter is being called

Просмотреть файл

@ -124,7 +124,7 @@ async function runTests(options) {
});
// Wait for initial sidebar load.
SidebarUI.browser.addEventListener(
SidebarController.browser.addEventListener(
"load",
async () => {
// Wait for the background page listeners to be ready and

Просмотреть файл

@ -42,7 +42,7 @@ add_task(async function sidebar_httpAuthPrompt() {
// Wait for the http auth prompt and close it with accept button.
let promptPromise = PromptTestUtils.handleNextPrompt(
SidebarUI.browser.contentWindow,
SidebarController.browser.contentWindow,
{
modalType: Services.prompt.MODAL_TYPE_WINDOW,
promptType: "promptUserAndPass",

Просмотреть файл

@ -124,11 +124,14 @@ add_task(async function test_sidebarAction_not_allowed() {
await extension.startup();
let sidebarID = `${makeWidgetId(extension.id)}-sidebar-action`;
ok(SidebarUI.sidebars.has(sidebarID), "sidebar exists in non-private window");
ok(
SidebarController.sidebars.has(sidebarID),
"sidebar exists in non-private window"
);
let winData = await getIncognitoWindow();
let hasSidebar = winData.win.SidebarUI.sidebars.has(sidebarID);
let hasSidebar = winData.win.SidebarController.sidebars.has(sidebarID);
ok(!hasSidebar, "sidebar does not exist in private window");
// Test API access to private window data.
extension.sendMessage(winData.details);

Просмотреть файл

@ -52,9 +52,10 @@ add_task(async function test_sidebar_disconnect() {
await connected;
// Bug 1445080 fixes currentURI, test to avoid future breakage.
let currentURI = window.SidebarUI.browser.contentDocument.getElementById(
"webext-panels-browser"
).currentURI;
let currentURI =
window.SidebarController.browser.contentDocument.getElementById(
"webext-panels-browser"
).currentURI;
is(currentURI.scheme, "moz-extension", "currentURI is set correctly");
// switching sidebar to another extension
@ -68,7 +69,7 @@ add_task(async function test_sidebar_disconnect() {
// switching sidebar to built-in sidebar
let disconnected = extension2.awaitMessage("disconnected");
window.SidebarUI.show("viewBookmarksSidebar");
window.SidebarController.show("viewBookmarksSidebar");
await disconnected;
await extension.unload();

Просмотреть файл

@ -49,7 +49,7 @@ add_task(async function sidebar_windows() {
let secondSidebar = extension.awaitMessage("sidebar");
// SidebarUI relies on window.opener being set, which is normal behavior when
// SidebarController relies on window.opener being set, which is normal behavior when
// using menu or key commands to open a new browser window.
let win = await BrowserTestUtils.openNewBrowserWindow();

Просмотреть файл

@ -476,10 +476,11 @@ async function openContextMenuInPopup(
}
async function openContextMenuInSidebar(selector = "body") {
let contentAreaContextMenu = SidebarUI.browser.contentDocument.getElementById(
"contentAreaContextMenu"
);
let browser = SidebarUI.browser.contentDocument.getElementById(
let contentAreaContextMenu =
SidebarController.browser.contentDocument.getElementById(
"contentAreaContextMenu"
);
let browser = SidebarController.browser.contentDocument.getElementById(
"webext-panels-browser"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
@ -491,7 +492,9 @@ async function openContextMenuInSidebar(selector = "body") {
// fail intermittently if synthesizeMouseAtCenter is being called
// while the sidebar is still opening and the browser window layout
// being recomputed.
await SidebarUI.browser.contentWindow.promiseDocumentFlushed(() => {});
await SidebarController.browser.contentWindow.promiseDocumentFlushed(
() => {}
);
info("Opening context menu in sidebarAction panel");
await BrowserTestUtils.synthesizeMouseAtCenter(

Просмотреть файл

@ -1436,7 +1436,7 @@ PlacesController.prototype = {
let documentUrl = document.documentURI.toLowerCase();
if (documentUrl.endsWith("browser.xhtml")) {
// We're in a menu or a panel.
window.SidebarUI._show("viewBookmarksSidebar").then(() => {
window.SidebarController._show("viewBookmarksSidebar").then(() => {
let theSidebar = document.getElementById("sidebar");
theSidebar.contentDocument
.getElementById("bookmarks-view")

Просмотреть файл

@ -386,7 +386,9 @@ add_task(async function test_sidebar_folder_contextmenu_contents() {
tree.selectItems([folder.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -396,7 +398,7 @@ add_task(async function test_sidebar_folder_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -430,7 +432,9 @@ add_task(async function test_sidebar_multiple_folders_contextmenu_contents() {
tree.selectItems([folder1.guid, folder2.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -440,7 +444,7 @@ add_task(async function test_sidebar_multiple_folders_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -473,7 +477,9 @@ add_task(async function test_sidebar_bookmark_contextmenu_contents() {
tree.selectItems([bookmark.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -483,7 +489,7 @@ add_task(async function test_sidebar_bookmark_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -513,13 +519,17 @@ add_task(async function test_sidebar_bookmark_search_contextmenu_contents() {
info("Checking bookmark sidebar menu contents in search context");
// Perform a search first
let searchBox =
SidebarUI.browser.contentDocument.getElementById("search-box");
SidebarController.browser.contentDocument.getElementById(
"search-box"
);
searchBox.value = SECOND_BOOKMARK_TITLE;
searchBox.doCommand();
tree.selectItems([bookmark.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -529,7 +539,7 @@ add_task(async function test_sidebar_bookmark_search_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -641,7 +651,9 @@ add_task(async function test_sidebar_mixedselection_contextmenu_contents() {
tree.selectItems([bookmark.guid, folder.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -651,7 +663,7 @@ add_task(async function test_sidebar_mixedselection_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -679,7 +691,9 @@ add_task(async function test_sidebar_multiple_bookmarks_contextmenu_contents() {
tree.selectItems([bookmark.guid, bookmark2.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -689,7 +703,7 @@ add_task(async function test_sidebar_multiple_bookmarks_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -714,7 +728,9 @@ add_task(async function test_sidebar_multiple_links_contextmenu_contents() {
tree.selectAll();
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -724,7 +740,7 @@ add_task(async function test_sidebar_multiple_links_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});
@ -750,7 +766,9 @@ add_task(async function test_sidebar_mixed_bookmarks_contextmenu_contents() {
tree.selectItems([bookmark.guid, folder.guid]);
let contextMenu =
SidebarUI.browser.contentDocument.getElementById("placesContext");
SidebarController.browser.contentDocument.getElementById(
"placesContext"
);
let popupShownPromise = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
@ -760,7 +778,7 @@ add_task(async function test_sidebar_mixed_bookmarks_contextmenu_contents() {
return contextMenu;
},
optionItems,
SidebarUI.browser.contentDocument
SidebarController.browser.contentDocument
);
});
});

Просмотреть файл

@ -156,7 +156,7 @@ gTests.push({
},
finish() {
SidebarUI.hide();
SidebarController.hide();
},
async cleanup() {
@ -282,7 +282,7 @@ gTests.push({
},
finish() {
SidebarUI.hide();
SidebarController.hide();
},
async cleanup() {
@ -399,7 +399,7 @@ gTests.push({
},
finish() {
SidebarUI.hide();
SidebarController.hide();
},
async cleanup() {
@ -450,7 +450,7 @@ function execute_test_in_sidebar(test) {
},
{ capture: true, once: true }
);
SidebarUI.show(test.sidebar);
SidebarController.show(test.sidebar);
});
}

Просмотреть файл

@ -32,7 +32,7 @@ add_task(async function test() {
let sidebar = await promiseLoadedSidebar("viewBookmarksSidebar");
registerCleanupFunction(() => {
SidebarUI.hide();
SidebarController.hide();
});
// Focus the tree and check if its controller is returned.
@ -109,6 +109,6 @@ function promiseLoadedSidebar(cmd) {
{ capture: true, once: true }
);
SidebarUI.show(cmd);
SidebarController.show(cmd);
});
}

Просмотреть файл

@ -11,7 +11,7 @@
registerCleanupFunction(async () => {
CustomizableUI.setToolbarVisibility("PersonalToolbar", false);
CustomizableUI.removeWidgetFromArea("library-button");
SidebarUI.hide();
SidebarController.hide();
});
async function selectAppMenuView(buttonId, viewId) {

Просмотреть файл

@ -30,9 +30,9 @@ add_setup(async function () {
add_task(async function test_open_sidebar_and_customize() {
await withSidebarTree("bookmarks", async tree => {
async function checkTreeIsFunctional() {
Assert.ok(SidebarUI.isOpen, "Sidebar is open");
Assert.ok(SidebarController.isOpen, "Sidebar is open");
Assert.ok(
BrowserTestUtils.isVisible(SidebarUI.browser),
BrowserTestUtils.isVisible(SidebarController.browser),
"sidebar browser is visible"
);
Assert.ok(tree.view.result, "View result is defined");
@ -49,7 +49,7 @@ add_task(async function test_open_sidebar_and_customize() {
await promiseCustomizeStart();
Assert.ok(
!BrowserTestUtils.isVisible(SidebarUI.browser),
!BrowserTestUtils.isVisible(SidebarController.browser),
"sidebar browser is hidden"
);
Assert.ok(tree.view.result, "View result is defined");

Просмотреть файл

@ -31,7 +31,7 @@ add_task(async function test_sidebarpanels_click() {
false,
"Unexpected sidebar found - a previous test failed to cleanup correctly"
);
SidebarUI.hide();
SidebarController.hide();
}
// Ensure history is clean before starting the test.
@ -137,7 +137,7 @@ async function testPlacesPanel(testInfo) {
await promiseAlert;
executeSoon(async function () {
SidebarUI.hide();
SidebarController.hide();
await testInfo.cleanup();
resolve();
});
@ -147,7 +147,7 @@ async function testPlacesPanel(testInfo) {
);
});
SidebarUI.show(testInfo.sidebarName);
SidebarController.show(testInfo.sidebarName);
return promise;
}

Просмотреть файл

@ -11,7 +11,7 @@ const TEST_TITLE = "Test Bookmark";
let appMenuButton = document.getElementById("PanelUI-menu-button");
let bookmarksAppMenu = document.getElementById("PanelUI-bookmarks");
let sidebarWasAlreadyOpen = SidebarUI.isOpen;
let sidebarWasAlreadyOpen = SidebarController.isOpen;
const { CustomizableUITestUtils } = ChromeUtils.importESModule(
"resource://testing-common/CustomizableUITestUtils.sys.mjs"
@ -86,7 +86,7 @@ add_task(async function toolbarBookmarkShowInFolder() {
// Cleanup
await PlacesUtils.bookmarks.eraseEverything();
if (!sidebarWasAlreadyOpen) {
SidebarUI.hide();
SidebarController.hide();
}
await gCUITestUtils.hideMainMenu();
});

Просмотреть файл

@ -28,9 +28,9 @@ add_task(async function () {
let promiseSidebarLoaded = new Promise(resolve => {
sidebar.addEventListener("load", resolve, { capture: true, once: true });
});
SidebarUI.show("viewBookmarksSidebar");
SidebarController.show("viewBookmarksSidebar");
registerCleanupFunction(() => {
SidebarUI.hide();
SidebarController.hide();
});
await promiseSidebarLoaded;

Просмотреть файл

@ -395,7 +395,7 @@ var withSidebarTree = async function (type, taskFn) {
});
let sidebarId =
type == "bookmarks" ? "viewBookmarksSidebar" : "viewHistorySidebar";
SidebarUI.show(sidebarId);
SidebarController.show(sidebarId);
await sidebarLoadedPromise;
let treeId = type == "bookmarks" ? "bookmarks-view" : "historyTree";
@ -406,7 +406,7 @@ var withSidebarTree = async function (type, taskFn) {
try {
await taskFn(tree);
} finally {
SidebarUI.hide();
SidebarController.hide();
}
};

Просмотреть файл

@ -213,7 +213,7 @@ export const ResetPBMPanel = {
});
// In the remaining PBM window: If the sidebar is open close it.
triggeringWindow.SidebarUI?.hide();
triggeringWindow.SidebarController?.hide();
// Clear session store data for the remaining PBM window.
lazy.SessionStore.purgeDataForPrivateWindow(triggeringWindow);

Просмотреть файл

@ -682,23 +682,23 @@ add_task(async function test_reset_action_closes_sidebar() {
info(
"Open the sidebar of both the private browsing window and the normal browsing window."
);
await SidebarUI.show("viewBookmarksSidebar");
await win.SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
await win.SidebarController.show("viewBookmarksSidebar");
info("Trigger the restart PBM action");
await ResetPBMPanel._restartPBM(win);
Assert.ok(
SidebarUI.isOpen,
SidebarController.isOpen,
"Normal browsing window sidebar should still be open."
);
Assert.ok(
!win.SidebarUI.isOpen,
!win.SidebarController.isOpen,
"Private browsing sidebar should be closed."
);
// Cleanup: Close the sidebar of the normal browsing window.
SidebarUI.hide();
SidebarController.hide();
// Cleanup: Close the private window that remained open.
await BrowserTestUtils.closeWindow(win);

Просмотреть файл

@ -12,7 +12,7 @@ function test() {
// opens a sidebar
function openSidebar(win) {
return win.SidebarUI.show("viewBookmarksSidebar").then(() => win);
return win.SidebarController.show("viewBookmarksSidebar").then(() => win);
}
let windowCache = [];

Просмотреть файл

@ -5730,7 +5730,7 @@ var SessionStoreInternal = {
(sidebarBox.getAttribute("sidebarcommand") != aSidebar ||
!sidebarBox.getAttribute("checked"))
) {
aWindow.SidebarUI.showInitially(aSidebar);
aWindow.SidebarController.showInitially(aSidebar);
}
// since resizing/moving a window brings it to the foreground,
// we might want to re-focus the last focused window

Просмотреть файл

@ -3,9 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
* SidebarUI controls showing and hiding the browser sidebar.
* SidebarController handles logic such as toggling sidebar panels,
* dynamically adding menubar menu items for the View -> Sidebar menu,
* and provides APIs for sidebar extensions, etc.
*/
var SidebarUI = {
var SidebarController = {
get sidebars() {
if (this._sidebars) {
return this._sidebars;
@ -134,8 +136,8 @@ var SidebarUI = {
}
if (this.sidebarRevampEnabled) {
await import("chrome://browser/content/sidebar/sidebar-launcher.mjs");
document.getElementById("sidebar-launcher").hidden = false;
await import("chrome://browser/content/sidebar/sidebar-main.mjs");
document.getElementById("sidebar-main").hidden = false;
document.getElementById("sidebar-header").hidden = true;
} else {
this._switcherTarget.addEventListener("command", () => {
@ -351,30 +353,30 @@ var SidebarUI = {
[...browser.children].forEach((node, i) => {
node.style.order = i + 1;
});
let sidebarLauncher = document.querySelector("sidebar-launcher");
let sidebarMain = document.querySelector("sidebar-main");
if (!this._positionStart) {
// DOM ordering is: sidebar-launcher | sidebar-box | splitter | appcontent |
// Want to display as: | appcontent | splitter | sidebar-box | sidebar-launcher
// So we just swap box and appcontent ordering and move sidebar-launcher to the end
// DOM ordering is: sidebar-main | sidebar-box | splitter | appcontent |
// Want to display as: | appcontent | splitter | sidebar-box | sidebar-main
// So we just swap box and appcontent ordering and move sidebar-main to the end
let appcontent = document.getElementById("appcontent");
let boxOrdinal = this._box.style.order;
this._box.style.order = appcontent.style.order;
appcontent.style.order = boxOrdinal;
// the launcher should be on the right of the sidebar-box
sidebarLauncher.style.order = parseInt(this._box.style.order) + 1;
sidebarMain.style.order = parseInt(this._box.style.order) + 1;
// Indicate we've switched ordering to the box
this._box.setAttribute("positionend", true);
sidebarLauncher.setAttribute("positionend", true);
sidebarMain.setAttribute("positionend", true);
} else {
this._box.removeAttribute("positionend");
sidebarLauncher.removeAttribute("positionend");
sidebarMain.removeAttribute("positionend");
}
this.hideSwitcherPanel();
let content = SidebarUI.browser.contentWindow;
let content = SidebarController.browser.contentWindow;
if (content && content.updatePosition) {
content.updatePosition();
}
@ -391,7 +393,7 @@ var SidebarUI = {
// If the opener had a sidebar, open the same sidebar in our window.
// The opener can be the hidden window too, if we're coming from the state
// where no windows are open, and the hidden window has no sidebar box.
let sourceUI = sourceWindow.SidebarUI;
let sourceUI = sourceWindow.SidebarController;
if (!sourceUI || !sourceUI._box) {
// no source UI or no _box means we also can't adopt the state.
return false;
@ -904,14 +906,14 @@ var SidebarUI = {
// Add getters related to the position here, since we will want them
// available for both startDelayedLoad and init.
XPCOMUtils.defineLazyPreferenceGetter(
SidebarUI,
SidebarController,
"_positionStart",
SidebarUI.POSITION_START_PREF,
SidebarController.POSITION_START_PREF,
true,
SidebarUI.setPosition.bind(SidebarUI)
SidebarController.setPosition.bind(SidebarController)
);
XPCOMUtils.defineLazyPreferenceGetter(
SidebarUI,
SidebarController,
"sidebarRevampEnabled",
"sidebar.revamp",
false

Просмотреть файл

@ -4,8 +4,8 @@
browser.jar:
content/browser/sidebar/browser-sidebar.js
content/browser/sidebar/sidebar-launcher.css
content/browser/sidebar/sidebar-launcher.mjs
content/browser/sidebar/sidebar-main.css
content/browser/sidebar/sidebar-main.mjs
content/browser/sidebar/sidebar-history.html
content/browser/sidebar/sidebar-history.mjs
content/browser/sidebar/sidebar-page.mjs

Просмотреть файл

@ -13,11 +13,10 @@ import { MozLitElement } from "chrome://global/content/lit-utils.mjs";
import "chrome://global/content/elements/moz-button.mjs";
/**
* Vertical strip attached to the launcher that provides an entry point
* to various sidebar panels.
*
* Sidebar with expanded and collapsed states that provides entry points
* to various sidebar panels and sidebar extensions.
*/
export default class SidebarLauncher extends MozLitElement {
export default class SidebarMain extends MozLitElement {
static properties = {
topActions: { type: Array },
extensionActions: { type: Array },
@ -36,7 +35,7 @@ export default class SidebarLauncher extends MozLitElement {
{
icon: `url("chrome://browser/skin/insights.svg")`,
view: null,
l10nId: "sidebar-launcher-insights",
l10nId: "sidebar-main-insights",
},
];
this.extensionActions = [];
@ -58,8 +57,8 @@ export default class SidebarLauncher extends MozLitElement {
},
];
this.selectedView = window.SidebarUI.currentID;
this.open = window.SidebarUI.isOpen;
this.selectedView = window.SidebarController.currentID;
this.open = window.SidebarController.isOpen;
}
connectedCallback() {
@ -106,7 +105,7 @@ export default class SidebarLauncher extends MozLitElement {
}
setExtensionItems() {
this.extensionActions = window.SidebarUI.getExtensions().map(
this.extensionActions = window.SidebarController.getExtensions().map(
({ commandID, icon, label }) => ({
tooltiptext: label,
icon,
@ -134,7 +133,7 @@ export default class SidebarLauncher extends MozLitElement {
showView(e) {
let view = e.target.getAttribute("view");
window.SidebarUI.toggle(view);
window.SidebarController.toggle(view);
}
buttonType(action) {
@ -160,7 +159,7 @@ export default class SidebarLauncher extends MozLitElement {
return html`
<link
rel="stylesheet"
href="chrome://browser/content/sidebar/sidebar-launcher.css"
href="chrome://browser/content/sidebar/sidebar-main.css"
/>
<div class="wrapper">
<div class="top-actions actions-list">
@ -178,4 +177,4 @@ export default class SidebarLauncher extends MozLitElement {
`;
}
}
customElements.define("sidebar-launcher", SidebarLauncher);
customElements.define("sidebar-main", SidebarMain);

Просмотреть файл

@ -2,7 +2,7 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
sidebar-launcher-insights =
sidebar-main-insights =
.title = Insights
## Variables:

Просмотреть файл

@ -83,7 +83,7 @@ add_task(async function test_extension_sidebar_actions() {
// await one "sidebar" message.
const win = await BrowserTestUtils.openNewBrowserWindow();
const { document } = win;
const sidebar = document.getElementById("sidebar-launcher");
const sidebar = document.getElementById("sidebar-main");
ok(sidebar, "Sidebar is shown.");
const extension = ExtensionTestUtils.loadExtension({ ...extData });
@ -121,7 +121,7 @@ add_task(async function test_extension_sidebar_actions() {
await sendMessage(extension, "set-panel", "1.html");
const panelUrl = `moz-extension://${extension.uuid}/1.html`;
await TestUtils.waitForCondition(() => {
const browser = SidebarUI.browser.contentDocument.getElementById(
const browser = SidebarController.browser.contentDocument.getElementById(
"webext-panels-browser"
);
return browser.currentURI.spec === panelUrl;
@ -144,7 +144,7 @@ add_task(async function test_open_new_window_after_install() {
const win = await BrowserTestUtils.openNewBrowserWindow();
const { document } = win;
const sidebar = document.getElementById("sidebar-launcher");
const sidebar = document.getElementById("sidebar-main");
ok(sidebar, "Sidebar is shown.");
await extension.awaitMessage("sidebar");
is(
@ -172,7 +172,7 @@ add_task(async function test_open_new_private_window_after_install() {
private: true,
});
const { document } = privateWin;
const sidebar = document.getElementById("sidebar-launcher");
const sidebar = document.getElementById("sidebar-main");
ok(sidebar, "Sidebar is shown.");
await TestUtils.waitForCondition(
() => sidebar.extensionButtons,

Просмотреть файл

@ -91,28 +91,28 @@ function setupSyncedTabsStubs({
async function testClean() {
sinon.restore();
await new Promise(resolve => {
window.SidebarUI.browser.contentWindow.addEventListener(
window.SidebarController.browser.contentWindow.addEventListener(
"unload",
function () {
resolve();
},
{ once: true }
);
SidebarUI.hide();
SidebarController.hide();
});
}
add_task(async function testSyncedTabsSidebarList() {
await SidebarUI.show("viewTabsSidebar");
await SidebarController.show("viewTabsSidebar");
Assert.equal(
SidebarUI.currentID,
SidebarController.currentID,
"viewTabsSidebar",
"Sidebar should have SyncedTabs loaded"
);
let syncedTabsDeckComponent =
SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
SidebarController.browser.contentWindow.syncedTabsDeckComponent;
Assert.ok(syncedTabsDeckComponent, "component exists");
@ -172,9 +172,9 @@ add_task(async function testSyncedTabsSidebarList() {
add_task(testClean);
add_task(async function testSyncedTabsSidebarFilteredList() {
await SidebarUI.show("viewTabsSidebar");
await SidebarController.show("viewTabsSidebar");
let syncedTabsDeckComponent =
window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
window.SidebarController.browser.contentWindow.syncedTabsDeckComponent;
Assert.ok(syncedTabsDeckComponent, "component exists");
@ -244,9 +244,9 @@ add_task(async function testSyncedTabsSidebarFilteredList() {
add_task(testClean);
add_task(async function testSyncedTabsSidebarStatus() {
await SidebarUI.show("viewTabsSidebar");
await SidebarController.show("viewTabsSidebar");
let syncedTabsDeckComponent =
window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
window.SidebarController.browser.contentWindow.syncedTabsDeckComponent;
Assert.ok(syncedTabsDeckComponent, "component exists");
@ -377,9 +377,9 @@ add_task(async function testSyncedTabsSidebarStatus() {
add_task(testClean);
add_task(async function testSyncedTabsSidebarContextMenu() {
await SidebarUI.show("viewTabsSidebar");
await SidebarController.show("viewTabsSidebar");
let syncedTabsDeckComponent =
window.SidebarUI.browser.contentWindow.syncedTabsDeckComponent;
window.SidebarController.browser.contentWindow.syncedTabsDeckComponent;
Assert.ok(syncedTabsDeckComponent, "component exists");
@ -547,7 +547,8 @@ async function testContextMenu(
let chromeWindow = triggerElement.ownerGlobal.top;
let rect = triggerElement.getBoundingClientRect();
let contentRect = chromeWindow.SidebarUI.browser.getBoundingClientRect();
let contentRect =
chromeWindow.SidebarController.browser.getBoundingClientRect();
// The offsets in `rect` are relative to the content window, but
// `synthesizeMouseAtPoint` calls `nsIDOMWindowUtils.sendMouseEvent`,
// which interprets the offsets relative to the containing *chrome* window.

Просмотреть файл

@ -134,7 +134,7 @@ var gBuiltInInputs = {
type: kInputTypes.BUTTON,
callback: () => {
let win = lazy.BrowserWindowTracker.getTopWindow();
win.SidebarUI.toggle();
win.SidebarController.toggle();
},
},
AddBookmark: {

Просмотреть файл

@ -706,7 +706,7 @@ add_task(async function webextension() {
// Clear the last opened ID so if this test runs again the sidebar won't
// automatically open when the extension is installed.
window.SidebarUI.lastOpenedId = null;
window.SidebarController.lastOpenedId = null;
// The second should retain its ID.
click("random_addon2_example_com-browser-action");

Просмотреть файл

@ -103,12 +103,12 @@ add_task(async function () {
// Tests focusing the sidebar, which is in a parent process subframe
// and then switching the focus to another window.
add_task(async function () {
await SidebarUI.show("viewBookmarksSidebar");
await SidebarController.show("viewBookmarksSidebar");
gURLBar.focus();
// Focus the sidebar.
await SimpleTest.promiseFocus(SidebarUI.browser);
await SimpleTest.promiseFocus(SidebarController.browser);
is(
document.activeElement,
document.getElementById("sidebar"),
@ -120,7 +120,7 @@ add_task(async function () {
);
// Focus the sidebar again, which should cause no change.
await SimpleTest.promiseFocus(SidebarUI.browser);
await SimpleTest.promiseFocus(SidebarController.browser);
is(
document.activeElement,
document.getElementById("sidebar"),
@ -156,5 +156,5 @@ add_task(async function () {
);
await BrowserTestUtils.closeWindow(window2);
await SidebarUI.hide();
await SidebarController.hide();
});

Просмотреть файл

@ -449,7 +449,7 @@ export class ExtensionShortcuts {
}
doc.documentElement.appendChild(keyset);
if (sidebarKey) {
window.SidebarUI.updateShortcut({ keyId: sidebarKey.id });
window.SidebarController.updateShortcut({ keyId: sidebarKey.id });
}
this.keysetsMap.set(window, keyset);
}

Просмотреть файл

@ -139,7 +139,9 @@ add_task(async function test_getcurrent_privateBrowsing() {
"resource://gre/modules/ExtensionCommon.sys.mjs"
);
const { makeWidgetId } = ExtensionCommon;
privateWin.SidebarUI.show(`${makeWidgetId(extension.id)}-sidebar-action`);
privateWin.SidebarController.show(
`${makeWidgetId(extension.id)}-sidebar-action`
);
let imageLoaded = extension.awaitMessage("theme-image");
Assert.deepEqual(await imageLoaded, { success: true }, "theme image loaded");

Просмотреть файл

@ -17,7 +17,7 @@ async function test_sidebar_theme(theme, isBrightText) {
const sidebarBox = document.getElementById("sidebar-box");
const browserRoot = document.documentElement;
const content = SidebarUI.browser.contentWindow;
const content = SidebarController.browser.contentWindow;
const root = content.document.documentElement;
ok(
@ -184,7 +184,7 @@ add_task(async function test_support_sidebar_colors() {
for (let command of ["viewBookmarksSidebar", "viewHistorySidebar"]) {
info("Executing command: " + command);
await SidebarUI.show(command);
await SidebarController.show(command);
await test_sidebar_theme(
{
@ -263,7 +263,7 @@ add_task(async function test_support_sidebar_border_color() {
"Sidebar splitter should be colored properly"
);
SidebarUI.reversePosition();
SidebarController.reversePosition();
is(
sidebarSplitterCS.borderInlineStartColor,
@ -271,7 +271,7 @@ add_task(async function test_support_sidebar_border_color() {
"Sidebar splitter should be colored properly after switching sides"
);
SidebarUI.reversePosition();
SidebarController.reversePosition();
}
await extension.unload();

Просмотреть файл

@ -12,7 +12,7 @@ add_task(async function test_search_input_popupshowing() {
let sidebar = document.getElementById("sidebar");
let loadPromise = BrowserTestUtils.waitForEvent(sidebar, "load", true);
SidebarUI.toggle("viewBookmarksSidebar");
SidebarController.toggle("viewBookmarksSidebar");
await loadPromise;
let inputField =
@ -45,5 +45,5 @@ add_task(async function test_search_input_popupshowing() {
popup.hidePopup();
await popuphidden;
SidebarUI.toggle("viewBookmarksSidebar");
SidebarController.toggle("viewBookmarksSidebar");
});