Bug 1507117 - aboutPerformance.js, add a null check before accessing row.nextSibling when removing a subtree, r=Gijs.
authorFlorian Quèze <florian@queze.net>
Wed, 14 Nov 2018 14:46:45 +0100
changeset 502821 d933706067df67a706db0b7880f1c7cea4618ab8
parent 502820 f790f10bca336852f65e14efa5c2e083775acf03
child 502822 b9725b8b1c14bb944e5ed3526758fe966da79905
push id10290
push userffxbld-merge
push dateMon, 03 Dec 2018 16:23:23 +0000
treeherdermozilla-beta@700bed2445e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1507117
milestone65.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 1507117 - aboutPerformance.js, add a null check before accessing row.nextSibling when removing a subtree, r=Gijs.
toolkit/components/aboutperformance/content/aboutPerformance.js
--- a/toolkit/components/aboutperformance/content/aboutPerformance.js
+++ b/toolkit/components/aboutperformance/content/aboutPerformance.js
@@ -1088,16 +1088,22 @@ var View = {
 
     this._fragment.appendChild(row);
     return row;
   },
 };
 
 var Control = {
   _openItems: new Set(),
+  _removeSubtree(row) {
+    while (row.nextSibling &&
+           row.nextSibling.firstChild.classList.contains("indent")) {
+      row.nextSibling.remove();
+    }
+  },
   init() {
     this._initAutorefresh();
     this._initDisplayMode();
     let tbody = document.getElementById("dispatch-tbody");
     tbody.addEventListener("click", event => {
       this._updateLastMouseEvent();
 
       // Handle showing or hiding subitems of a row.
@@ -1106,33 +1112,31 @@ var Control = {
         let row = target.parentNode.parentNode;
         let id = row.windowId;
         if (target.classList.toggle("open")) {
           this._openItems.add(id);
           this._showChildren(row);
           View.insertAfterRow(row);
         } else {
           this._openItems.delete(id);
-          while (row.nextSibling.firstChild.classList.contains("indent"))
-            row.nextSibling.remove();
+          this._removeSubtree(row);
         }
         return;
       }
 
       // Handle closing a tab.
       if (target.classList.contains("close-icon")) {
         let row = target.parentNode.parentNode;
         let id = parseInt(row.windowId);
         let found = tabFinder.get(id);
         if (!found || !found.tabbrowser)
           return;
         let {tabbrowser, tab} = found;
         tabbrowser.removeTab(tab);
-        while (row.nextSibling.firstChild.classList.contains("indent"))
-          row.nextSibling.remove();
+        this._removeSubtree(row);
         row.remove();
         return;
       }
 
       if (target.classList.contains("addon-icon")) {
         let row = target.parentNode.parentNode;
         let id = row.windowId;
         let parentWin = window.docShell.rootTreeItem.domWindow;