Bug 1258797 - Catch error when trying to open save as dialog to invalid path. r=Gijs draft
authorIan Moody <moz-ian@perix.co.uk>
Sat, 30 Sep 2017 17:51:05 +0100
changeset 673112 da89a0b7d2c66e8c744395f874a6b5fc61516454
parent 671801 76a26ef7c493311c170ae83eb0c1d6592a21396d
child 734008 a865e5d5d4dc4ea27447aeaf90bc12c701430597
push id82468
push usermoz-ian@perix.co.uk
push dateSun, 01 Oct 2017 10:21:05 +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,23 @@ 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()) {