Bug 1275289 - Add try catch to DownloadLegacy.js since aRequest.responseStatus does not exist in the case of a failed download. r=paolo
☠☠ backed out by fb2ed37447b7 ☠ ☠
authorJimmy Wang <jimmyw22@gmail.com>
Tue, 24 May 2016 14:37:42 -0400
changeset 349468 7638ea3c616cdba26394a886bcf3aea4629cff85
parent 349467 d69343be1c2416a33595f78190a41d13c9bcc284
child 349469 0212e01c7769479a4a5ce8ef26c8d082a50b8f88
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaolo
bugs1275289
milestone50.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 1275289 - Add try catch to DownloadLegacy.js since aRequest.responseStatus does not exist in the case of a failed download. r=paolo MozReview-Commit-ID: HbN86Ef3Okv
toolkit/components/jsdownloads/src/DownloadLegacy.js
--- a/toolkit/components/jsdownloads/src/DownloadLegacy.js
+++ b/toolkit/components/jsdownloads/src/DownloadLegacy.js
@@ -85,20 +85,30 @@ DownloadLegacyTransfer.prototype = {
   {
     if (!Components.isSuccessCode(aStatus)) {
       this._componentFailed = true;
     }
 
     if ((aStateFlags & Ci.nsIWebProgressListener.STATE_START) &&
         (aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK)) {
 
-      // If the request's response has been blocked by Windows Parental Controls
-      // with an HTTP 450 error code, we must cancel the request synchronously.
-      let blockedByParentalControls = aRequest instanceof Ci.nsIHttpChannel &&
+      let blockedByParentalControls = false;
+      // If it is a failed download, aRequest.responseStatus doesn't exist.
+      // (missing file on the server, network failure to download)
+      try {
+        // If the request's response has been blocked by Windows Parental Controls
+        // with an HTTP 450 error code, we must cancel the request synchronously.
+        blockedByParentalControls = aRequest instanceof Ci.nsIHttpChannel &&
                                       aRequest.responseStatus == 450;
+      } catch (e) {
+        if (e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
+          aRequest.cancel(Cr.NS_BINDING_ABORTED);
+        }
+      }
+
       if (blockedByParentalControls) {
         aRequest.cancel(Cr.NS_BINDING_ABORTED);
       }
 
       // The main request has just started.  Wait for the associated Download
       // object to be available before notifying.
       this._deferDownload.promise.then(download => {
         // If the request was blocked, now that we have the download object we