Bug 1203813 - Make nsHelperAppDlg dialog be parented by top-level nsIDOMWindow. r=mrbkap
authorMike Conley <mconley@mozilla.com>
Thu, 27 Oct 2016 02:47:32 -0400
changeset 319876 a1ea2703d9e81330c261846575016399e01ba893
parent 319815 ed22ec2c58924267a99e6d81658c4dc387f19fc3
child 319907 5074747b77f0e344aa5131b817e1e6873d73a398
push id20749
push userryanvm@gmail.com
push dateSat, 29 Oct 2016 13:21:21 +0000
treeherderfx-team@1b170b39ed6b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmrbkap
bugs1203813
milestone52.0a1
Bug 1203813 - Make nsHelperAppDlg dialog be parented by top-level nsIDOMWindow. r=mrbkap MozReview-Commit-ID: LUK01OptZgG
toolkit/mozapps/downloads/nsHelperAppDlg.js
--- 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);