Bug 1274877 - contextMenus API starts logging errors after removing an item, r=kmag
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 07 Jun 2016 15:26:08 -0400
changeset 301181 aaac9952244efafe0f37257a795bf44bfa2737e0
parent 301180 518e72986fab90942b50560178f143490501229d
child 301182 43a83633a789f6078f4807c09b657ccd83ef9cf4
push id78241
push userkwierso@gmail.com
push dateThu, 09 Jun 2016 00:09:10 +0000
treeherdermozilla-inbound@2c66b75bbb7f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1274877
milestone50.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 1274877 - contextMenus API starts logging errors after removing an item, r=kmag MozReview-Commit-ID: 86bxjxEQaQX
browser/components/extensions/ext-contextMenus.js
--- a/browser/components/extensions/ext-contextMenus.js
+++ b/browser/components/extensions/ext-contextMenus.js
@@ -35,17 +35,17 @@ var gMaxLabelLength = 64;
 // popuphidden fires.
 var gMenuBuilder = {
   build: function(contextData) {
     let xulMenu = contextData.menu;
     xulMenu.addEventListener("popuphidden", this);
     this.xulMenu = xulMenu;
     for (let [, root] of gRootItems) {
       let rootElement = this.buildElementWithChildren(root, contextData);
-      if (!rootElement.firstChild.childNodes.length) {
+      if (!rootElement.firstChild || !rootElement.firstChild.childNodes.length) {
         // If the root has no visible children, there is no reason to show
         // the root menu item itself either.
         continue;
       }
       rootElement.setAttribute("ext-type", "top-level-menu");
       rootElement = this.removeTopLevelMenuIfNeeded(rootElement);
 
       // Display the extension icon on the root element.