Bug 1412681 - Fix NSS dialogs; r=snorp

The context object for NSS dialogs apparently won't give us a window, so
we have to fall back to the active window.

MozReview-Commit-ID: 4cHpcE8oggL
This commit is contained in:
Jim Chen 2017-10-30 22:48:58 -04:00
Родитель a1e7521959
Коммит e51e2066e0
2 изменённых файлов: 12 добавлений и 15 удалений

Просмотреть файл

@ -56,9 +56,14 @@ NSSDialogs.prototype = {
escapedArgList.length);
},
getPrompt: function(aTitle, aText, aButtons, aWindow) {
getPrompt: function(aTitle, aText, aButtons, aCtx) {
let win = null;
try {
win = aCtx.getInterface(Ci.nsIDOMWindow);
} catch (e) {
}
return new Prompt({
window: aWindow,
window: win,
title: aTitle,
text: aText,
buttons: aButtons,
@ -203,10 +208,10 @@ NSSDialogs.prototype = {
return detailLines.join("<br/>");
},
viewCertDetails: function(details, window) {
viewCertDetails: function(details, ctx) {
let p = this.getPrompt(this.getString("clientAuthAsk.message3"),
"",
[ this.getString("nssdialogs.ok.label") ], window);
[ this.getString("nssdialogs.ok.label") ], ctx);
p.addLabel({ label: details });
this.showPrompt(p);
},

Просмотреть файл

@ -20,21 +20,13 @@ function log(msg) {
Services.console.logStringMessage(msg);
}
function getRootWindow(win) {
// Get the root xul window.
return win.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDocShell).QueryInterface(Ci.nsIDocShellTreeItem)
.rootTreeItem.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
}
function Prompt(aOptions) {
this.window = "window" in aOptions ? aOptions.window : null;
this.msg = { async: true };
if (this.window) {
let window = getRootWindow(this.window);
let window = GeckoViewUtils.getChromeWindow(this.window);
let tab = window &&
window.document.documentElement
.getAttribute("windowtype") === "navigator:browser" &&
@ -260,7 +252,7 @@ var DoorHanger = {
},
show: function(aWindow, aMessage, aValue, aButtons, aOptions, aCategory) {
let chromeWin = getRootWindow(aWindow);
let chromeWin = GeckoViewUtils.getChromeWindow(aWindow);
if (chromeWin.NativeWindow && chromeWin.NativeWindow.doorhanger) {
// We're dealing with browser.js.
return chromeWin.NativeWindow.doorhanger.show(
@ -299,7 +291,7 @@ var DoorHanger = {
},
hide: function(aWindow, aValue) {
let chromeWin = getRootWindow(aWindow);
let chromeWin = GeckoViewUtils.getChromeWindow(aWindow);
if (chromeWin.NativeWindow && chromeWin.NativeWindow.doorhanger) {
// We're dealing with browser.js.
return chromeWin.NativeWindow.doorhanger.hide(