Bug 1275078 - toolbox-init.js error handling tweaks from Positron. r=ochameau
MozReview-Commit-ID: LDjzdUTJikc
--- a/devtools/client/framework/toolbox-init.js
+++ b/devtools/client/framework/toolbox-init.js
@@ -53,40 +53,40 @@ if (url.search.length > 1) {
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;
+ if (!iframe) {
+ throw new Error("Unable to find the targeted iframe to debug");
+ }
+
// 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 };
+ // 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());
- yield client.connect();
- // Creates a target for a given browser iframe.
- let response = yield client.getTab({ tab });
- let form = response.tab;
- target = yield TargetFactory.forRemoteTab({client, form, chrome: false});
- } else {
- alert("Unable to find the targetted iframe to debug");
- }
+ yield client.connect();
+ // Creates a target for a given browser iframe.
+ let response = yield client.getTab({ tab });
+ let form = response.tab;
+ target = yield TargetFactory.forRemoteTab({client, form, chrome: false});
} else {
target = yield targetFromURL(url);
}
let options = { customIframe: host };
yield gDevTools.showToolbox(target, tool, Toolbox.HostType.CUSTOM, options);
}).catch(error => {
console.error("Exception while loading the toolbox", error);
});