From 11d65297503eb044a8a8567dbde4bfc18b147839 Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Tue, 11 Jul 2023 18:01:33 -0400 Subject: [PATCH 1/4] [Basilisk] Add pref to control history menu length. Backport of MoonchildProductions/Pale-Moon commit d7581957ff --- application/basilisk/base/content/browser-places.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/application/basilisk/base/content/browser-places.js b/application/basilisk/base/content/browser-places.js index a7f33b10c1..474053510c 100644 --- a/application/basilisk/base/content/browser-places.js +++ b/application/basilisk/base/content/browser-places.js @@ -717,9 +717,13 @@ function HistoryMenu(aPopupShowingEvent) { // Defining the prototype inheritance in the prototype itself would cause // browser.js to halt on "PlacesMenu is not defined" error. this.__proto__.__proto__ = PlacesMenu.prototype; + let maxResults = Services.prefs.getIntPref("browser.history.menuMaxResults",15); + if (maxResults < 1 || maxResults > 50) { + // Return to sanity... + maxResults = 15; + } PlacesMenu.call(this, aPopupShowingEvent, - "place:sort=4&maxResults=15"); -} + "place:sort=4&maxResults=" + maxResults.toString().trim()); } HistoryMenu.prototype = { _getClosedTabCount() { From ab1a1e893f9b7f29e59d74138cf9024ee3105c46 Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Tue, 11 Jul 2023 18:03:04 -0400 Subject: [PATCH 2/4] [Basilisk] Follow-up: Don't show link items when pref is less than 1. Backport of MoonchildProductions/Pale-Moon commit 1e7f19afdf --- .../basilisk/base/content/browser-places.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/application/basilisk/base/content/browser-places.js b/application/basilisk/base/content/browser-places.js index 474053510c..e6ad83deff 100644 --- a/application/basilisk/base/content/browser-places.js +++ b/application/basilisk/base/content/browser-places.js @@ -717,13 +717,15 @@ function HistoryMenu(aPopupShowingEvent) { // Defining the prototype inheritance in the prototype itself would cause // browser.js to halt on "PlacesMenu is not defined" error. this.__proto__.__proto__ = PlacesMenu.prototype; - let maxResults = Services.prefs.getIntPref("browser.history.menuMaxResults",15); - if (maxResults < 1 || maxResults > 50) { - // Return to sanity... - maxResults = 15; - } - PlacesMenu.call(this, aPopupShowingEvent, - "place:sort=4&maxResults=" + maxResults.toString().trim()); } + let maxResults = Services.prefs.getIntPref("browser.history.menuMaxResults", 15); + // Workaround so that maxResults = 0 wouldn't create unlimited items + if (maxResults > 0) { + if (maxResults > 50) { + // Return to sanity... + maxResults = 15; + } + PlacesMenu.call(this, aPopupShowingEvent, + "place:sort=4&maxResults=" + maxResults.toString().trim()); HistoryMenu.prototype = { _getClosedTabCount() { From 803bde238700d1b55fa412eb86b6cef6637c0ee0 Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Tue, 11 Jul 2023 18:06:30 -0400 Subject: [PATCH 3/4] [Basilisk] Follow-up: Throw errors on invalid values. Backport of MoonchildProductions/Pale-Moon commit f953abe13c --- application/basilisk/base/content/browser-places.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/application/basilisk/base/content/browser-places.js b/application/basilisk/base/content/browser-places.js index e6ad83deff..3ceb635a8b 100644 --- a/application/basilisk/base/content/browser-places.js +++ b/application/basilisk/base/content/browser-places.js @@ -718,15 +718,21 @@ function HistoryMenu(aPopupShowingEvent) { // browser.js to halt on "PlacesMenu is not defined" error. this.__proto__.__proto__ = PlacesMenu.prototype; let maxResults = Services.prefs.getIntPref("browser.history.menuMaxResults", 15); - // Workaround so that maxResults = 0 wouldn't create unlimited items + if (maxResults < 0) { + Components.utils.reportError("Maximum number of history menu entries is invalid! Using defaults."); + maxResults = 15; + } if (maxResults > 0) { if (maxResults > 50) { // Return to sanity... - maxResults = 15; + Components.utils.reportError("Maximum number of history menu entries is too large! Capping to 50."); + maxResults = 50; } PlacesMenu.call(this, aPopupShowingEvent, "place:sort=4&maxResults=" + maxResults.toString().trim()); - + } else { + // maxResults == 0; do nothing. This suppresses the history entries. + } HistoryMenu.prototype = { _getClosedTabCount() { // SessionStore doesn't track the hidden window, so just return zero then. From 748cac6e807ddb71a61da8ffac89b5146f88730c Mon Sep 17 00:00:00 2001 From: Basilisk-Dev Date: Tue, 11 Jul 2023 18:11:00 -0400 Subject: [PATCH 4/4] [Basilisk] Front-end fixes Partial backport of MoonchildProductions/Pale-Moon commit 84c814f55c --- application/basilisk/base/content/browser-places.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/application/basilisk/base/content/browser-places.js b/application/basilisk/base/content/browser-places.js index 3ceb635a8b..a330b00399 100644 --- a/application/basilisk/base/content/browser-places.js +++ b/application/basilisk/base/content/browser-places.js @@ -642,8 +642,9 @@ var PlacesCommandHook = { updateBookmarkAllTabsCommand: function PCH_updateBookmarkAllTabsCommand() { // There's nothing to do in non-browser windows. - if (window.location.href != getBrowserURL()) + if (!window.location || window.location.href != getBrowserURL()) { return; + } // Disable "Bookmark All Tabs" if there are less than two // "unique current pages".