Bug 1258797 - Catch error when trying to open save as dialog to invalid path. r=Gijs
☠☠ backed out by 562b8f9ed39c ☠ ☠
authorIan Moody <moz-ian@perix.co.uk>
Sat, 30 Sep 2017 17:51:05 +0100
changeset 426488 e900a3d074b81b7617e6a65bcd18a02450652990
parent 426487 22374473d24f4b4877e50f0b49da3174a70f79ab
child 426489 65a1e4064a52ebd60ec55fdf0380405b97f78a8e
push id97
push userfmarier@mozilla.com
push dateSat, 14 Oct 2017 01:12:59 +0000
reviewersGijs
bugs1258797
milestone58.0a1
Bug 1258797 - Catch error when trying to open save as dialog to invalid path. r=Gijs MozReview-Commit-ID: GbMgcfOgVaq
toolkit/mozapps/downloads/DownloadLastDir.jsm
--- a/toolkit/mozapps/downloads/DownloadLastDir.jsm
+++ b/toolkit/mozapps/downloads/DownloadLastDir.jsm
@@ -138,19 +138,24 @@ DownloadLastDir.prototype = {
                          .getService(Components.interfaces.nsIContentPrefService2);
     let result = null;
     cps2.getByDomainAndName(uri, LAST_DIR_PREF, this.fakeContext, {
       handleResult: aResult => result = aResult,
       handleCompletion(aReason) {
         let file = plainPrefFile;
         if (aReason == Components.interfaces.nsIContentPrefCallback2.COMPLETE_OK &&
            result instanceof Components.interfaces.nsIContentPref) {
-          file = Components.classes["@mozilla.org/file/local;1"]
-                           .createInstance(Components.interfaces.nsIFile);
-          file.initWithPath(result.value);
+          try {
+            file = Components.classes["@mozilla.org/file/local;1"]
+                             .createInstance(Components.interfaces.nsIFile);
+            file.initWithPath(result.value);
+          }
+          catch (e) {
+            file = plainPrefFile;
+          }
         }
         aCallback(file);
       }
     });
   },
 
   setFile(aURI, aFile) {
     if (aURI && isContentPrefEnabled()) {