Backed out changeset bfe0d5c41edd (bug 1014332)
authorEd Morley <emorley@mozilla.com>
Thu, 21 Aug 2014 12:27:12 +0100
changeset 200818 3b1781bae995c7b96cc4c3e2aa309c6344c0f86b
parent 200816 f734fbcc3de7c68bdf72b7635ca1fc5b219fe20a
child 200819 ac0454b42fe4b14c2718d236528086516a4bee90
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs1014332
milestone34.0a1
backs outbfe0d5c41edd3a56b5d8f5e3d5a2f5963bd7f203
Backed out changeset bfe0d5c41edd (bug 1014332)
browser/base/content/test/social/browser_aboutHome_activation.js
browser/base/content/test/social/browser_social_chatwindow.js
browser/base/content/test/social/browser_social_errorPage.js
--- a/browser/base/content/test/social/browser_aboutHome_activation.js
+++ b/browser/base/content/test/social/browser_aboutHome_activation.js
@@ -14,17 +14,17 @@ XPCOMUtils.defineLazyModuleGetter(this, 
 let snippet =
 '     <script>' +
 '       var manifest = {' +
 '         "name": "Demo Social Service",' +
 '         "origin": "https://example.com",' +
 '         "iconURL": "chrome://branding/content/icon16.png",' +
 '         "icon32URL": "chrome://branding/content/favicon32.png",' +
 '         "icon64URL": "chrome://branding/content/icon64.png",' +
-'         "sidebarURL": "https://example.com/browser/browser/base/content/test/social/social_sidebar_empty.html",' +
+'         "sidebarURL": "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",' +
 '         "postActivationURL": "https://example.com/browser/browser/base/content/test/social/social_postActivation.html",' +
 '       };' +
 '       function activateProvider(node) {' +
 '         node.setAttribute("data-service", JSON.stringify(manifest));' +
 '         var event = new CustomEvent("ActivateSocialFeature");' +
 '         node.dispatchEvent(event);' +
 '       }' +
 '     </script>' +
@@ -36,17 +36,17 @@ let snippet =
 let snippet2 =
 '     <script>' +
 '       var manifest = {' +
 '         "name": "Demo Social Service",' +
 '         "origin": "https://example.com",' +
 '         "iconURL": "chrome://branding/content/icon16.png",' +
 '         "icon32URL": "chrome://branding/content/favicon32.png",' +
 '         "icon64URL": "chrome://branding/content/icon64.png",' +
-'         "sidebarURL": "https://example.com/browser/browser/base/content/test/social/social_sidebar_empty.html",' +
+'         "sidebarURL": "https://example.com/browser/browser/base/content/test/social/social_sidebar.html",' +
 '         "postActivationURL": "https://example.com/browser/browser/base/content/test/social/social_postActivation.html",' +
 '         "oneclick": true' +
 '       };' +
 '       function activateProvider(node) {' +
 '         node.setAttribute("data-service", JSON.stringify(manifest));' +
 '         var event = new CustomEvent("ActivateSocialFeature");' +
 '         node.dispatchEvent(event);' +
 '       }' +
--- a/browser/base/content/test/social/browser_social_chatwindow.js
+++ b/browser/base/content/test/social/browser_social_chatwindow.js
@@ -29,24 +29,24 @@ let manifests = [
 ];
 
 let chatId = 0;
 function openChat(provider, callback) {
   let chatUrl = provider.origin + "/browser/browser/base/content/test/social/social_chat.html";
   let port = provider.getWorkerPort();
   port.onmessage = function(e) {
     if (e.data.topic == "got-chatbox-message") {
+      port.close();
       callback();
     }
   }
   let url = chatUrl + "?" + (chatId++);
   port.postMessage({topic: "test-init"});
   port.postMessage({topic: "test-worker-chat", data: url});
   gURLsNotRemembered.push(url);
-  return port;
 }
 
 function windowHasChats(win) {
   return !!getChatBar().firstElementChild;
 }
 
 function test() {
   requestLongerTimeout(2); // only debug builds seem to need more time...
@@ -167,19 +167,16 @@ var tests = {
 
   // Check what happens when you close the only visible chat.
   testCloseOnlyVisible: function(next) {
     let chatbar = getChatBar();
     let chatWidth = undefined;
     let num = 0;
     is(chatbar.childNodes.length, 0, "chatbar starting empty");
     is(chatbar.menupopup.childNodes.length, 0, "popup starting empty");
-    let port = SocialSidebar.provider.getWorkerPort();
-    ok(port, "provider has a port");
-    port.postMessage({topic: "test-init"});
 
     makeChat("normal", "first chat", function() {
       // got the first one.
       checkPopup();
       ok(chatbar.menupopup.parentNode.collapsed, "menu selection isn't visible");
       // we kinda cheat here and get the width of the first chat, assuming
       // that all future chats will have the same width when open.
       chatWidth = chatbar.calcTotalWidthOf(chatbar.selectedChat);
@@ -193,17 +190,16 @@ var tests = {
           let second = chatbar.childNodes[1];
           is(chatbar.selectedChat, first, "first chat is selected");
           ok(second.collapsed, "second chat is currently collapsed");
           // closing the first chat will leave enough room for the second
           // chat to appear, and thus become selected.
           chatbar.selectedChat.close();
           is(chatbar.selectedChat, second, "second chat is selected");
           closeAllChats();
-          port.close();
           next();
         });
       });
     });
   },
 
   testShowWhenCollapsed: function(next) {
     let port = SocialSidebar.provider.getWorkerPort();
@@ -242,34 +238,34 @@ var tests = {
           });
       }
     }
     port.postMessage({topic: "test-init", data: { id: 1 }});
   },
 
   testMultipleProviderChat: function(next) {
     // test incomming chats from all providers
-    let port0 = openChat(Social.providers[0], function() {
-      let port1 = openChat(Social.providers[1], function() {
-        let port2 = openChat(Social.providers[2], function() {
+    openChat(Social.providers[0], function() {
+      openChat(Social.providers[1], function() {
+        openChat(Social.providers[2], function() {
           let chats = document.getElementById("pinnedchats");
           waitForCondition(function() chats.children.length == Social.providers.length,
             function() {
               ok(true, "one chat window per provider opened");
               // test logout of a single provider
-              port2.postMessage({topic: "test-logout"});
+              let provider = Social.providers[2];
+              let port = provider.getWorkerPort();
+              port.postMessage({topic: "test-logout"});
               waitForCondition(function() chats.children.length == Social.providers.length - 1,
                 function() {
                   closeAllChats();
                   waitForCondition(function() chats.children.length == 0,
                                    function() {
                                     ok(!chats.selectedChat, "multiprovider chats are all closed");
-                                    port0.close();
-                                    port1.close();
-                                    port2.close();
+                                    port.close();
                                     next();
                                    },
                                    "chat windows didn't close");
                 },
                 "chat window didn't close");
             }, "chat windows did not open");
         });
       });
--- a/browser/base/content/test/social/browser_social_errorPage.js
+++ b/browser/base/content/test/social/browser_social_errorPage.js
@@ -31,26 +31,20 @@ function goOnline(callback) {
     BrowserOffline.toggleOfflineStatus();
   if (callback)
     callback();
 }
 
 function openPanel(url, panelCallback, loadCallback) {
   // open a flyout
   SocialFlyout.open(url, 0, panelCallback);
-  // wait for both open and loaded before callback. Since the test doesn't close
-  // the panel between opens, we cannot rely on events here. We need to ensure
-  // popupshown happens before we finish out the tests.
-  waitForCondition(function() {
-                    return SocialFlyout.panel.state == "open" &&
-                           SocialFlyout.iframe.contentDocument.readyState == "complete";
-                   },
-                   loadCallback,
-                   "flyout is open and loaded");
-
+  SocialFlyout.panel.firstChild.addEventListener("load", function panelLoad() {
+    SocialFlyout.panel.firstChild.removeEventListener("load", panelLoad, true);
+    loadCallback();
+  }, true);
 }
 
 function openChat(url, panelCallback, loadCallback) {
   // open a chat window
   let chatbar = getChatBar();
   openChatWindow(null, SocialSidebar.provider, url, panelCallback);
   chatbar.firstChild.addEventListener("DOMContentLoaded", function panelLoad() {
     chatbar.firstChild.removeEventListener("DOMContentLoaded", panelLoad, true);
@@ -184,20 +178,16 @@ var tests = {
       }
     );
   },
 
   testChatWindowAfterTearOff: function(next) {
     // Ensure that the error listener survives the chat window being detached.
     let url = "https://example.com/browser/browser/base/content/test/social/social_chat.html";
     let panelCallbackCount = 0;
-    // chatwindow tests throw errors, which muddy test output, if the worker
-    // doesn't get test-init
-    let port = SocialSidebar.provider.getWorkerPort();
-    port.postMessage({topic: "test-init"});
     // open a chat while we are still online.
     openChat(
       url,
       null,
       function() { // the "load" callback.
         executeSoon(function() {
           let chat = getChatBar().selectedChat;
           is(chat.contentDocument.location.href, url, "correct url loaded");
@@ -205,17 +195,16 @@ var tests = {
           chat.swapWindows().then(
             chat => {
               // now go offline and reload the chat - about:socialerror should be loaded.
               goOffline();
               chat.contentDocument.location.reload();
               waitForCondition(function() chat.contentDocument.location.href.indexOf("about:socialerror?")==0,
                                function() {
                                 chat.close();
-                                port.close();
                                 next();
                                 },
                                "error page didn't appear");
             }
           );
         });
       }
     );