Bug 1252239: Trap errors thrown by speculativeConnect. r?ttaubert draft
authorKris Maglione <maglione.k@gmail.com>
Mon, 29 Feb 2016 13:06:26 -0800
changeset 335570 e5e4ad4333ae52c8b03475941be16f7528e76578
parent 335569 2dc35ef10107dba0e719c458cbc6bf4a6de70835
child 515159 e7585fe284d0f8b41d0f00ecc5307499b4df1c59
push id11813
push usermaglione.k@gmail.com
push dateMon, 29 Feb 2016 21:13:38 +0000
reviewersttaubert
bugs1252239
milestone47.0a1
Bug 1252239: Trap errors thrown by speculativeConnect. r?ttaubert MozReview-Commit-ID: Bbik1htw3qk
browser/base/content/newtab/sites.js
--- a/browser/base/content/newtab/sites.js
+++ b/browser/base/content/newtab/sites.js
@@ -290,17 +290,23 @@ Site.prototype = {
   },
 
   /**
    * Speculatively opens a connection to the current site.
    */
   _speculativeConnect: function Site_speculativeConnect() {
     let sc = Services.io.QueryInterface(Ci.nsISpeculativeConnect);
     let uri = Services.io.newURI(this.url, null, null);
-    sc.speculativeConnect(uri, null);
+    try {
+      // This can throw for certain internal URLs, when they wind up in
+      // about:newtab. Be sure not to propagate the error.
+      sc.speculativeConnect(uri, null);
+    } catch (e) {
+      Cu.reportError(e);
+    }
   },
 
   /**
    * Record interaction with site using telemetry.
    */
   _recordSiteClicked: function Site_recordSiteClicked(aIndex) {
     if (Services.prefs.prefHasUserValue("browser.newtabpage.rows") ||
         Services.prefs.prefHasUserValue("browser.newtabpage.columns") ||