Bug 733651 - Snippet fails to load on about:home due to XMLHttpRequest.open error. r=mak
authorFrank Yan <fyan@mozilla.com>
Wed, 14 Mar 2012 16:09:15 -0700
changeset 89006 63612df321939448993c5d150c2a11880ea9ff3d
parent 89005 e7f495b11aa6e49bbd0bb24dcc5a6c55d70ac9ed
child 89007 039e03f6d382173b3ff4f67c0eea318b3ea74be2
push id605
push userfyan@mozilla.com
push dateWed, 14 Mar 2012 23:15:21 +0000
treeherderfx-team@039e03f6d382 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs733651
milestone14.0a1
Bug 733651 - Snippet fails to load on about:home due to XMLHttpRequest.open error. r=mak
browser/base/content/aboutHome.js
--- a/browser/base/content/aboutHome.js
+++ b/browser/base/content/aboutHome.js
@@ -205,23 +205,27 @@ function setupSearchEngine()
 
 function loadSnippets()
 {
   // Check last snippets update.
   let lastUpdate = localStorage["snippets-last-update"];
   let updateURL = localStorage["snippets-update-url"];
   if (updateURL && (!lastUpdate ||
                     Date.now() - lastUpdate > SNIPPETS_UPDATE_INTERVAL_MS)) {
+    // Try to update from network.
+    let xhr = new XMLHttpRequest();
+    try {
+      xhr.open("GET", updateURL, true);
+    } catch (ex) {
+      showSnippets();
+      return;
+    }
     // Even if fetching should fail we don't want to spam the server, thus
     // set the last update time regardless its results.  Will retry tomorrow.
     localStorage["snippets-last-update"] = Date.now();
-
-    // Try to update from network.
-    let xhr = new XMLHttpRequest();
-    xhr.open('GET', updateURL, true);
     xhr.onerror = function (event) {
       showSnippets();
     };
     xhr.onload = function (event)
     {
       if (xhr.status == 200) {
         localStorage["snippets"] = xhr.responseText;
       }