Bug 1266836 - Fix password manager handling of popup windows in e10s
MozReview-Commit-ID: I7xWOBuYNqT
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -1339,25 +1339,25 @@ LoginManagerPrompter.prototype = {
var usernames = logins.map(l => l.username);
var dialogText = this._getLocalizedString("userSelectText");
var dialogTitle = this._getLocalizedString("passwordChangeTitle");
var selectedIndex = { value: null };
// If user selects ok, outparam.value is set to the index
// of the selected username.
var ok = this._promptService.select(this._window,
- dialogTitle, dialogText,
- usernames.length, usernames,
- selectedIndex);
+ dialogTitle, dialogText,
+ usernames.length, usernames,
+ selectedIndex);
if (ok) {
// Now that we know which login to use, modify its password.
var selectedLogin = logins[selectedIndex.value];
this.log("Updating password for user " + selectedLogin.username);
var newLoginWithUsername = Cc["@mozilla.org/login-manager/loginInfo;1"].
- createInstance(Ci.nsILoginInfo);
+ createInstance(Ci.nsILoginInfo);
newLoginWithUsername.init(aNewLogin.hostname,
aNewLogin.formSubmitURL, aNewLogin.httpRealm,
selectedLogin.username, aNewLogin.password,
selectedLogin.userNameField, aNewLogin.passwordField);
this._updateLogin(selectedLogin, newLoginWithUsername);
}
},
@@ -1398,54 +1398,63 @@ LoginManagerPrompter.prototype = {
return aWindow;
var chromeWin = aWindow.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell)
.chromeEventHandler.ownerDocument.defaultView;
return chromeWin;
},
-
- /*
- * _getNotifyWindow
- */
_getNotifyWindow: function () {
-
+ this.log("_getNotifyWindow");
try {
// Get topmost window, in case we're in a frame.
var notifyWin = this._window.top;
var isE10s = (notifyWin instanceof Ci.nsIDOMChromeWindow);
var useOpener = false;
+ this.log("opener:", notifyWin.opener,
+ "hasContentOpener:", this._getChromeWindow(notifyWin).gBrowser.selectedBrowser.hasContentOpener,
+ "e10s:", isE10s);
+ //debugger;
// Some sites pop up a temporary login window, which disappears
// upon submission of credentials. We want to put the notification
// bar in the opener window if this seems to be happening.
- if (notifyWin.opener) {
+ // TODO: why isn't notifyWin.opener truthy with e10s?
+ // TODO: Can/should I use this._opener instead?
+ if (notifyWin.opener || (this._browser && this._browser.hasContentOpener)) {
var chromeDoc = this._getChromeWindow(notifyWin).
document.documentElement;
var hasHistory;
if (isE10s) {
if (!this._browser)
throw new Error("Expected a browser in e10s");
hasHistory = this._browser.canGoBack;
} else {
var webnav = notifyWin.
QueryInterface(Ci.nsIInterfaceRequestor).
getInterface(Ci.nsIWebNavigation);
hasHistory = webnav.sessionHistory.count > 1;
}
+ this.log("_getNotifyWindow: chromehidden:", chromeDoc.getAttribute("chromehidden"),
+ "hasHistory:", hasHistory);
// Check to see if the current window was opened with chrome
// disabled, and if so use the opener window. But if the window
// has been used to visit other pages (ie, has a history),
// assume it'll stick around and *don't* use the opener.
if (chromeDoc.getAttribute("chromehidden") && !hasHistory) {
- this.log("Using opener window for notification bar.");
- notifyWin = notifyWin.opener;
+ this.log("Using opener window for notification");
+ if (isE10s) {
+ notifyWin = this._getChromeWindow(this._opener);
+ } else {
+ // TODO: this is wrong for e10s as we try to use the original notifyWin for getBrowserForContentWindow later
+ notifyWin = notifyWin.opener;
+ }
useOpener = true;
}
}
let browser;
if (useOpener && this._opener && isE10s) {
// In e10s, we have to reconstruct the opener browser from
// the CPOW passed in the message (and then passed to us in