Bug 1079707 - asyncresolve can throw, r=alexbardas
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Thu, 16 Oct 2014 15:01:32 -0700
changeset 210786 044923edbc611a51369d561db12efc794e1e9b80
parent 210785 719a055fe22bcbd785c48fd06f178402987fc393
child 210787 6e7bdaa5a71ff2e87cbca793a3e4ab2630828f70
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersalexbardas
bugs1079707
milestone36.0a1
Bug 1079707 - asyncresolve can throw, r=alexbardas
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -777,17 +777,25 @@ function gKeywordURIFixup({ target: brow
     ];
     let notification =
       notificationBox.appendNotification(message,"keyword-uri-fixup", null,
                                          notificationBox.PRIORITY_INFO_HIGH,
                                          buttons);
     notification.persistence = 1;
   };
 
-  gDNSService.asyncResolve(hostName, 0, onLookupComplete, Services.tm.mainThread);
+  try {
+    gDNSService.asyncResolve(hostName, 0, onLookupComplete, Services.tm.mainThread);
+  } catch (ex) {
+    // Do nothing if the URL is invalid (we don't want to show a notification in that case).
+    if (ex.result != Cr.NS_ERROR_UNKNOWN_HOST) {
+      // ... otherwise, report:
+      Cu.reportError(ex);
+    }
+  }
 }
 
 // Called when a docshell has attempted to load a page in an incorrect process.
 // This function is responsible for loading the page in the correct process.
 function RedirectLoad({ target: browser, data }) {
   let tab = gBrowser.getTabForBrowser(browser);
   // Flush the tab state before getting it
   TabState.flush(browser);