summaryrefslogtreecommitdiffstats
path: root/browser/components/customizableui
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:35:29 +0000
commit59203c63bb777a3bacec32fb8830fba33540e809 (patch)
tree58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/customizableui
parentAdding upstream version 126.0.1. (diff)
downloadfirefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz
firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/customizableui')
-rw-r--r--browser/components/customizableui/CustomizableWidgets.sys.mjs70
-rw-r--r--browser/components/customizableui/CustomizeMode.sys.mjs2
-rw-r--r--browser/components/customizableui/content/panelUI.inc.xhtml4
-rw-r--r--browser/components/customizableui/content/panelUI.js82
-rw-r--r--browser/components/customizableui/test/browser_PanelMultiView_keyboard.js1
-rw-r--r--browser/components/customizableui/test/browser_ctrl_click_panel_opening.js4
-rw-r--r--browser/components/customizableui/test/browser_panelUINotifications_bannerVisibility.js6
-rw-r--r--browser/components/customizableui/test/browser_sidebar_toggle.js22
-rw-r--r--browser/components/customizableui/test/browser_synced_tabs_menu.js51
9 files changed, 204 insertions, 38 deletions
diff --git a/browser/components/customizableui/CustomizableWidgets.sys.mjs b/browser/components/customizableui/CustomizableWidgets.sys.mjs
index 1f37af7963..09b57be4c9 100644
--- a/browser/components/customizableui/CustomizableWidgets.sys.mjs
+++ b/browser/components/customizableui/CustomizableWidgets.sys.mjs
@@ -99,6 +99,21 @@ export const CustomizableWidgets = [
case "unload":
this.onWindowUnload(event);
break;
+ case "command": {
+ let { target } = event;
+ let { PanelUI, PlacesCommandHook } = target.ownerGlobal;
+ if (target.id == "appMenuRecentlyClosedTabs") {
+ PanelUI.showSubView(this.recentlyClosedTabsPanel, target);
+ } else if (target.id == "appMenuRecentlyClosedWindows") {
+ PanelUI.showSubView(this.recentlyClosedWindowsPanel, target);
+ } else if (target.id == "appMenuSearchHistory") {
+ PlacesCommandHook.searchHistory();
+ } else if (target.id == "PanelUI-historyMore") {
+ PlacesCommandHook.showPlacesOrganizer("History");
+ lazy.CustomizableUI.hidePanelForNode(target);
+ }
+ break;
+ }
default:
throw new Error(`Unsupported event for '${this.id}'`);
}
@@ -153,6 +168,7 @@ export const CustomizableWidgets = [
// When the popup is hidden (thus the panelmultiview node as well), make
// sure to stop listening to PlacesDatabase updates.
panelview.panelMultiView.addEventListener("PanelMultiViewHidden", this);
+ panelview.addEventListener("command", this);
window.addEventListener("unload", this);
},
onViewHiding() {
@@ -172,6 +188,10 @@ export const CustomizableWidgets = [
document,
this.recentlyClosedWindowsPanel
).removeEventListener("ViewShowing", this);
+ lazy.PanelMultiView.getViewNode(
+ document,
+ this.viewId
+ ).removeEventListener("command", this);
}
panelMultiView.removeEventListener("PanelMultiViewHidden", this);
},
@@ -260,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
@@ -419,7 +439,7 @@ export const CustomizableWidgets = [
id: "characterencoding-button",
l10nId: "repair-text-encoding-button",
onCommand(aEvent) {
- aEvent.view.BrowserForceEncodingDetection();
+ aEvent.view.BrowserCommands.forceEncodingDetection();
},
},
{
@@ -464,10 +484,52 @@ if (Services.prefs.getBoolPref("identity.fxaccounts.enabled")) {
lazy.PanelMultiView.getViewNode(doc, "PanelUI-remotetabs-deck"),
lazy.PanelMultiView.getViewNode(doc, "PanelUI-remotetabs-tabslist")
);
+ panelview.addEventListener("command", this);
+ let syncNowButton = lazy.PanelMultiView.getViewNode(
+ aEvent.target.ownerDocument,
+ "PanelUI-remotetabs-syncnow"
+ );
+ syncNowButton.addEventListener("mouseover", this);
},
onViewHiding(aEvent) {
- aEvent.target.syncedTabsPanelList.destroy();
- aEvent.target.syncedTabsPanelList = null;
+ let panelview = aEvent.target;
+ panelview.syncedTabsPanelList.destroy();
+ panelview.syncedTabsPanelList = null;
+ panelview.removeEventListener("command", this);
+ let syncNowButton = lazy.PanelMultiView.getViewNode(
+ aEvent.target.ownerDocument,
+ "PanelUI-remotetabs-syncnow"
+ );
+ syncNowButton.removeEventListener("mouseover", this);
+ },
+ handleEvent(aEvent) {
+ let button = aEvent.target;
+ let { gSync } = button.ownerGlobal;
+ switch (aEvent.type) {
+ case "mouseover":
+ gSync.refreshSyncButtonsTooltip();
+ break;
+ case "command": {
+ switch (button.id) {
+ case "PanelUI-remotetabs-syncnow":
+ gSync.doSync();
+ break;
+ case "PanelUI-remotetabs-view-managedevices":
+ gSync.openDevicesManagementPage("syncedtabs-menupanel");
+ break;
+ case "PanelUI-remotetabs-tabsdisabledpane-button":
+ case "PanelUI-remotetabs-setupsync-button":
+ case "PanelUI-remotetabs-syncdisabled-button":
+ case "PanelUI-remotetabs-reauthsync-button":
+ case "PanelUI-remotetabs-unverified-button":
+ gSync.openPrefs("synced-tabs");
+ break;
+ case "PanelUI-remotetabs-connect-device-button":
+ gSync.openConnectAnotherDevice("synced-tabs");
+ break;
+ }
+ }
+ }
},
});
}
diff --git a/browser/components/customizableui/CustomizeMode.sys.mjs b/browser/components/customizableui/CustomizeMode.sys.mjs
index 7b4ee373be..41f347130e 100644
--- a/browser/components/customizableui/CustomizeMode.sys.mjs
+++ b/browser/components/customizableui/CustomizeMode.sys.mjs
@@ -1376,7 +1376,7 @@ CustomizeMode.prototype = {
},
openAddonsManagerThemes() {
- this.window.BrowserOpenAddonsMgr("addons://list/theme");
+ this.window.BrowserAddonUI.openAddonsMgr("addons://list/theme");
},
getMoreThemes(aEvent) {
diff --git a/browser/components/customizableui/content/panelUI.inc.xhtml b/browser/components/customizableui/content/panelUI.inc.xhtml
index 956a6ae45d..7607f59ec4 100644
--- a/browser/components/customizableui/content/panelUI.inc.xhtml
+++ b/browser/components/customizableui/content/panelUI.inc.xhtml
@@ -107,7 +107,7 @@
<toolbarbutton id="unified-extensions-manage-extensions"
class="subviewbutton panel-subview-footer-button unified-extensions-manage-extensions"
data-l10n-id="unified-extensions-manage-extensions"
- oncommand="BrowserOpenAddonsMgr('addons://list/extension');" />
+ oncommand="BrowserAddonUI.openAddonsMgr('addons://list/extension');" />
</panelview>
</panelmultiview>
</panel>
@@ -271,7 +271,7 @@
flip="slide"
position="bottomright topright"
noautofocus="true">
- <panelmultiview id="appMenu-multiView" mainViewId="appMenu-protonMainView"
+ <panelmultiview id="appMenu-multiView" mainViewId="appMenu-mainView"
viewCacheId="appMenu-viewCache">
</panelmultiview>
</panel>
diff --git a/browser/components/customizableui/content/panelUI.js b/browser/components/customizableui/content/panelUI.js
index cb32085fd7..cbd27e465e 100644
--- a/browser/components/customizableui/content/panelUI.js
+++ b/browser/components/customizableui/content/panelUI.js
@@ -128,10 +128,16 @@ const PanelUI = {
this.panel.addEventListener(event, this);
}
+ this._onLibraryCommand = this._onLibraryCommand.bind(this);
PanelMultiView.getViewNode(document, "PanelUI-helpView").addEventListener(
"ViewShowing",
this._onHelpViewShow
);
+ PanelMultiView.getViewNode(
+ document,
+ "appMenu-libraryView"
+ ).addEventListener("command", this._onLibraryCommand);
+ this.mainView.addEventListener("command", this);
this._eventListenersAdded = true;
},
@@ -143,6 +149,11 @@ const PanelUI = {
document,
"PanelUI-helpView"
).removeEventListener("ViewShowing", this._onHelpViewShow);
+ PanelMultiView.getViewNode(
+ document,
+ "appMenu-libraryView"
+ ).removeEventListener("command", this._onLibraryCommand);
+ this.mainView.removeEventListener("command", this);
this._eventListenersAdded = false;
},
@@ -299,6 +310,54 @@ const PanelUI = {
case "activate":
this.updateNotifications();
break;
+ case "command":
+ this.onCommand(aEvent);
+ break;
+ }
+ },
+
+ // Note that we listen for bubbling command events. In the case where the
+ // button that the user clicks has a command attribute, those events are
+ // redirected to the relevant command element, and we never see them in
+ // here. Bear this in mind if you want to write code that applies to
+ // all commands, for which this wouldn't work well.
+ onCommand(aEvent) {
+ let { target } = aEvent;
+ switch (target.id) {
+ case "appMenu-update-banner":
+ this._onBannerItemSelected(aEvent);
+ break;
+ case "appMenu-fxa-label2":
+ gSync.toggleAccountPanel(target, aEvent);
+ break;
+ case "appMenu-profiles-button":
+ gProfiles.updateView(target);
+ break;
+ case "appMenu-bookmarks-button":
+ BookmarkingUI.showSubView(target);
+ break;
+ case "appMenu-history-button":
+ this.showSubView("PanelUI-history", target);
+ break;
+ case "appMenu-passwords-button":
+ LoginHelper.openPasswordManager(window, { entryPoint: "mainmenu" });
+ break;
+ case "appMenu-fullscreen-button2":
+ // Note that we're custom-handling the hiding of the panel to make
+ // sure it disappears before entering fullscreen. Otherwise it can
+ // end up moving around on the screen during the fullscreen transition.
+ target.closest("panel").hidePopup();
+ setTimeout(() => BrowserCommands.fullScreen(), 0);
+ break;
+ case "appMenu-settings-button":
+ openPreferences();
+ break;
+ case "appMenu-more-button2":
+ this.showMoreToolsPanel(target);
+ break;
+ case "appMenu-help-button2":
+ this.showSubView("PanelUI-helpView", target);
+ break;
}
},
@@ -632,6 +691,22 @@ const PanelUI = {
items.appendChild(fragment);
},
+ _onLibraryCommand(aEvent) {
+ let button = aEvent.target;
+ let { BookmarkingUI, DownloadsPanel } = button.ownerGlobal;
+ switch (button.id) {
+ case "appMenu-library-bookmarks-button":
+ BookmarkingUI.showSubView(button);
+ break;
+ case "appMenu-library-history-button":
+ this.showSubView("PanelUI-history", button);
+ break;
+ case "appMenu-library-downloads-button":
+ DownloadsPanel.showDownloadsHistory();
+ break;
+ }
+ },
+
_hidePopup() {
if (!this._notificationPanel) {
return;
@@ -840,10 +915,7 @@ const PanelUI = {
get mainView() {
if (!this._mainView) {
- this._mainView = PanelMultiView.getViewNode(
- document,
- "appMenu-protonMainView"
- );
+ this._mainView = PanelMultiView.getViewNode(document, "appMenu-mainView");
}
return this._mainView;
},
@@ -852,7 +924,7 @@ const PanelUI = {
if (!this._addonNotificationContainer) {
this._addonNotificationContainer = PanelMultiView.getViewNode(
document,
- "appMenu-proton-addon-banners"
+ "appMenu-addon-banners"
);
}
diff --git a/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js b/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
index b41fc2ef23..d8c687d88a 100644
--- a/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
+++ b/browser/components/customizableui/test/browser_PanelMultiView_keyboard.js
@@ -150,7 +150,6 @@ add_setup(async function () {
gLink.innerText = "gLink";
gLink.id = "gLink";
gMainView.appendChild(gLink);
- await window.ensureCustomElements("moz-toggle");
gToggle = document.createElement("moz-toggle");
gToggle.label = "Test label";
gMainView.appendChild(gToggle);
diff --git a/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js b/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
index 9377c28950..92528f2537 100644
--- a/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
+++ b/browser/components/customizableui/test/browser_ctrl_click_panel_opening.js
@@ -13,8 +13,8 @@ add_task(async function test_appMenu_mainView() {
return;
}
- let mainViewID = "appMenu-protonMainView";
- const mainView = document.getElementById(mainViewID);
+ let mainViewID = "appMenu-mainView";
+ const mainView = PanelMultiView.getViewNode(document, mainViewID);
let shownPromise = BrowserTestUtils.waitForEvent(mainView, "ViewShown");
// Should still open the panel when Ctrl key is pressed.
diff --git a/browser/components/customizableui/test/browser_panelUINotifications_bannerVisibility.js b/browser/components/customizableui/test/browser_panelUINotifications_bannerVisibility.js
index df856dd4cf..686d600601 100644
--- a/browser/components/customizableui/test/browser_panelUINotifications_bannerVisibility.js
+++ b/browser/components/customizableui/test/browser_panelUINotifications_bannerVisibility.js
@@ -24,7 +24,7 @@ add_task(async function testBannerVisibilityBeforeOpen() {
menuButton.click();
await shown;
- let banner = newWin.document.getElementById("appMenu-proton-update-banner");
+ let banner = newWin.document.getElementById("appMenu-update-banner");
let labelPromise = BrowserTestUtils.waitForMutationCondition(
banner,
@@ -62,7 +62,7 @@ add_task(async function testBannerVisibilityDuringOpen() {
menuButton.click();
await shown;
- let banner = newWin.document.getElementById("appMenu-proton-update-banner");
+ let banner = newWin.document.getElementById("appMenu-update-banner");
ok(
!banner.hasAttribute("label"),
"Update banner shouldn't contain text before notification"
@@ -109,7 +109,7 @@ add_task(async function testBannerVisibilityAfterClose() {
ok(newWin.PanelUI.mainView.hasAttribute("visible"));
- let banner = newWin.document.getElementById("appMenu-proton-update-banner");
+ let banner = newWin.document.getElementById("appMenu-update-banner");
ok(banner.hidden, "Update banner should be hidden before notification");
ok(
diff --git a/browser/components/customizableui/test/browser_sidebar_toggle.js b/browser/components/customizableui/test/browser_sidebar_toggle.js
index 5742f368ee..a063cc26cf 100644
--- a/browser/components/customizableui/test/browser_sidebar_toggle.js
+++ b/browser/components/customizableui/test/browser_sidebar_toggle.js
@@ -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"
);
diff --git a/browser/components/customizableui/test/browser_synced_tabs_menu.js b/browser/components/customizableui/test/browser_synced_tabs_menu.js
index 33c8f6a845..c99223a80e 100644
--- a/browser/components/customizableui/test/browser_synced_tabs_menu.js
+++ b/browser/components/customizableui/test/browser_synced_tabs_menu.js
@@ -216,6 +216,17 @@ add_task(async function () {
ok(button, "found the button");
await document.getElementById("nav-bar").overflowable.show();
+ // Actually show the fxa view:
+ let shown = BrowserTestUtils.waitForEvent(
+ document.getElementById("PanelUI-remotetabs"),
+ "ViewShown"
+ );
+ PanelUI.showSubView(
+ "PanelUI-remotetabs",
+ document.getElementById("sync-button")
+ );
+ await shown;
+
let expectedUrl =
"https://example.com/connect_another_device?context=" +
"fx_desktop_v3&entrypoint=synced-tabs&service=sync&uid=uid&email=foo%40bar.com";
@@ -325,20 +336,28 @@ add_task(async function () {
node = node.firstElementChild;
is(node.getAttribute("itemtype"), "client", "node is a client entry");
is(node.textContent, "My Desktop", "correct client");
- // Next entry is the most-recent tab
+ // Next node is an hbox, that contains the tab and potentially
+ // a button for closing the tab remotely
node = node.nextElementSibling;
- is(node.getAttribute("itemtype"), "tab", "node is a tab");
- is(node.getAttribute("label"), "http://example.com/10");
+ is(node.nodeName, "hbox");
+ // Next entry is the most-recent tab
+ let childNode = node.firstElementChild;
+ is(childNode.getAttribute("itemtype"), "tab", "node is a tab");
+ is(childNode.getAttribute("label"), "http://example.com/10");
// Next entry is the next-most-recent tab
node = node.nextElementSibling;
- is(node.getAttribute("itemtype"), "tab", "node is a tab");
- is(node.getAttribute("label"), "http://example.com/5");
+ is(node.nodeName, "hbox");
+ childNode = node.firstElementChild;
+ is(childNode.getAttribute("itemtype"), "tab", "node is a tab");
+ is(childNode.getAttribute("label"), "http://example.com/5");
// Next entry is the least-recent tab from the first client.
node = node.nextElementSibling;
- is(node.getAttribute("itemtype"), "tab", "node is a tab");
- is(node.getAttribute("label"), "http://example.com/1");
+ is(node.nodeName, "hbox");
+ childNode = node.firstElementChild;
+ is(childNode.getAttribute("itemtype"), "tab", "node is a tab");
+ is(childNode.getAttribute("label"), "http://example.com/1");
node = node.nextElementSibling;
is(node, null, "no more siblings");
@@ -357,8 +376,10 @@ add_task(async function () {
is(node.textContent, "My Other Desktop", "correct client");
// Its single tab
node = node.nextElementSibling;
- is(node.getAttribute("itemtype"), "tab", "node is a tab");
- is(node.getAttribute("label"), "http://example.com/6");
+ is(node.nodeName, "hbox");
+ childNode = node.firstElementChild;
+ is(childNode.getAttribute("itemtype"), "tab", "node is a tab");
+ is(childNode.getAttribute("label"), "http://example.com/6");
node = node.nextElementSibling;
is(node, null, "no more siblings");
@@ -468,14 +489,16 @@ add_task(async function () {
is(node.textContent, "My Desktop", "correct client");
for (let i = 0; i < tabsShownCount; i++) {
node = node.nextElementSibling;
- is(node.getAttribute("itemtype"), "tab", "node is a tab");
+ is(node.nodeName, "hbox");
+ let childNode = node.firstElementChild;
+ is(childNode.getAttribute("itemtype"), "tab", "node is a tab");
is(
- node.getAttribute("label"),
+ childNode.getAttribute("label"),
"Tab #" + (i + 1),
"the tab is the correct one"
);
is(
- node.getAttribute("targetURI"),
+ childNode.getAttribute("targetURI"),
SAMPLE_TAB_URL,
"url is the correct one"
);
@@ -498,7 +521,9 @@ add_task(async function () {
async function checkCanOpenURL() {
let tabList = document.getElementById("PanelUI-remotetabs-tabslist");
- let node = tabList.firstElementChild.firstElementChild.nextElementSibling;
+ let node =
+ tabList.firstElementChild.firstElementChild.nextElementSibling
+ .firstElementChild;
let promiseTabOpened = BrowserTestUtils.waitForLocationChange(
gBrowser,
SAMPLE_TAB_URL