[Basilisk] Follow-up: Throw errors on invalid values.

Backport of MoonchildProductions/Pale-Moon commit f953abe13c
This commit is contained in:
Basilisk-Dev 2023-07-11 18:06:30 -04:00 committed by roytam1
commit 803bde2387

View file

@ -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.