diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index 532937dd9100..973f5ab83921 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -1006,6 +1006,7 @@ var SocialSidebar = { let sbrowser = document.getElementById("social-sidebar-browser"); if (hideSidebar) { + sbrowser.removeEventListener("load", SocialSidebar._loadListener, true); this.setSidebarVisibilityState(false); // If we've been disabled, unload the sidebar content immediately; // if the sidebar was just toggled to invisible, wait a timeout @@ -1028,19 +1029,19 @@ var SocialSidebar = { if (sbrowser.getAttribute("origin") != Social.provider.origin) { sbrowser.setAttribute("origin", Social.provider.origin); sbrowser.setAttribute("src", Social.provider.sidebarURL); - sbrowser.addEventListener("load", function sidebarOnShow() { - sbrowser.removeEventListener("load", sidebarOnShow, true); - // let load finish, then fire our event - setTimeout(function () { - SocialSidebar.setSidebarVisibilityState(true); - }, 0); - }, true); + sbrowser.addEventListener("load", SocialSidebar._loadListener, true); } else { this.setSidebarVisibilityState(true); } } }, + _loadListener: function SocialSidebar_loadListener() { + let sbrowser = document.getElementById("social-sidebar-browser"); + sbrowser.removeEventListener("load", SocialSidebar._loadListener, true); + SocialSidebar.setSidebarVisibilityState(true); + }, + unloadSidebar: function SocialSidebar_unloadSidebar() { let sbrowser = document.getElementById("social-sidebar-browser"); if (!sbrowser.hasAttribute("origin"))