Bug 1105825 - 3 - Make sure sidebar widget destroy works even if window is closed during panel destroy; r=past
authorPatrick Brosset <pbrosset@mozilla.com>
Sat, 10 Jan 2015 19:50:01 +0100
changeset 249081 814e685b77e19a8782667d5168df20052af14752
parent 249080 9beacf61fe3dce6945f8f4630aa32ea3ee4e0fc2
child 249082 35144551829c6ae3d8784885c0db2ba5554da614
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs1105825
milestone37.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 1105825 - 3 - Make sure sidebar widget destroy works even if window is closed during panel destroy; r=past
browser/devtools/framework/sidebar.js
--- a/browser/devtools/framework/sidebar.js
+++ b/browser/devtools/framework/sidebar.js
@@ -252,26 +252,29 @@ ToolSidebar.prototype = {
       return promise.resolve(null);
     }
     this._destroyed = true;
 
     Services.prefs.setIntPref("devtools.toolsidebar-width." + this._uid, this._tabbox.width);
 
     this._tabbox.tabpanels.removeEventListener("select", this, true);
 
-    while (this._tabbox.tabpanels.hasChildNodes()) {
+    // Note that we check for the existence of this._tabbox.tabpanels at each
+    // step as the container window may have been closed by the time one of the
+    // panel's destroy promise resolves.
+    while (this._tabbox.tabpanels && this._tabbox.tabpanels.hasChildNodes()) {
       let panel = this._tabbox.tabpanels.firstChild;
       let win = panel.firstChild.contentWindow;
       if ("destroy" in win) {
         yield win.destroy();
       }
       panel.remove();
     }
 
-    while (this._tabbox.tabs.hasChildNodes()) {
+    while (this._tabbox.tabs && this._tabbox.tabs.hasChildNodes()) {
       this._tabbox.tabs.removeChild(this._tabbox.tabs.firstChild);
     }
 
     if (this._currentTool) {
       this._telemetry.toolClosed(this._currentTool);
     }
 
     this._toolPanel.emit("sidebar-destroyed", this);