mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1281731 - Destroy the toolbox on toolbox.xul unload. r=jryans
This commit is contained in:
parent
804ddb6322
commit
9e552a2542
@ -29,44 +29,56 @@ if (url.search.length > 1) {
|
||||
// Specify the default tool to open
|
||||
let tool = url.searchParams.get("tool");
|
||||
|
||||
if (url.searchParams.has("target")) {
|
||||
// Attach toolbox to a given browser iframe (<xul:browser> or <html:iframe
|
||||
// mozbrowser>) whose reference is set on the host iframe.
|
||||
Task.spawn(function* () {
|
||||
let target;
|
||||
if (url.searchParams.has("target")) {
|
||||
// Attach toolbox to a given browser iframe (<xul:browser> or <html:iframe
|
||||
// mozbrowser>) whose reference is set on the host iframe.
|
||||
|
||||
// `iframe` is the targeted document to debug
|
||||
let iframe = host.wrappedJSObject ? host.wrappedJSObject.target
|
||||
: host.target;
|
||||
// Need to use a xray and query some interfaces to have
|
||||
// attributes and behavior expected by devtools codebase
|
||||
iframe = XPCNativeWrapper(iframe);
|
||||
iframe.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
// `iframe` is the targeted document to debug
|
||||
let iframe = host.wrappedJSObject ? host.wrappedJSObject.target
|
||||
: host.target;
|
||||
// Need to use a xray and query some interfaces to have
|
||||
// attributes and behavior expected by devtools codebase
|
||||
iframe = XPCNativeWrapper(iframe);
|
||||
iframe.QueryInterface(Ci.nsIFrameLoaderOwner);
|
||||
|
||||
if (iframe) {
|
||||
// Fake a xul:tab object as we don't have one.
|
||||
// linkedBrowser is the only one attribute being queried by client.getTab
|
||||
let tab = { linkedBrowser: iframe };
|
||||
if (iframe) {
|
||||
// Fake a xul:tab object as we don't have one.
|
||||
// linkedBrowser is the only one attribute being queried by client.getTab
|
||||
let tab = { linkedBrowser: iframe };
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
|
||||
if (!DebuggerServer.initialized) {
|
||||
DebuggerServer.init();
|
||||
DebuggerServer.addBrowserActors();
|
||||
}
|
||||
let client = new DebuggerClient(DebuggerServer.connectPipe());
|
||||
Task.spawn(function* () {
|
||||
yield client.connect();
|
||||
// Creates a target for a given browser iframe.
|
||||
let response = yield client.getTab({ tab });
|
||||
let form = response.tab;
|
||||
let target = yield TargetFactory.forRemoteTab({client, form, chrome: false});
|
||||
let options = { customIframe: host };
|
||||
yield gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
|
||||
});
|
||||
target = yield TargetFactory.forRemoteTab({client, form, chrome: false});
|
||||
} else {
|
||||
alert("Unable to find the targetted iframe to debug");
|
||||
}
|
||||
} else {
|
||||
target = yield targetFromURL(url);
|
||||
}
|
||||
} else {
|
||||
targetFromURL(url).then(target => {
|
||||
let options = { customIframe: host };
|
||||
return gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
|
||||
}).then(null, e => {
|
||||
window.alert("Unable to start the toolbox:" + e.message);
|
||||
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, true);
|
||||
toolbox.on("destroy", function () {
|
||||
window.removeEventListener("unload", onUnload);
|
||||
});
|
||||
}
|
||||
}).catch(error => {
|
||||
console.error("Exception while loading the toolbox", error);
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user