Bug 1258797 - Catch error when trying to open save as dialog to invalid path. r=Gijs
authorIan Moody <moz-ian@perix.co.uk>
Sat, 30 Sep 2017 17:51:05 +0100
changeset 383912 972c3948109e948628c6f81f2528e50b82dae747
parent 383911 2e8b0f9f2f7ef1272b7abffa19e8733e9e39a2b6
child 383913 b5cf95178314a50d6ee2790cc55fb660708a3e02
child 383943 44643fce30b43a8981535c335aaccb45006e456b
push id52432
push usergijskruitbosch@gmail.com
push dateSun, 01 Oct 2017 11:39:02 +0000
treeherderautoland@972c3948109e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1258797
milestone58.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 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()) {