From d26cfde8913ec49980423e64fd97c65132ffe8d6 Mon Sep 17 00:00:00 2001 From: Shane Caraveo Date: Thu, 17 Mar 2016 18:25:09 -0700 Subject: [PATCH] Bug 1032398 repalce socialShow/Hide with visibility api, r=markh --- browser/base/content/browser-social.js | 6 -- browser/base/content/socialchat.xml | 2 + browser/base/content/socialmarks.xml | 3 - .../test/social/browser_social_flyout.js | 10 +-- .../test/social/browser_social_isVisible.js | 9 +-- .../test/social/browser_social_marks.js | 9 +-- .../test/social/browser_social_sidebar.js | 64 ++++++++++++------- .../test/social/browser_social_status.js | 6 -- 8 files changed, 51 insertions(+), 58 deletions(-) diff --git a/browser/base/content/browser-social.js b/browser/base/content/browser-social.js index 1a6d35f1907d..6c8f694d5425 100644 --- a/browser/base/content/browser-social.js +++ b/browser/base/content/browser-social.js @@ -376,7 +376,6 @@ SocialFlyout = { iframe.docShellIsActive = true; if (iframe.contentDocument.readyState == "complete") { this._dynamicResizer.start(panel, iframe); - this.dispatchPanelEvent("socialFrameShow"); } else { // first time load, wait for load and dispatch after load iframe.addEventListener("load", function panelBrowserOnload(e) { @@ -384,7 +383,6 @@ SocialFlyout = { setTimeout(function() { if (SocialFlyout._dynamicResizer) { // may go null if hidden quickly SocialFlyout._dynamicResizer.start(panel, iframe); - SocialFlyout.dispatchPanelEvent("socialFrameShow"); } }, 0); }, true); @@ -395,7 +393,6 @@ SocialFlyout = { this._dynamicResizer.stop(); this._dynamicResizer = null; this.iframe.docShellIsActive = false; - this.dispatchPanelEvent("socialFrameHide"); }, load: function(aURL, cb) { @@ -838,9 +835,6 @@ SocialSidebar = { if (aEnabled == sbrowser.docShellIsActive) return; sbrowser.docShellIsActive = aEnabled; - let evt = sbrowser.contentDocument.createEvent("CustomEvent"); - evt.initCustomEvent(aEnabled ? "socialFrameShow" : "socialFrameHide", true, true, {}); - sbrowser.contentDocument.documentElement.dispatchEvent(evt); }, updateToggleNotifications: function() { diff --git a/browser/base/content/socialchat.xml b/browser/base/content/socialchat.xml index f01347b259ad..38adec5bd0cf 100644 --- a/browser/base/content/socialchat.xml +++ b/browser/base/content/socialchat.xml @@ -152,6 +152,8 @@ this.content.docShellIsActive = !!val; + // Bug 1256431 to remove socialFrameShow/Hide from hello, keep this + // until that is complete. // let the chat frame know if it is being shown or hidden this.content.messageManager.sendAsyncMessage("Social:CustomEvent", { name: val ? "socialFrameShow" : "socialFrameHide" diff --git a/browser/base/content/socialmarks.xml b/browser/base/content/socialmarks.xml index 927957f9cab5..a9f5ac059fe1 100644 --- a/browser/base/content/socialmarks.xml +++ b/browser/base/content/socialmarks.xml @@ -291,13 +291,11 @@ let sizeSocialPanelToContent = Cu.import("resource:///modules/Social.jsm", {}).sizeSocialPanelToContent; if (!this._loading && this.contentDocument && this.contentDocument.readyState == "complete") { - this.dispatchPanelEvent("socialFrameShow"); if (this._useDynamicResizer) sizeSocialPanelToContent(this.panel, this.content); } else { let panelBrowserOnload = (e) => { this.content.removeEventListener("load", panelBrowserOnload, true); - this.dispatchPanelEvent("socialFrameShow"); if (this._useDynamicResizer) sizeSocialPanelToContent(this.panel, this.content); }; @@ -350,7 +348,6 @@ this.onShown(); ]]> { + // First check the the sidebar is initially visible, and loaded + ok(!command.hidden, "toggle command should be visible"); + let mm = getGroupMessageManager("social"); + mm.addMessageListener("visibility", function shown(msg) { + if (msg.data == "shown") { + mm.removeMessageListener("visibility", shown); + checkShown(true); + info("Toggling sidebar to closed"); + SocialSidebar.toggleSidebar(); + } + }); + mm.addMessageListener("visibility", function handler(msg) { + if (msg.data == "hidden") { + mm.removeMessageListener("visibility", handler); + // disable social. + SocialService.disableProvider(SocialSidebar.provider.origin, function() { + checkShown(false); + is(Social.providers.length, 0, "no providers left"); + defaultFinishChecks(); + // Finish the test + executeSoon(finish); + }); + } }); - - // Toggle it back on - info("Toggling sidebar back on"); - SocialSidebar.toggleSidebar(); }); SocialSidebar.show(); } diff --git a/browser/base/content/test/social/browser_social_status.js b/browser/base/content/test/social/browser_social_status.js index 66c207d2baab..d6e0c8d0ec19 100644 --- a/browser/base/content/test/social/browser_social_status.js +++ b/browser/base/content/test/social/browser_social_status.js @@ -39,12 +39,6 @@ function test() { waitForExplicitFinish(); let frameScript = "data:,(" + function frame_script() { - addEventListener("socialFrameShow", function(e) { - sendAsyncMessage("visibility", "shown"); - }, false); - addEventListener("socialFrameHide", function(e) { - sendAsyncMessage("visibility", "hidden"); - }, false); addMessageListener("socialTest-sendEvent", function(msg) { let data = msg.data; let evt = content.document.createEvent("CustomEvent");