Ignore invalid display directories in FilePicker

As of Firefox 140.17/153.4 (Bug 2068406), setting nsIFilePicker's
displayDirectory to a directory that doesn't exist or isn't readable
throws instead of being ignored. This broke callers that pass a saved
path that may be stale (e.g., choosing a PDF/EPUB handler after the old
app's folder was removed, or a missing Scaffold translators directory).

(cherry picked from commit ae50d52589)
This commit is contained in:
Dan Stillman 2026-10-01 16:32:36 -04:00
parent 672bd4255e
commit a8411d11ab

View file

@ -175,6 +175,13 @@ FilePicker.prototype.filterVideo = 0x200;
if (prop == 'displayDirectory') {
// Convert to nsIFile
val = new lazy.FileUtils.File(val);
// As of Firefox 140.17/153.4, this throws if the directory doesn't exist or
// isn't readable. Ignore that and let the platform pick the initial directory.
try {
this._fp[prop] = val;
}
catch {}
return;
}
this._fp[prop] = val;
},