Bug 1258797 - Catch error when trying to open save as dialog to invalid path. r=Gijs
MozReview-Commit-ID: GbMgcfOgVaq
--- 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()) {