diff --git a/toolkit/mozapps/downloads/nsHelperAppDlg.js b/toolkit/mozapps/downloads/nsHelperAppDlg.js index 186fcf15a8c3..cc4903cc0b60 100644 --- a/toolkit/mozapps/downloads/nsHelperAppDlg.js +++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js @@ -228,7 +228,21 @@ nsUnknownContentTypeDialog.prototype = { // because the original one is definitely gone (and nsIFilePicker doesn't like // a null parent): gDownloadLastDir = this._mDownloadDir; - parent = Services.wm.getMostRecentWindow(""); + let windowsEnum = Services.wm.getEnumerator(""); + while (windowsEnum.hasMoreElements()) { + let someWin = windowsEnum.getNext(); + // We need to make sure we don't end up with this dialog, because otherwise + // that's going to go away when the user clicks "Save", and that breaks the + // windows file picker that's supposed to show up if we let the user choose + // where to save files... + if (someWin != this.mDialog) { + parent = someWin; + } + } + if (!parent) { + Cu.reportError("No candidate parent windows were found for the save filepicker." + + "This should never happen."); + } } Task.spawn(function() {