Bug 699533 - Save/update password doorhanger does not restore focus to the webpage. r=felipe
authorMarcos Santiago <littledodgeviper@sbcglobal.net>
Mon, 28 May 2012 21:31:48 -0700
changeset 99211 76791f5996ccd6ea78b183d675b35fb66d42da92
parent 99210 6aa5239fe656e06756662f53f589b377280f4a36
child 99212 8ad6067e90f7deeea99ae626b934790176c6cfb1
push idunknown
push userunknown
push dateunknown
reviewersfelipe
bugs699533
milestone15.0a1
Bug 699533 - Save/update password doorhanger does not restore focus to the webpage. r=felipe Patch by Marcos Santiago and Jimmy Phan
toolkit/components/passwordmgr/nsLoginManagerPrompter.js
toolkit/content/PopupNotifications.jsm
--- a/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
+++ b/toolkit/components/passwordmgr/nsLoginManagerPrompter.js
@@ -796,26 +796,28 @@ LoginManagerPrompter.prototype = {
         // Notification is a PopupNotification
         if (aNotifyObj == this._getPopupNote()) {
             // "Remember" button
             var mainAction = {
                 label:     rememberButtonText,
                 accessKey: rememberButtonAccessKey,
                 callback: function(aNotifyObj, aButton) {
                     pwmgr.addLogin(aLogin);
+                    browser.focus();
                 }
             };
 
             var secondaryActions = [
                 // "Never for this site" button
                 {
                     label:     neverButtonText,
                     accessKey: neverButtonAccessKey,
                     callback: function(aNotifyObj, aButton) {
                         pwmgr.setLoginSavingEnabled(aLogin.hostname, false);
+                        browser.focus();
                     }
                 }
             ];
 
             var notifyWin = this._getNotifyWindow();
             var chromeWin = this._getChromeWindow(notifyWin).wrappedJSObject;
             var browser = chromeWin.gBrowser.
                                     getBrowserForDocument(this._window.top.document);
--- a/toolkit/content/PopupNotifications.jsm
+++ b/toolkit/content/PopupNotifications.jsm
@@ -371,17 +371,21 @@ PopupNotifications.prototype = {
     notifications.splice(index, 1);
     this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
   },
 
   /**
    * Dismisses the notification without removing it.
    */
   _dismiss: function PopupNotifications_dismiss() {
+    let browser = this.panel.firstChild &&
+                  this.panel.firstChild.notification.browser;
     this.panel.hidePopup();
+    if (browser)
+      browser.focus();
   },
 
   /**
    * Hides the notification popup.
    */
   _hidePanel: function PopupNotifications_hide() {
     this._ignoreDismissal = true;
     this.panel.hidePopup();