Bug 1386197 - Show/Hide recently bookmarked menuitems don't exist in the Library window on Mac, handle the case so to avoid exceptions stopping listeners being removed. r=mak
authorMark Banner <standard8@mozilla.com>
Tue, 01 Aug 2017 11:59:41 +0100
changeset 420898 2ca9999610542d892390ed7da7d28e0c30ec2867
parent 420897 b6a01f3ac7046300a8cdd4bab80417e0d1e85b7d
child 420899 65d1f1440a9fd3006e2c94a811986d3df84b257d
child 421732 a41c7f4f768e10f41f205ae4d431a4da14d796ef
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1386197
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1386197 - Show/Hide recently bookmarked menuitems don't exist in the Library window on Mac, handle the case so to avoid exceptions stopping listeners being removed. r=mak MozReview-Commit-ID: 6zcw2Q7vRYI
browser/base/content/browser-places.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1504,20 +1504,24 @@ var BookmarkingUI = {
     this._recentlyBookmarkedObserver.onItemRemoved = () => {
       // Update the menu when a bookmark has been removed.
       // The native menubar on Mac doesn't support live update, so this won't
       // work there.
       this._populateRecentBookmarks(aHeaderItem, aExtraCSSClass);
     };
 
     let updatePlacesContextMenu = (shouldHidePrefUI = false) => {
-      let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
       let showItem = document.getElementById("placesContext_showRecentlyBookmarked");
+      // On Mac the menuitem doesn't exist when we're in the Library window context.
+      if (!showItem) {
+        return;
+      }
       let hideItem = document.getElementById("placesContext_hideRecentlyBookmarked");
       let separator = document.getElementById("placesContext_recentlyBookmarkedSeparator");
+      let prefEnabled = !shouldHidePrefUI && Services.prefs.getBoolPref(this.RECENTLY_BOOKMARKED_PREF);
       showItem.hidden = shouldHidePrefUI || prefEnabled;
       hideItem.hidden = shouldHidePrefUI || !prefEnabled;
       separator.hidden = shouldHidePrefUI;
       if (!shouldHidePrefUI) {
         // Move to the bottom of the menu.
         separator.parentNode.appendChild(separator);
         showItem.parentNode.appendChild(showItem);
         hideItem.parentNode.appendChild(hideItem);