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 89448 63612df321939448993c5d150c2a11880ea9ff3d
parent 89447 e7f495b11aa6e49bbd0bb24dcc5a6c55d70ac9ed
child 89449 039e03f6d382173b3ff4f67c0eea318b3ea74be2
push id22256
push usergsharp@mozilla.com
push dateFri, 16 Mar 2012 04:41:46 +0000
treeherdermozilla-central@e5f6caa40409 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs733651
milestone14.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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;
       }