Bug 1298082 - Cleanup toolbox on its document unload. r=jryans

MozReview-Commit-ID: 6tghrnYJiOy
This commit is contained in:
Alexandre Poirot
2016-08-30 06:32:00 -07:00
parent 35acaa9d89
commit f32b04847e
2 changed files with 12 additions and 19 deletions

View File

@@ -66,18 +66,7 @@ if (url.search.length > 1) {
target = yield targetFromURL(url);
}
let options = { customIframe: host };
let toolbox = yield gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
// Watch for toolbox.xul unload in order to cleanup things when we close
// about:devtools-toolbox tabs
function onUnload() {
window.removeEventListener("unload", onUnload);
toolbox.destroy();
}
window.addEventListener("unload", onUnload);
toolbox.on("destroy", function () {
window.removeEventListener("unload", onUnload);
});
yield gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
}).catch(error => {
console.error("Exception while loading the toolbox", error);
});