Bug 1225473 - Cleanup DebuggerClient on about:debugging close and fetch only the target of the currently opened tab. r=janx
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 03 Dec 2015 06:42:35 -0800
changeset 309626 20fc590db5655f299da87df165845d2f0127fbb5
parent 309625 310bf739e766fb1755e48c3e53f9d9aa73352f56
child 309627 91642bf07cd0aaba3a589d52c2c063c5c8919e97
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanx
bugs1225473
milestone45.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 1225473 - Cleanup DebuggerClient on about:debugging close and fetch only the target of the currently opened tab. r=janx
devtools/client/aboutdebugging/aboutdebugging.js
--- a/devtools/client/aboutdebugging/aboutdebugging.js
+++ b/devtools/client/aboutdebugging/aboutdebugging.js
@@ -59,26 +59,30 @@ var AboutDebugging = {
     }
     // Show the corresponding tab and hide the others.
     document.querySelector(".tab.active").classList.remove("active");
     document.querySelector("#tab-" + category).classList.add("active");
     document.querySelector(".category[selected]").removeAttribute("selected");
     document.querySelector(".category[value=" + category + "]")
       .setAttribute("selected", "true");
     location.hash = "#" + category;
+
+    if (category == "addons") {
+      React.render(React.createElement(AddonsComponent, { client: this.client }),
+        document.querySelector("#addons"));
+    } else if (category == "workers") {
+      React.render(React.createElement(WorkersComponent, { client: this.client }),
+        document.querySelector("#workers"));
+    }
   },
 
   init() {
     let telemetry = this._telemetry = new Telemetry();
     telemetry.toolOpened("aboutdebugging");
 
-    // Show the first available tab.
-    this.showTab();
-    window.addEventListener("hashchange", () => this.showTab());
-
     // Link checkboxes to prefs.
     let elements = document.querySelectorAll("input[type=checkbox][data-pref]");
     Array.map(elements, element => {
       let pref = element.dataset.pref;
       let updatePref = () => {
         Services.prefs.setBoolPref(pref, element.checked);
       };
       element.addEventListener("change", updatePref, false);
@@ -94,23 +98,22 @@ var AboutDebugging = {
     let loadAddonButton = document.getElementById("load-addon-from-file");
     loadAddonButton.addEventListener("click", this.loadAddonFromFile);
 
     if (!DebuggerServer.initialized) {
       DebuggerServer.init();
       DebuggerServer.addBrowserActors();
     }
     DebuggerServer.allowChromeProcess = true;
-    let client = new DebuggerClient(DebuggerServer.connectPipe());
+    this.client = new DebuggerClient(DebuggerServer.connectPipe());
 
-    client.connect(() => {
-      React.render(React.createElement(AddonsComponent, { client }),
-        document.querySelector("#addons"));
-      React.render(React.createElement(WorkersComponent, { client }),
-        document.querySelector("#workers"));
+    this.client.connect(() => {
+      // Show the first available tab.
+      this.showTab();
+      window.addEventListener("hashchange", () => this.showTab());
     });
   },
 
   loadAddonFromFile() {
     let fp = Cc["@mozilla.org/filepicker;1"].createInstance(Ci.nsIFilePicker);
     fp.init(window,
       Strings.GetStringFromName("selectAddonFromFile"),
       Ci.nsIFilePicker.modeOpen);
@@ -139,16 +142,19 @@ var AboutDebugging = {
 
     this._prefListeners.forEach(([pref, listener]) => {
       Services.prefs.removeObserver(pref, listener);
     });
     this._prefListeners = [];
 
     React.unmountComponentAtNode(document.querySelector("#addons"));
     React.unmountComponentAtNode(document.querySelector("#workers"));
+
+    this.client.close();
+    this.client = null;
   },
 };
 
 window.addEventListener("DOMContentLoaded", function load() {
   window.removeEventListener("DOMContentLoaded", load);
   AboutDebugging.init();
 });