diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js
index 21895875c685..ef886afe3707 100644
--- a/browser/base/content/browser-social.js
+++ b/browser/base/content/browser-social.js
@@ -282,14 +282,6 @@ var SocialToolbar = {
updateButtonHiddenState: function SocialToolbar_updateButtonHiddenState() {
this.button.hidden = !Social.uiVisible;
- if (!Social.provider.profile || !Social.provider.profile.userName) {
- ["social-notification-box",
- "social-status-iconbox"].forEach(function removeChildren(parentId) {
- let parent = document.getElementById(parentId);
- while(parent.hasChildNodes())
- parent.removeChild(parent.firstChild);
- });
- }
},
updateProfile: function SocialToolbar_updateProfile() {
@@ -314,67 +306,42 @@ var SocialToolbar = {
updateButton: function SocialToolbar_updateButton() {
this.updateButtonHiddenState();
+
let provider = Social.provider;
+ // if there are no ambient icons, we collapse them in the following loop
let iconNames = Object.keys(provider.ambientNotificationIcons);
let iconBox = document.getElementById("social-status-iconbox");
- let notifBox = document.getElementById("social-notification-box");
- let notifBrowsers = document.createDocumentFragment();
- let iconContainers = document.createDocumentFragment();
-
- for each(let name in iconNames) {
- let icon = provider.ambientNotificationIcons[name];
-
- let notifBrowserId = "social-status-" + icon.name;
- let notifBrowser = document.getElementById(notifBrowserId);
- if (!notifBrowser) {
- notifBrowser = document.createElement("iframe");
- notifBrowser.setAttribute("type", "content");
- notifBrowser.setAttribute("id", notifBrowserId);
- notifBrowsers.appendChild(notifBrowser);
+ for (var i = 0; i < iconBox.childNodes.length; i++) {
+ let iconContainer = iconBox.childNodes[i];
+ if (i > iconNames.length - 1) {
+ iconContainer.collapsed = true;
+ continue;
}
- notifBrowser.setAttribute("origin", provider.origin);
- if (notifBrowser.getAttribute("src") != icon.contentPanel)
- notifBrowser.setAttribute("src", icon.contentPanel);
- let iconId = "social-notification-icon-" + icon.name;
- let iconContainer = document.getElementById(iconId);
- let iconImage, iconCounter;
- if (iconContainer) {
- iconImage = iconContainer.getElementsByClassName("social-notification-icon-image")[0];
- iconCounter = iconContainer.getElementsByClassName("social-notification-icon-counter")[0];
+ iconContainer.collapsed = false;
+ let icon = provider.ambientNotificationIcons[iconNames[i]];
+ let iconImage = iconContainer.firstChild;
+ let iconCounter = iconImage.nextSibling;
+
+ iconImage.setAttribute("contentPanel", icon.contentPanel);
+ iconImage.setAttribute("src", icon.iconURL);
+
+ if (iconCounter.firstChild)
+ iconCounter.removeChild(iconCounter.firstChild);
+
+ if (icon.counter) {
+ iconCounter.appendChild(document.createTextNode(icon.counter));
+ iconCounter.collapsed = false;
} else {
- iconContainer = document.createElement("box");
- iconContainer.setAttribute("id", iconId);
- iconContainer.classList.add("social-notification-icon-container");
- iconContainer.addEventListener("click", function (e) { SocialToolbar.showAmbientPopup(iconContainer); }, false);
-
- iconImage = document.createElement("image");
- iconImage.classList.add("social-notification-icon-image");
- iconImage = iconContainer.appendChild(iconImage);
-
- iconCounter = document.createElement("box");
- iconCounter.classList.add("social-notification-icon-counter");
- iconCounter.appendChild(document.createTextNode(""));
- iconCounter = iconContainer.appendChild(iconCounter);
-
- iconContainers.appendChild(iconContainer);
+ iconCounter.collapsed = true;
}
- if (iconImage.getAttribute("src") != icon.iconURL)
- iconImage.setAttribute("src", icon.iconURL);
- iconImage.setAttribute("notifBrowserId", notifBrowserId);
-
- iconCounter.collapsed = !icon.counter;
- iconCounter.firstChild.textContent = icon.counter || "";
}
- notifBox.appendChild(notifBrowsers);
- iconBox.appendChild(iconContainers);
},
showAmbientPopup: function SocialToolbar_showAmbientPopup(iconContainer) {
let iconImage = iconContainer.firstChild;
let panel = document.getElementById("social-notification-panel");
- let notifBox = document.getElementById("social-notification-box");
- let notifBrowser = document.getElementById(iconImage.getAttribute("notifBrowserId"));
+ let notifBrowser = document.getElementById("social-notification-browser");
panel.hidden = false;
@@ -382,36 +349,30 @@ var SocialToolbar = {
// FIXME: bug 764787: Maybe we can use nsIDOMWindowUtils.getRootBounds() here?
// Need to handle dynamic sizing
let doc = notifBrowser.contentDocument;
- if (!doc) {
- return;
- }
// "notif" is an implementation detail that we should get rid of
// eventually
- let body = doc.getElementById("notif") || doc.body;
- if (!body || !body.firstChild) {
+ let body = doc.getElementById("notif") || (doc.body && doc.body.firstChild);
+ if (!body)
return;
- }
-
- // Clear dimensions on all browsers so the panel size will
- // only use the selected browser.
- let browserIter = notifBox.firstElementChild;
- while (browserIter) {
- browserIter.hidden = (browserIter != notifBrowser);
- browserIter = browserIter.nextElementSibling;
- }
-
- let [height, width] = [body.firstChild.offsetHeight || 300, 330];
- notifBrowser.style.width = width + "px";
- notifBrowser.style.height = height + "px";
+ let h = body.scrollHeight > 0 ? body.scrollHeight : 300;
+ notifBrowser.style.width = body.scrollWidth + "px";
+ notifBrowser.style.height = h + "px";
}
- sizePanelToContent();
+ notifBrowser.addEventListener("DOMContentLoaded", function onload() {
+ notifBrowser.removeEventListener("DOMContentLoaded", onload);
+ sizePanelToContent();
+ });
panel.addEventListener("popuphiding", function onpopuphiding() {
panel.removeEventListener("popuphiding", onpopuphiding);
+ // unload the panel
SocialToolbar.button.removeAttribute("open");
+ notifBrowser.setAttribute("src", "about:blank");
});
+ notifBrowser.setAttribute("origin", Social.provider.origin);
+ notifBrowser.setAttribute("src", iconImage.getAttribute("contentPanel"));
this.button.setAttribute("open", "true");
panel.openPopup(iconImage, "bottomcenter topleft", 0, 0, false, false);
}
diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul
index 28d74bdc7f33..b1ee6a1a3c45 100644
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -269,7 +269,7 @@
-
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/browser/base/content/test/Makefile.in b/browser/base/content/test/Makefile.in
index 2f353a01900a..bc7593106c1e 100644
--- a/browser/base/content/test/Makefile.in
+++ b/browser/base/content/test/Makefile.in
@@ -64,9 +64,6 @@ endif
# browser_pageInfo.js + feed_tab.html is disabled for leaking (bug 767896)
-# browser_social_shareButton.js is disabled for not properly
-# tearing down the social providers (bug 780010).
-
_BROWSER_FILES = \
head.js \
browser_typeAheadFind.js \
@@ -159,6 +156,7 @@ _BROWSER_FILES = \
browser_bug749738.js \
browser_bug763468.js \
browser_bug767836.js \
+ browser_social_shareButton.js \
browser_canonizeURL.js \
browser_customize.js \
browser_findbarClose.js \
diff --git a/browser/base/content/test/browser_social_mozSocial_API.js b/browser/base/content/test/browser_social_mozSocial_API.js
index 2678e9be1384..0ac4faa30e49 100644
--- a/browser/base/content/test/browser_social_mozSocial_API.js
+++ b/browser/base/content/test/browser_social_mozSocial_API.js
@@ -29,7 +29,7 @@ var tests = {
function triggerIconPanel() {
let statusIcons = document.getElementById("social-status-iconbox");
- ok(!statusIcons.firstChild.hidden, "status icon is visible");
+ ok(!statusIcons.firstChild.collapsed, "status icon is visible");
// Click the button to trigger its contentPanel
let panel = document.getElementById("social-notification-panel");
EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {});
diff --git a/browser/base/content/test/browser_social_toolbar.js b/browser/base/content/test/browser_social_toolbar.js
index 7c12a7ebc4f6..359479261a88 100644
--- a/browser/base/content/test/browser_social_toolbar.js
+++ b/browser/base/content/test/browser_social_toolbar.js
@@ -62,7 +62,7 @@ var tests = {
ok(userButton.hidden, "username is not visible");
let ambience = document.getElementById("social-status-iconbox").firstChild;
while (ambience) {
- ok(ambience.collapsed, "ambient icon (" + ambience.id + ") is collapsed");
+ ok(ambience.collapsed, "ambient icon is collapsed");
ambience = ambience.nextSibling;
}