bug 896314 fix permission icon when swapping social providers, r=felipe
authorShane Caraveo <scaraveo@mozilla.com>
Mon, 29 Jul 2013 09:35:41 -0700
changeset 152655 8f24192cb2b25d67789e158b23d40305c321ee6c
parent 152654 00c1c1de3e0fd760fb601d5b1b3f0713a5ee244e
child 152656 82659e86fd98739a56cc08058d29751829634848
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfelipe
bugs896314
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 896314 fix permission icon when swapping social providers, r=felipe
browser/base/content/browser-social.js
toolkit/modules/PopupNotifications.jsm
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -1361,16 +1361,17 @@ SocialSidebar = {
       if (Social.provider.errorState == "frameworker-error") {
         SocialSidebar.setSidebarErrorMessage();
         return;
       }
 
       // Make sure the right sidebar URL is loaded
       if (sbrowser.getAttribute("src") != Social.provider.sidebarURL) {
         sbrowser.setAttribute("src", Social.provider.sidebarURL);
+        PopupNotifications.locationChange(sbrowser);
       }
 
       // if the document has not loaded, delay until it is
       if (sbrowser.contentDocument.readyState != "complete") {
         sbrowser.addEventListener("load", SocialSidebar._loadListener, true);
       } else {
         this.setSidebarVisibilityState(true);
       }
--- a/toolkit/modules/PopupNotifications.jsm
+++ b/toolkit/modules/PopupNotifications.jsm
@@ -16,16 +16,28 @@ const NOTIFICATION_EVENT_SHOWN = "shown"
 const ICON_SELECTOR = ".notification-anchor-icon";
 const ICON_ATTRIBUTE_SHOWING = "showing";
 
 const PREF_SECURITY_DELAY = "security.notification_enable_delay";
 
 let popupNotificationsMap = new WeakMap();
 let gNotificationParents = new WeakMap;
 
+function getAnchorFromBrowser(aBrowser) {
+  let anchor = aBrowser.getAttribute("popupnotificationanchor") ||
+                aBrowser.popupnotificationanchor;
+  if (anchor) {
+    if (anchor instanceof Ci.nsIDOMXULElement) {
+      return anchor;
+    }
+    return aBrowser.ownerDocument.getElementById(anchor);
+  }
+  return null;
+}
+
 /**
  * Notification object describes a single popup notification.
  *
  * @see PopupNotifications.show()
  */
 function Notification(id, message, anchorID, mainAction, secondaryActions,
                       browser, owner, options) {
   this.id = id;
@@ -55,26 +67,17 @@ Notification.prototype = {
    */
   remove: function Notification_remove() {
     this.owner.remove(this);
   },
 
   get anchorElement() {
     let iconBox = this.owner.iconBox;
 
-    let anchorElement = null;
-    let anchor = this.browser.getAttribute("popupnotificationanchor") ||
-                 this.browser.popupnotificationanchor;
-    if (anchor) {
-      if (anchor instanceof Ci.nsIDOMXULElement) {
-        anchorElement = anchor;
-      } else {
-        anchorElement = this.browser.ownerDocument.getElementById(anchor);
-      }
-    }
+    let anchorElement = getAnchorFromBrowser(this.browser);
 
     if (!iconBox)
       return anchorElement;
 
     if (!anchorElement && this.anchorID)
       anchorElement = iconBox.querySelector("#"+this.anchorID);
 
     // Use a default anchor icon if it's available
@@ -339,18 +342,25 @@ PopupNotifications.prototype = {
       }
 
       this._fireCallback(notification, NOTIFICATION_EVENT_REMOVED);
       return false;
     }, this);
 
     this._setNotificationsForBrowser(aBrowser, notifications);
 
-    if (aBrowser.docShell.isActive)
-      this._update(notifications);
+    if (aBrowser.docShell.isActive) {
+      // get the anchor element if the browser has defined one so it will
+      // _update will handle both the tabs iconBox and non-tab permission
+      // anchors.
+      let anchorElement = notifications.length > 0 ? notifications[0].anchorElement : null;
+      if (!anchorElement)
+        anchorElement = getAnchorFromBrowser(aBrowser);
+      this._update(notifications, anchorElement);
+    }
   },
 
   /**
    * Removes a Notification.
    * @param notification
    *        The Notification object to remove.
    */
   remove: function PopupNotifications_remove(notification) {