Bug 1203813 - Make nsHelperAppDlg dialog be parented by top-level nsIDOMWindow. r?mrbkap
MozReview-Commit-ID: LUK01OptZgG
--- a/toolkit/mozapps/downloads/nsHelperAppDlg.js
+++ b/toolkit/mozapps/downloads/nsHelperAppDlg.js
@@ -158,21 +158,25 @@ nsUnknownContentTypeDialog.prototype = {
},
// When opening from new tab, if tab closes while dialog is opening,
// (which is a race condition on the XUL file being cached and the timer
// in nsExternalHelperAppService), the dialog gets a blur and doesn't
// activate the OK button. So we wait a bit before doing opening it.
reallyShow: function() {
try {
- var ir = this.mContext.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
- var dwi = ir.getInterface(Components.interfaces.nsIDOMWindow);
- var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
+ let ir = this.mContext.QueryInterface(Components.interfaces.nsIInterfaceRequestor);
+ let docShell = ir.getInterface(Components.interfaces.nsIDocShell);
+ let rootWin = docShell.QueryInterface(Ci.nsIDocShellTreeItem)
+ .rootTreeItem
+ .QueryInterface(Ci.nsIInterfaceRequestor)
+ .getInterface(Ci.nsIDOMWindow);
+ let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher);
- this.mDialog = ww.openWindow(dwi,
+ this.mDialog = ww.openWindow(rootWin,
"chrome://mozapps/content/downloads/unknownContentType.xul",
null,
"chrome,centerscreen,titlebar,dialog=yes,dependent",
null);
} catch (ex) {
// The containing window may have gone away. Break reference
// cycles and stop doing the download.
this.mLauncher.cancel(Components.results.NS_BINDING_ABORTED);