Bug 793935 - tests for closing social chat windows on logout. r=jaws
authorMark Hammond <mhammond@skippinet.com.au>
Wed, 26 Sep 2012 09:32:27 +1000
changeset 108196 c23f6a95cdb31c46c704da8a08339c89efeb11c6
parent 108195 4fcabe5f5ca599c1a92773c1f6d426c28668b3e5
child 108197 ac6eab3c5aa70e6524608f1a10038f5a56e51bc7
push id82
push usershu@rfrn.org
push dateFri, 05 Oct 2012 13:20:22 +0000
reviewersjaws
bugs793935
milestone18.0a1
Bug 793935 - tests for closing social chat windows on logout. r=jaws
browser/base/content/test/browser_social_chatwindow.js
browser/base/content/test/social_worker.js
--- a/browser/base/content/test/browser_social_chatwindow.js
+++ b/browser/base/content/test/browser_social_chatwindow.js
@@ -110,10 +110,29 @@ var tests = {
           ok(!chats.selectedChat, "chats are all closed");
           port.close();
           ensureSocialUrlNotRemembered(chatUrl);
           next();
           break;
       }
     }
     port.postMessage({topic: "test-worker-chat", data: chatUrl});
+  },
+  testCloseOnLogout: function(next) {
+    const chatUrl = "https://example.com/browser/browser/base/content/test/social_chat.html";
+    let port = Social.provider.getWorkerPort();
+    ok(port, "provider has a port");
+    port.postMessage({topic: "test-init"});
+    port.onmessage = function (e) {
+      let topic = e.data.topic;
+      switch (topic) {
+        case "got-chatbox-message":
+          ok(true, "got a chat window opened");
+          port.postMessage({topic: "test-logout"});
+          waitForCondition(function() document.getElementById("pinnedchats").firstChild == null,
+                           next,
+                           "chat windows didn't close");
+          break;
+      }
+    }
+    port.postMessage({topic: "test-worker-chat", data: chatUrl});
   }
 }
--- a/browser/base/content/test/social_worker.js
+++ b/browser/base/content/test/social_worker.js
@@ -8,16 +8,19 @@ onconnect = function(e) {
   let port = e.ports[0];
   port.onmessage = function onMessage(event) {
     let topic = event.data.topic;
     switch (topic) {
       case "test-init":
         testPort = port;
         port.postMessage({topic: "test-init-done"});
         break;
+      case "test-logout":
+        apiPort.postMessage({topic: "social.user-profile", data: {}});
+        break;
       case "sidebar-message":
         sidebarPort = port;
         if (testPort && event.data.result == "ok")
           testPort.postMessage({topic:"got-sidebar-message"});
         break;
       case "service-window-message":
         testPort.postMessage({topic:"got-service-window-message",
                               location: event.data.location});