Bug 1275078 - toolbox-init.js error handling tweaks from Positron. r=ochameau
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 22 Feb 2017 12:45:06 -0600
changeset 373534 22c5f7ea3629a548783bb88f6dc16fa10d9fbfaa
parent 373533 f66f556b789311697a943d0d2a717f73d8969e6c
child 373535 9b7d8840e54f0470d9defb2a7b0a0a32b10cd7b1
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersochameau
bugs1275078
milestone54.0a1
Bug 1275078 - toolbox-init.js error handling tweaks from Positron. r=ochameau MozReview-Commit-ID: LDjzdUTJikc
devtools/client/framework/toolbox-init.js
--- 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);
   });