From f20132edb0b7d6a3517497caaa0cb6202d5483c4 Mon Sep 17 00:00:00 2001 From: wuggy Date: Sat, 19 Sep 2026 04:21:19 -0700 Subject: [PATCH] Fix browser console errors --- browser/base/content/browser-places.js | 4 ++-- browser/base/content/tab-content.js | 8 ++++++-- .../components/internaluserscripts.js | 14 +++++++++++--- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js index 9e472ad6e4..e2408aaf8f 100644 --- a/browser/base/content/browser-places.js +++ b/browser/base/content/browser-places.js @@ -1731,14 +1731,14 @@ var BookmarkingUI = { if (this._itemIds.length > 0) { this.broadcaster.setAttribute("starred", "true"); this.broadcaster.setAttribute("buttontooltiptext", this._starredTooltip); - if (this.button.getAttribute("overflowedItem") == "true") { + if (this.button && this.button.getAttribute("overflowedItem") == "true") { this.button.setAttribute("label", this._starButtonOverflowedStarredLabel); } } else { this.broadcaster.removeAttribute("starred"); this.broadcaster.setAttribute("buttontooltiptext", this._unstarredTooltip); - if (this.button.getAttribute("overflowedItem") == "true") { + if (this.button && this.button.getAttribute("overflowedItem") == "true") { this.button.setAttribute("label", this._starButtonOverflowedLabel); } } diff --git a/browser/base/content/tab-content.js b/browser/base/content/tab-content.js index fd4612cc4d..a7b62d753c 100644 --- a/browser/base/content/tab-content.js +++ b/browser/base/content/tab-content.js @@ -133,8 +133,12 @@ var AboutHomeListener = { onUpdate: function(aData) { let doc = content.document; - if (aData.showRestoreLastSession && !PrivateBrowsingUtils.isContentWindowPrivate(content)) - doc.getElementById("launcher").setAttribute("session", "true"); + if (aData.showRestoreLastSession && !PrivateBrowsingUtils.isContentWindowPrivate(content)) { + let launcher = doc.getElementById("launcher"); + if (launcher) { + launcher.setAttribute("session", "true"); + } + } // Inject search engine URL. let docElt = doc.documentElement; diff --git a/browser/internaluserscripts/components/internaluserscripts.js b/browser/internaluserscripts/components/internaluserscripts.js index 8876acaac7..7469ed2e26 100644 --- a/browser/internaluserscripts/components/internaluserscripts.js +++ b/browser/internaluserscripts/components/internaluserscripts.js @@ -106,9 +106,17 @@ InternalUserscriptsService.prototype = { // The codec shim is deliberately limited to YouTube. Use the browser's // decoder probe rather than guessing from the user's graphics settings. - if (documentURI && - documentURI.host && - /(^|\.)youtube(?:-nocookie)?\.com$/i.test(documentURI.host)) { + let documentHost = null; + try { + // nsIURI.host is not implemented by hostless URI schemes (about:, data:, + // moz-extension:, and others), so reading it can throw. + if (documentURI) { + documentHost = documentURI.host; + } + } catch (e) {} + + if (documentHost && + /(^|\.)youtube(?:-nocookie)?\.com$/i.test(documentHost)) { let settings = { hideUnaccelerated: Services.prefs.getBoolPref( "browser.video.youtube.hide-unaccelerated", true),