Bug 1289659 - Account for placesContext not existing in non-browser windows on Mac. r=mdeboer a=lizzard
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -1414,24 +1414,31 @@ var BookmarkingUI = {
let onBookmarksMenuHidden = event => {
if (event.target == event.currentTarget) {
updatePlacesContextMenu(true);
Services.prefs.removeObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
PlacesUtils.bookmarks.removeObserver(this._recentlyBookmarkedObserver);
this._recentlyBookmarkedObserver = null;
- placesContextMenu.removeEventListener("popupshowing", onPlacesContextMenuShowing);
+ if (placesContextMenu) {
+ placesContextMenu.removeEventListener("popupshowing", onPlacesContextMenuShowing);
+ }
bookmarksMenu.removeEventListener("popuphidden", onBookmarksMenuHidden);
}
};
Services.prefs.addObserver(this.RECENTLY_BOOKMARKED_PREF, prefObserver, false);
PlacesUtils.bookmarks.addObserver(this._recentlyBookmarkedObserver, true);
- placesContextMenu.addEventListener("popupshowing", onPlacesContextMenuShowing);
+
+ // The context menu doesn't exist in non-browser windows on Mac
+ if (placesContextMenu) {
+ placesContextMenu.addEventListener("popupshowing", onPlacesContextMenuShowing);
+ }
+
bookmarksMenu.addEventListener("popuphidden", onBookmarksMenuHidden);
},
_populateRecentBookmarks(aHeaderItem, aExtraCSSClass = "") {
while (aHeaderItem.nextSibling &&
aHeaderItem.nextSibling.localName == "menuitem") {
aHeaderItem.nextSibling.remove();
}